-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSuperheroPlugin.cs
More file actions
58 lines (43 loc) · 1.8 KB
/
SuperheroPlugin.cs
File metadata and controls
58 lines (43 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using CounterStrikeSharp.API;
using CounterStrikeSharp.API.Core;
namespace SuperheroPlugin;
public partial class SuperheroPlugin : BasePlugin
{
public override string ModuleName => "Superhero plugin";
public override string ModuleVersion => "0.0.13";
public int XpPerKill = 10;
public float XpHeadshotMultiplier = 1.5f;
public float XpKnifeMultiplier = 3f;
public float XpAssistMultiplier = 0.3f;
public int maxLevel = 10;
public List<int> xpCurve = new();
public Dictionary<IntPtr, SuperheroPlayer> SuperheroPlayers = new();
public List<SuperheroPlayer> Players => SuperheroPlayers.Values.ToList();
public AbilityManager AbilityManager = new AbilityManager();
public override void Load(bool hotReload)
{
Console.WriteLine(string.Format("Loaded : {0}, Version: {1}", this.ModuleName, this.ModuleVersion));
// Register listeners
RegisterListener<Listeners.OnClientConnected>(OnClientPutInServerHandler);
RegisterListener<Listeners.OnClientDisconnect>(OnClientDisconnectHandler);
//Setup methods
SuperheroSetup.SetupCommands(this);
this.xpCurve = SuperheroUtilities.generateXpLevelCurve(this.maxLevel);
}
private void OnClientPutInServerHandler(int slot)
{
var player = Utilities.GetPlayerFromSlot(slot);
if (!player.IsValid || player.IsBot) return;
SuperheroPlayers[player.Handle] = new SuperheroPlayer(player, this.xpCurve, this.maxLevel);
}
private void OnClientDisconnectHandler(int slot)
{
var player = Utilities.GetPlayerFromSlot(slot);
if (!player.IsValid || player.IsBot) return;
RemoveShPlayer(player);
}
public void RemoveShPlayer(CCSPlayerController player)
{
SuperheroPlayers.Remove(player.Handle);
}
}