Skip to content

Commit 4325cbd

Browse files
authored
Add files via upload
1 parent 7778fad commit 4325cbd

File tree

5 files changed

+282
-10
lines changed

5 files changed

+282
-10
lines changed

Config.cs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,35 @@ public class ConfigBan : BasePluginConfig
3535
[JsonPropertyName("Enable_Credits_Defuse")] public bool More_Credit3 { get; set; } = true;
3636
[JsonPropertyName("Credits_Defuse")] public int Credits_For_Defuse { get; set; } = 50;
3737

38-
[JsonPropertyName("StartHealth")] public int StartHealth { get; set; } = 110;
38+
[JsonPropertyName("EnabledBhop")] public bool EnabledBhop { get; set; } = true;
39+
[JsonPropertyName("EnabledTrails")] public bool EnabledTrails { get; set; } = true;
40+
[JsonPropertyName("EnabledShotTrails")] public bool EnabledShotTrails { get; set; } = true;
41+
[JsonPropertyName("EnabledGuns")] public bool EnabledGuns { get; set; } = true;
42+
[JsonPropertyName("EnabledQuake")] public bool EnabledQuake { get; set; } = false;
43+
[JsonPropertyName("EnabledFallDamage")] public bool FallDamage { get; set; } = true;
44+
[JsonPropertyName("EnabledNoKnifeDamage")] public bool NoKnifeDamage { get; set; } = true;
45+
[JsonPropertyName("EnabledModels")] public bool ModelsEnabled { get; set; } = true;
46+
[JsonPropertyName("EnabledDoubbleJump")] public bool EnabledDoubbleJump { get; set; } = true;
47+
[JsonPropertyName("EnabledInstantReload")] public bool EnabledInstantReload { get; set; } = true;
48+
[JsonPropertyName("QuakeTeamKiller")] public string QuakeTeamKiller { get; set; } = "sounds/madgamessounds/quake/teamkiller.vsnd_c";
49+
[JsonPropertyName("QuakeHeadShot")] public string QuakeHeadShot { get; set; } = "sounds/madgamessounds/quake/headshot.vsnd_c";
50+
51+
public List<Sound> Sounds { get; set; } = new List<Sound>
52+
{
53+
new Sound { Kill = 1, Path = "sounds/madgamessounds/quake/firstblood.vsnd_c" },
54+
new Sound { Kill = 2, Path = "sounds/madgamessounds/quake/doublekill.vsnd_c" },
55+
new Sound { Kill = 3, Path = "sounds/madgamessounds/quake/triplekill.vsnd_c" },
56+
};
3957

58+
[JsonPropertyName("StartHealth")] public int StartHealth { get; set; } = 110;
4059
[JsonPropertyName("MinRoundForGuns")] public int MinRoundForGuns { get; set; } = 2;
4160

61+
}
62+
public class Sound
63+
{
64+
[JsonPropertyName("quake_kill")]
65+
public required int Kill { get; init; }
66+
67+
[JsonPropertyName("path")]
68+
public required string Path { get; init; }
4269
}

CustomPlugin.cs

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,27 @@ public partial class CustomPlugin : BasePlugin, IPluginConfig<ConfigBan>
5656
public CounterStrikeSharp.API.Modules.Timers.Timer? timer_ac;
5757
private static readonly int?[] UserTrialColor = new int?[64];
5858
private static readonly int?[] CreditEnable = new int?[64];
59+
private static readonly int?[] JumpEnable = new int?[64];
5960
private static readonly int?[] ShotsEnable = new int?[64];
61+
private static readonly int?[] BhopEnable = new int?[64];
62+
private static readonly int?[] QuakeEnable = new int?[64];
6063
private static readonly int?[] KillCount = new int?[64];
6164
private static readonly int?[] Selected = new int?[64];
6265
private static readonly int?[] Selected_round = new int?[64];
6366
private static readonly int?[] Selectedr = new int?[64];
6467

65-
private static readonly int?[] Trials = new int?[64];
68+
private static readonly int?[] IReload = new int?[64];
69+
private static readonly int?[] DJump = new int?[64];
70+
private static readonly int?[] Trails = new int?[64];
6671
private static readonly int?[] NadeEnable = new int?[64];
67-
private static readonly int?[] NadeTrials = new int?[64];
72+
private static readonly int?[] NadeTrails = new int?[64];
6873
private static readonly int?[] CSStore = new int?[64];
74+
private static readonly int?[] SelectedModel = new int?[64];
6975
private static readonly int?[] LaserShot = new int?[64];
7076
private static readonly int?[] Healthshot = new int?[64];
7177
private static readonly int?[] Guns = new int?[64];
78+
private static readonly int?[] falldmg = new int?[64];
79+
private static readonly int?[] knife = new int?[64];
7280
private static readonly int?[] Bhop = new int?[64];
7381
private static readonly int?[] Health = new int?[64];
7482
private static readonly int?[] Models = new int?[64];
@@ -191,9 +199,10 @@ public void CreateDatabase()
191199

192200

193201

194-
MySql.ExecuteNonQueryAsync(@"CREATE TABLE IF NOT EXISTS `deadswim_settings` (`id` INT AUTO_INCREMENT PRIMARY KEY, `steamid` VARCHAR(32) UNIQUE NOT NULL, `enable_quake` INT(11) NOT NULL, `free_vip` INT(11) NOT NULL, `shots` INT(11) NOT NULL, `enable_nade` INT(11) NOT NULL, `trials` INT(11) NOT NULL, `guns` INT(11) NOT NULL, `credits` VARCHAR(255) NOT NULL, UNIQUE (`steamid`));");
195-
MySql.ExecuteNonQueryAsync(@"CREATE TABLE IF NOT EXISTS `deadswim_vip` (`id` INT AUTO_INCREMENT PRIMARY KEY, `steamid` VARCHAR(32) UNIQUE NOT NULL, `healthshot` INT(11) NOT NULL, `nade` INT(11) NOT NULL, `store_credit` INT(11) NOT NULL, `trials` INT(11) NOT NULL, `shotlaser` INT(11) NOT NULL, `guns` INT(11) NOT NULL, `bhop` INT(11) NOT NULL, `models` INT(11) NOT NULL, `health` INT(11) NOT NULL, `bomb` INT(11) NOT NULL, `mvip` INT(11) NOT NULL, `timestamp` INT(11) NOT NULL, UNIQUE (`steamid`));");
196-
MySql.ExecuteNonQueryAsync(@$"CREATE TABLE IF NOT EXISTS `deadswim_users_key_vip` (`id` INT AUTO_INCREMENT PRIMARY KEY, `token` VARCHAR(32) UNIQUE NOT NULL, `end` INT(11) NOT NULL, `group` INT(11) NOT NULL, UNIQUE (`token`));");
202+
MySql.ExecuteNonQueryAsync(@"CREATE TABLE IF NOT EXISTS `deadswim_settings` (`id` INT AUTO_INCREMENT PRIMARY KEY, `steamid` VARCHAR(32) UNIQUE NOT NULL, `enable_quake` INT(11) NOT NULL, `enable_djump` INT(11) NOT NULL, `model` INT(11) NOT NULL, `bhop` INT(11) NOT NULL, `free_vip` INT(11) NOT NULL, `shots` INT(11) NOT NULL, `enable_nade` INT(11) NOT NULL, `trials` INT(11) NOT NULL, `guns` INT(11) NOT NULL, `credits` VARCHAR(255) NOT NULL, UNIQUE (`steamid`));");
203+
MySql.ExecuteNonQueryAsync(@"CREATE TABLE IF NOT EXISTS `deadswim_vip` (`id` INT AUTO_INCREMENT PRIMARY KEY, `steamid` VARCHAR(32) UNIQUE NOT NULL, `healthshot` INT(11) NOT NULL, `reload` INT(11) NOT NULL, `jump` INT(11) NOT NULL, `falldmg` INT(11) NOT NULL, `knife` INT(11) NOT NULL, `nade` INT(11) NOT NULL, `store_credit` INT(11) NOT NULL, `trials` INT(11) NOT NULL, `shotlaser` INT(11) NOT NULL, `guns` INT(11) NOT NULL, `bhop` INT(11) NOT NULL, `models` INT(11) NOT NULL, `health` INT(11) NOT NULL, `bomb` INT(11) NOT NULL, `mvip` INT(11) NOT NULL, `timestamp` INT(11) NOT NULL, UNIQUE (`steamid`));");
204+
MySql.ExecuteNonQueryAsync(@"CREATE TABLE IF NOT EXISTS `deadswim_users_key_vip` (`id` INT AUTO_INCREMENT PRIMARY KEY, `token` VARCHAR(32) UNIQUE NOT NULL, `end` INT(11) NOT NULL, `group` INT(11) NOT NULL, UNIQUE (`token`));");
205+
MySql.ExecuteNonQueryAsync(@$"CREATE TABLE IF NOT EXISTS `deadswim_models` (`id` INT AUTO_INCREMENT PRIMARY KEY, `name` VARCHAR(32) UNIQUE NOT NULL, `permission` VARCHAR(32) NOT NULL, `side` VARCHAR(32) UNIQUE NOT NULL, `path` VARCHAR(128) UNIQUE NOT NULL, UNIQUE (`id`));");
197206

198207
}
199208
catch (Exception ex)
@@ -417,6 +426,7 @@ public void CommandActivator(CCSPlayerController? player, CommandInfo info)
417426
.Add("bhop", "1")
418427
.Add("health", "1")
419428
.Add("bomb", "1")
429+
.Add("knife", "1")
420430
.Add("timestamp", $"{timeofvip}");
421431
int rowsAffected = MySql.Table("deadswim_vip").Where($"steamid = '{SteamIDC}'").Update(values);
422432
}
@@ -432,7 +442,11 @@ public void CommandActivator(CCSPlayerController? player, CommandInfo info)
432442
.Add("bhop", "1")
433443
.Add("health", "1")
434444
.Add("bomb", "1")
445+
.Add("falldmg", "1")
446+
.Add("knife", "1")
435447
.Add("mvip", "1")
448+
.Add("jump", "1")
449+
.Add("reloading", "1")
436450
.Add("timestamp", $"{timeofvip}");
437451
int rowsAffected = MySql.Table("deadswim_vip").Where($"steamid = '{SteamIDC}'").Update(values);
438452
}
@@ -516,6 +530,7 @@ public void addvip(CCSPlayerController? player, CommandInfo info)
516530
.Add("bhop", "1")
517531
.Add("health", "1")
518532
.Add("bomb", "1")
533+
.Add("knife", "1")
519534
.Add("timestamp", $"{timeofvip}");
520535
int rowsAffected = MySql.Table("deadswim_vip").Where($"steamid = '{SteamIDC}'").Update(values);
521536
info.ReplyToCommand($" {Config.Prefix} VIP has been activated on SteamID {SteamIDC}");
@@ -533,6 +548,10 @@ public void addvip(CCSPlayerController? player, CommandInfo info)
533548
.Add("health", "1")
534549
.Add("bomb", "1")
535550
.Add("mvip", "1")
551+
.Add("falldmg", "1")
552+
.Add("knife", "1")
553+
.Add("jump", "1")
554+
.Add("reloading", "1")
536555
.Add("timestamp", $"{timeofvip}");
537556
int rowsAffected = MySql.Table("deadswim_vip").Where($"steamid = '{SteamIDC}'").Update(values);
538557
info.ReplyToCommand($" {Config.Prefix} VIP has been ativated on SteamID {SteamIDC}");
@@ -615,7 +634,7 @@ public void OnTick(CCSPlayerController controller)
615634
return;
616635
if (buttons != 0 || (flags & PlayerFlags.FL_ONGROUND) != 0)
617636
{
618-
if (Trials[client] == 1)
637+
if (Trails[client] == 1)
619638
{
620639
//CounterStrikeSharp.API.Modules.Utils.Vector player_vec = pawn?.AbsOrigin!;
621640
//CounterStrikeSharp.API.Modules.Utils.Vector end_pos = new CounterStrikeSharp.API.Modules.Utils.Vector(player_vec.X + 5.0f, player_vec.Y + 5.0f, player_vec.Z + 5.0f);
@@ -687,7 +706,7 @@ public void LoadVIP(CCSPlayerController player)
687706
player.PrintToChat($" {Config.Prefix} {Localizer["VIPRemaining"]} : {ChatColors.Lime}{timeRemainingFormatted}");
688707
player.PrintToChat($" {Config.Prefix} {ChatColors.Red}------------------------");
689708

690-
Server.PrintToConsole($"CustomPlugins - Hráč {player.PlayerName} Má = HS = {Healthshot[player.Index]} TR = {Trials[player.Index]}, Bhop = {Bhop[player.Index]}");
709+
Server.PrintToConsole($"CustomPlugins - Hráč {player.PlayerName} Má = HS = {Healthshot[player.Index]} TR = {Trails[player.Index]}, Bhop = {Bhop[player.Index]}");
691710
if (Guns[client] == 1)
692711
{
693712
AdminManager.AddPlayerPermissions(player, "@vip/basic");
@@ -716,8 +735,12 @@ public void SaveSettings(CCSPlayerController player)
716735
MySqlQueryValue values = new MySqlQueryValue()
717736
.Add("trials", $"{UserTrialColor[client]}")
718737
.Add("guns", $"{Selected[client]}")
738+
.Add("bhop", $"{BhopEnable[client]}")
719739
.Add("enable_nade", $"{NadeEnable[client]}")
740+
.Add("enable_quake", $"{QuakeEnable[client]}")
720741
.Add("shots", $"{ShotsEnable[client]}")
742+
.Add("enable_djump", $"{JumpEnable[client]}")
743+
.Add("model", $"{SelectedModel[client]}")
721744
.Add("credits", $"{CreditEnable[client]}");
722745
int rowsAffected = MySql.Table("deadswim_settings").Where($"steamid = '{player.SteamID.ToString()}'").Update(values);
723746

@@ -737,15 +760,19 @@ public void LoadPlayerData_VIP(CCSPlayerController player)
737760

738761
Healthshot[player.Index] = result.Get<int>(0, "healthshot");
739762
CSStore[player.Index] = result.Get<int>(0, "store_credit");
740-
Trials[player.Index] = result.Get<int>(0, "trials");
763+
Trails[player.Index] = result.Get<int>(0, "trials");
741764
LaserShot[player.Index] = result.Get<int>(0, "shotlaser");
742-
NadeTrials[player.Index] = result.Get<int>(0, "nade");
765+
NadeTrails[player.Index] = result.Get<int>(0, "nade");
743766
Guns[player.Index] = result.Get<int>(0, "guns");
744767
Bhop[player.Index] = result.Get<int>(0, "bhop");
745768
Health[player.Index] = result.Get<int>(0, "health");
746769
Models[player.Index] = result.Get<int>(0, "models");
747770
Bomb_a[player.Index] = result.Get<int>(0, "bomb");
748771
MVIP[player.Index] = result.Get<int>(0, "mvip");
772+
knife[player.Index] = result.Get<int>(0, "knife");
773+
falldmg[player.Index] = result.Get<int>(0, "falldmg");
774+
DJump[player.Index] = result.Get<int>(0, "jump");
775+
IReload[player.Index] = result.Get<int>(0, "reloading");
749776
Timestamp[player.Index] = result.Get<int>(0, "timestamp");
750777

751778
LoadVIP(player);
@@ -765,7 +792,11 @@ public void LoadPlayerData_VIP(CCSPlayerController player)
765792
.Add("bhop", "0")
766793
.Add("health", "0")
767794
.Add("bomb", "0")
795+
.Add("knife", "0")
796+
.Add("falldmg", "0")
768797
.Add("mvip", "0")
798+
.Add("jump", "0")
799+
.Add("reloading", "0")
769800
.Add("timestamp", "-1");
770801
int rowsAffected = MySql.Table("deadswim_vip").Where($"steamid = '{player.SteamID.ToString()}'").Update(values);
771802
UnLoadVIP(player);
@@ -791,7 +822,11 @@ public void LoadPlayerData_VIP(CCSPlayerController player)
791822
.Add("health", "0")
792823
.Add("models", "0")
793824
.Add("bomb", "0")
825+
.Add("knife", "0")
826+
.Add("falldmg", "0")
794827
.Add("mvip", "0")
828+
.Add("jump", "0")
829+
.Add("reloading", "0")
795830
.Add("timestamp", "-1");
796831
MySql.Table("deadswim_vip").Insert(values);
797832
}
@@ -810,9 +845,13 @@ public void LoadPlayerData(CCSPlayerController player)
810845
{
811846
UserTrialColor[player.Index] = result.Get<int>(0, "trials");
812847
CreditEnable[player.Index] = result.Get<int>(0, "credits");
848+
BhopEnable[player.Index] = result.Get<int>(0, "bhop");
813849
ShotsEnable[player.Index] = result.Get<int>(0, "shots");
814850
NadeEnable[player.Index] = result.Get<int>(0, "enable_nade");
851+
JumpEnable[player.Index] = result.Get<int>(0, "enable_djump");
852+
QuakeEnable[player.Index] = result.Get<int>(0, "enable_quake");
815853
Selected[player.Index] = result.Get<int>(0, "guns");
854+
SelectedModel[player.Index] = result.Get<int>(0, "model");
816855
}
817856
else
818857
{
@@ -822,9 +861,12 @@ public void LoadPlayerData(CCSPlayerController player)
822861
.Add("steamid", player.SteamID.ToString())
823862
.Add("shots", "0")
824863
.Add("trials", "0")
864+
.Add("bhop", "0")
865+
.Add("enable_djump", "0")
825866
.Add("enable_nade", "0")
826867
.Add("enable_quake", "0")
827868
.Add("free_vip", "0")
869+
.Add("model", "0")
828870
.Add("credits", "1")
829871
.Add("guns", "0");
830872
MySql.Table("deadswim_settings").Insert(values);

CustomPlugin.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
<TargetFramework>net8.0</TargetFramework>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
7+
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
78
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
9+
<OutputPath>$(ProjectDir)..\BuildOutput\plugins\CustomPlugin\</OutputPath>
10+
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
811
</PropertyGroup>
912

1013
<ItemGroup>

Hooks.cs

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,93 @@ public HookResult KillPlayer(EventPlayerDeath @event, GameEventInfo info)
113113
}
114114
}
115115

116+
return HookResult.Continue;
117+
}
118+
public HookResult OnPlayerDeath(EventPlayerDeath @event, GameEventInfo info)
119+
{
120+
if (@event == null) return HookResult.Continue;
121+
122+
var vic = @event.Userid;
123+
var vic_client = (int)vic!.Index;
124+
var att = @event.Attacker;
125+
var att_client = (int)att!.Index;
126+
var headshot = @event.Headshot;
127+
if (vic == null) return HookResult.Continue;
128+
if (att == null) return HookResult.Continue;
129+
if (att.IsBot) return HookResult.Continue;
130+
if (vic == att) return HookResult.Continue;
131+
if (att != vic)
132+
{
133+
if (Config.EnabledQuake)
134+
{
135+
if (QuakeEnable[att_client] == 1)
136+
{
137+
KillCount[att_client]++;
138+
if (headshot)
139+
{
140+
att.ExecuteClientCommand($"play {Config.QuakeHeadShot}");
141+
}
142+
else
143+
{
144+
if (att.TeamNum == vic.TeamNum)
145+
{
146+
att.ExecuteClientCommand($"play {Config.QuakeTeamKiller}");
147+
}
148+
else
149+
{
150+
foreach (var sound in Config.Sounds)
151+
{
152+
153+
154+
var sound_kill = sound.Kill;
155+
var sound_path = sound.Path;
156+
157+
if (KillCount[att_client] == sound.Kill)
158+
{
159+
att.ExecuteClientCommand($"play {sound_path}");
160+
}
161+
}
162+
}
163+
}
164+
}
165+
}
166+
}
167+
168+
return HookResult.Continue;
169+
}
170+
[GameEventHandler]
171+
public HookResult OnPlayerHurt(EventPlayerHurt @event, GameEventInfo info)
172+
{
173+
var attacker = @event.Attacker;
174+
var victim = @event.Userid;
175+
var weapon = @event.Weapon;
176+
if (weapon.Contains("knife"))
177+
{
178+
if (Config.NoKnifeDamage)
179+
{
180+
if (knife[victim.Index] == 1)
181+
{
182+
var health_taked = @event.DmgHealth;
183+
victim.PlayerPawn.Value!.Health = health_taked + victim.PlayerPawn.Value.Health;
184+
attacker.PrintToChat($" {Config.Prefix} {Localizer["VIPDMGKnife"]}");
185+
return HookResult.Continue;
186+
}
187+
}
188+
}
189+
if (Config.FallDamage)
190+
{
191+
if (falldmg[victim.Index] == 1)
192+
{
193+
if (@event.Hitgroup == 0 && @event.Weapon != "inferno" && @event.Weapon != "hegrenade" && @event.Weapon != "knife" && @event.Weapon != "decoy")
194+
{
195+
var health_taked = @event.DmgHealth;
196+
victim.PlayerPawn.Value!.Health = health_taked + victim.PlayerPawn.Value.Health;
197+
return HookResult.Continue;
198+
}
199+
}
200+
}
201+
202+
116203
return HookResult.Continue;
117204
}
118205
[GameEventHandler]

0 commit comments

Comments
 (0)