Skip to content

Commit 50576a8

Browse files
authored
Add files via upload
1 parent 6fc0f21 commit 50576a8

File tree

6 files changed

+176
-48
lines changed

6 files changed

+176
-48
lines changed

Config.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class ConfigBan : BasePluginConfig
2020
[JsonPropertyName("DBPort")] public int DBPort { get; set; } = 3306;
2121

2222
[JsonPropertyName("SettingsCommand")] public string SettingsCommand { get; set; } = "css_settings";
23+
[JsonPropertyName("AdminPermissions")] public string AdminPermissions { get; set; } = "@css/root";
2324

2425
[JsonPropertyName("VIPTag_Chat")] public string VIPTag_Chat { get; set; } = "{Green} VIP{Grey}» ";
2526
[JsonPropertyName("VIPTag_Score")] public string VIPTag_Score { get; set; } = "★";
@@ -83,6 +84,7 @@ public class ConfigBan : BasePluginConfig
8384
new VIP { value = 0, permission = "reserved"},
8485
new VIP { value = 0, permission = "reloading" },
8586
new VIP { value = 0, permission = "antiflash" },
87+
new VIP { value = 0, permission = "wings"},
8688
};
8789

8890
[JsonPropertyName("StartHealth")] public int StartHealth { get; set; } = 110;

CustomPlugin.cs

Lines changed: 91 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,17 @@ public partial class CustomPlugin : BasePlugin, IPluginConfig<ConfigBan>
7979
private static readonly int?[] NadeTrails = new int?[64];
8080
private static readonly int?[] CSStore = new int?[64];
8181
private static readonly int?[] SelectedModel = new int?[64];
82+
private static readonly int?[] SelectedWings = new int?[64];
8283
private static readonly int?[] LaserShot = new int?[64];
8384
private static readonly int?[] Healthshot = new int?[64];
85+
private static readonly int?[] Reserved = new int?[64];
8486
private static readonly int?[] Guns = new int?[64];
8587
private static readonly int?[] falldmg = new int?[64];
8688
private static readonly int?[] knife = new int?[64];
8789
private static readonly int?[] Bhop = new int?[64];
8890
private static readonly int?[] Health = new int?[64];
8991
private static readonly int?[] Models = new int?[64];
92+
private static readonly int?[] Wings = new int?[64];
9093
private static readonly int?[] Bomb_a = new int?[64];
9194
private static readonly int?[] MVIP = new int?[64];
9295
private static readonly int?[] AntiFlash = new int?[64];
@@ -146,6 +149,7 @@ public override void Load(bool hotReload)
146149
RegisterEventHandler<EventPlayerHurt>(EventPlayerHurt);
147150
RegisterEventHandler<EventPlayerSpawn>(EventPlayerSpawn);
148151
RegisterEventHandler<EventPlayerDeath>(EventPlayerDeath);
152+
RegisterEventHandler<EventWarmupEnd>(EventWarmupEnd);
149153

150154
RegisterEventHandler<EventPlayerBlind>(EventPlayerBlind);
151155

@@ -200,16 +204,18 @@ public void CreateDatabase()
200204
{
201205
MySqlDb MySql = new MySqlDb(Config.DBHost, Config.DBUser, Config.DBPassword, Config.DBDatabase);
202206

203-
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, `tag` INT(11) NOT NULL, `tag2` INT(11) NOT NULL, `enable_djump` INT(11) NOT NULL, `model` INT(11) NOT NULL, `bomb` INT(11) NOT NULL, `health` 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`));");
204-
MySql.ExecuteNonQueryAsync(@"CREATE TABLE IF NOT EXISTS `deadswim_vip` (`id` INT AUTO_INCREMENT PRIMARY KEY, `steamid` VARCHAR(32) UNIQUE NOT NULL, `reserved` INT(11) NOT NULL,`tag` INT(11) NOT NULL, `healthshot` INT(11) NOT NULL, `reloading` INT(11) NOT NULL, `antiflash` 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`));");
207+
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, `wings` INT(11) NOT NULL,`tag` INT(11) NOT NULL, `tag2` INT(11) NOT NULL, `enable_djump` INT(11) NOT NULL, `model` INT(11) NOT NULL, `bomb` INT(11) NOT NULL, `health` 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`));");
208+
MySql.ExecuteNonQueryAsync(@"CREATE TABLE IF NOT EXISTS `deadswim_vip` (`id` INT AUTO_INCREMENT PRIMARY KEY, `steamid` VARCHAR(32) UNIQUE NOT NULL, `wings` INT(11) NOT NULL, `reserved` INT(11) NOT NULL,`tag` INT(11) NOT NULL, `healthshot` INT(11) NOT NULL, `reloading` INT(11) NOT NULL, `antiflash` 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`));");
205209
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`));");
206210
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) NOT NULL, `path` VARCHAR(128) UNIQUE NOT NULL, UNIQUE (`id`));");
211+
MySql.ExecuteNonQueryAsync(@$"CREATE TABLE IF NOT EXISTS `deadswim_wings` (`id` INT AUTO_INCREMENT PRIMARY KEY, `name` VARCHAR(32) UNIQUE NOT NULL, `permission` VARCHAR(32) NOT NULL, `side` VARCHAR(32) NOT NULL, `path` VARCHAR(128) UNIQUE NOT NULL, UNIQUE (`id`));");
207212
MySql.ExecuteNonQueryAsync(@$"CREATE TABLE IF NOT EXISTS `deadswim_tags` (`id` INT AUTO_INCREMENT PRIMARY KEY, `tag` VARCHAR(32) NOT NULL, `permission` VARCHAR(32) NOT NULL, `type` VARCHAR(32) NOT NULL, UNIQUE (`id`));");
208213

209214
using (var connection = new MySqlConnection($"Server={Config.DBHost};Database={Config.DBDatabase};Uid={Config.DBUser};Pwd={Config.DBPassword};"))
210215
{
211216
connection.Open();
212217
EnsureColumns(connection, Config.DBDatabase);
218+
EnsureColumns_Settings(connection, Config.DBDatabase);
213219
}
214220
}
215221
catch (Exception ex)
@@ -233,7 +239,47 @@ public static void EnsureColumns(MySqlConnection connection, string db)
233239
{ "falldmg", "INT(11) NOT NULL DEFAULT 0" },
234240
{ "knife", "INT(11) NOT NULL DEFAULT 0" },
235241
{ "nade", "INT(11) NOT NULL DEFAULT 0" },
236-
{ "reserved", "INT(11) NOT NULL DEFAULT 0" }
242+
{ "reserved", "INT(11) NOT NULL DEFAULT 0" },
243+
{ "wings", "INT(11) NOT NULL DEFAULT 0" }
244+
};
245+
246+
var existingColumns = new HashSet<string>();
247+
248+
string columnQuery = $@"
249+
SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS
250+
WHERE TABLE_SCHEMA = '{databaseName}' AND TABLE_NAME = '{tableName}';
251+
";
252+
253+
using (var cmd = new MySqlCommand(columnQuery, connection))
254+
using (var reader = cmd.ExecuteReader())
255+
{
256+
while (reader.Read())
257+
{
258+
existingColumns.Add(reader.GetString(0));
259+
}
260+
}
261+
262+
foreach (var column in columnsToEnsure)
263+
{
264+
if (!existingColumns.Contains(column.Key))
265+
{
266+
string alterSql = $"ALTER TABLE `{tableName}` ADD COLUMN `{column.Key}` {column.Value};";
267+
using (var alterCmd = new MySqlCommand(alterSql, connection))
268+
{
269+
alterCmd.ExecuteNonQuery();
270+
Console.WriteLine($"✅ Adding in database: {column.Key}");
271+
}
272+
}
273+
}
274+
}
275+
public static void EnsureColumns_Settings(MySqlConnection connection, string db)
276+
{
277+
string databaseName = $"{db}";
278+
string tableName = "deadswim_settings";
279+
280+
var columnsToEnsure = new Dictionary<string, string>
281+
{
282+
{ "wings", "INT(11) NOT NULL DEFAULT 0" }
237283
};
238284

239285
var existingColumns = new HashSet<string>();
@@ -502,6 +548,11 @@ public void open_Models(CCSPlayerController player)
502548

503549
}
504550
public void SettingsMenu(CCSPlayerController player, CommandInfo info)
551+
{
552+
if (player == null) return;
553+
open_Settings(player);
554+
}
555+
public void open_Settings(CCSPlayerController player)
505556
{
506557
if (player == null) return;
507558

@@ -539,22 +590,6 @@ public void SettingsMenu(CCSPlayerController player, CommandInfo info)
539590
menu.AddItem($"Tag Menu\r\n___________", (p, option) => { open_Tags(player); });
540591
}
541592

542-
if (Config.EnabledShotTrails && LaserShot[player.Index] == 1)
543-
{
544-
menu.AddItem($"Shots - {shots_status}", (p, option) =>
545-
{
546-
if (ShotsEnable[client] == 0)
547-
{
548-
ShotsEnable[client] = 1;
549-
}
550-
else if (ShotsEnable[client] == 1)
551-
{
552-
ShotsEnable[client] = 0;
553-
}
554-
SaveSettings(player);
555-
});
556-
}
557-
558593
if (Config.EnabledBhop && Bhop[player.Index] == 1)
559594
{
560595
menu.AddItem($"Bhop - {bhop_status}", (p, option) =>
@@ -570,22 +605,6 @@ public void SettingsMenu(CCSPlayerController player, CommandInfo info)
570605
SaveSettings(player);
571606
});
572607
}
573-
574-
if (Config.NadeEnable && NadeTrails[player.Index] == 1)
575-
{
576-
menu.AddItem($"Nade's Trails - {nade_status}", (p, option) =>
577-
{
578-
if (NadeEnable[client] == 0)
579-
{
580-
NadeEnable[client] = 1;
581-
}
582-
else if (NadeEnable[client] == 1)
583-
{
584-
NadeEnable[client] = 0;
585-
}
586-
SaveSettings(player);
587-
});
588-
}
589608
if (Config.EnabledDoubbleJump && DJump[player.Index] == 1)
590609
{
591610
menu.AddItem($"Doubble Jump - {jump_status}", (p, option) =>
@@ -641,7 +660,7 @@ public void generatevip(CCSPlayerController? player, CommandInfo info)
641660
var Time = info.GetArg(1);
642661
var Type = info.GetArg(2);
643662

644-
if (!AdminManager.PlayerHasPermissions(player, "@css/root"))
663+
if (!AdminManager.PlayerHasPermissions(player, Config.AdminPermissions))
645664
{
646665
info.ReplyToCommand($" {Config.Prefix} This command are only for admins!");
647666
return;
@@ -697,7 +716,7 @@ public void addmodel(CCSPlayerController? player, CommandInfo info)
697716
var Side = info.GetArg(2);
698717
var Path = info.GetArg(1);
699718

700-
if (!AdminManager.PlayerHasPermissions(player, "@css/root"))
719+
if (!AdminManager.PlayerHasPermissions(player, Config.AdminPermissions))
701720
{
702721
info.ReplyToCommand($" {Config.Prefix} This command are only for admins!");
703722
return;
@@ -727,7 +746,7 @@ public void addtag(CCSPlayerController? player, CommandInfo info)
727746
var Permission = info.GetArg(2);
728747
var Type = info.GetArg(1);
729748

730-
if (!AdminManager.PlayerHasPermissions(player, "@css/root"))
749+
if (!AdminManager.PlayerHasPermissions(player, Config.AdminPermissions))
731750
{
732751
info.ReplyToCommand($" {Config.Prefix} This command are only for admins!");
733752
return;
@@ -852,7 +871,7 @@ public void addvip(CCSPlayerController? player, CommandInfo info)
852871
var SteamIDC = info.GetArg(2);
853872
var TimeSec = info.GetArg(1);
854873

855-
if (!AdminManager.PlayerHasPermissions(player, "@css/root"))
874+
if (!AdminManager.PlayerHasPermissions(player, Config.AdminPermissions))
856875
{
857876
info.ReplyToCommand($" {Config.Prefix} This command are only for admins!");
858877
return;
@@ -1016,6 +1035,23 @@ public void OnTick(CCSPlayerController controller)
10161035
//DrawTrials(player_vec, end_pos, controller); Only in Prémium
10171036
}
10181037
}
1038+
if (JumpEnable[client] == 1 && Config.EnabledDoubbleJump && DJump[client] == 1)
1039+
{
1040+
if ((LF[client] & PlayerFlags.FL_ONGROUND) != 0 && (flags & PlayerFlags.FL_ONGROUND) == 0 &&
1041+
(buttons & PlayerButtons.Jump) == 0 && (buttons & PlayerButtons.Jump) != 0)
1042+
{
1043+
J[client]++;
1044+
}
1045+
else if ((flags & PlayerFlags.FL_ONGROUND) != 0)
1046+
{
1047+
J[client] = 0;
1048+
}
1049+
else if ((LB[client] & PlayerButtons.Jump) == 0 && (buttons & PlayerButtons.Jump) != 0 && J[client] <= 1)
1050+
{
1051+
J[client]++;
1052+
pawn.AbsVelocity.Z = 320;
1053+
}
1054+
}
10191055
LF[client] = flags;
10201056
LB[client] = buttons;
10211057
}
@@ -1169,6 +1205,7 @@ public void SaveSettings(CCSPlayerController player)
11691205
.Add("shots", $"{ShotsEnable[client]}")
11701206
.Add("enable_djump", $"{JumpEnable[client]}")
11711207
.Add("model", $"{SelectedModel[client]}")
1208+
.Add("wings", $"{SelectedWings[client]}")
11721209
.Add("credits", $"{CreditEnable[client]}")
11731210
.Add("bomb", $"{BombEnable[client]}")
11741211
.Add("health", $"{HealthEnable[client]}")
@@ -1201,12 +1238,14 @@ public void LoadPlayerData_VIP(CCSPlayerController player)
12011238
Bhop[player.Index] = result.Get<int>(0, "bhop");
12021239
Health[player.Index] = result.Get<int>(0, "health");
12031240
Models[player.Index] = result.Get<int>(0, "models");
1241+
Wings[player.Index] = result.Get<int>(0, "wings");
12041242
Bomb_a[player.Index] = result.Get<int>(0, "bomb");
12051243
MVIP[player.Index] = result.Get<int>(0, "mvip");
12061244
knife[player.Index] = result.Get<int>(0, "knife");
12071245
falldmg[player.Index] = result.Get<int>(0, "falldmg");
12081246
DJump[player.Index] = result.Get<int>(0, "jump");
12091247
IReload[player.Index] = result.Get<int>(0, "reloading");
1248+
Reserved[player.Index] = result.Get<int>(0, "reserved");
12101249
AntiFlash[player.Index] = result.Get<int>(0, "antiflash");
12111250
Timestamp[player.Index] = result.Get<int>(0, "timestamp");
12121251

@@ -1228,8 +1267,10 @@ public void LoadPlayerData_VIP(CCSPlayerController player)
12281267
.Add("health", "0")
12291268
.Add("bomb", "0")
12301269
.Add("knife", "0")
1270+
.Add("wings", "0")
12311271
.Add("falldmg", "0")
12321272
.Add("mvip", "0")
1273+
.Add("reserved", "0")
12331274
.Add("jump", "0")
12341275
.Add("reloading", "0")
12351276
.Add("tag", "0")
@@ -1260,10 +1301,12 @@ public void LoadPlayerData_VIP(CCSPlayerController player)
12601301
.Add("models", "0")
12611302
.Add("bomb", "0")
12621303
.Add("knife", "0")
1304+
.Add("wings", "0")
12631305
.Add("falldmg", "0")
12641306
.Add("mvip", "0")
12651307
.Add("jump", "0")
12661308
.Add("reloading", "0")
1309+
.Add("reserved", "0")
12671310
.Add("reload", "0")
12681311
.Add("tag", "0")
12691312
.Add("antiflash", "0")
@@ -1292,6 +1335,7 @@ public void LoadPlayerData(CCSPlayerController player)
12921335
QuakeEnable[player.Index] = result.Get<int>(0, "enable_quake");
12931336
Selected[player.Index] = result.Get<int>(0, "guns");
12941337
SelectedModel[player.Index] = result.Get<int>(0, "model");
1338+
SelectedWings[player.Index] = result.Get<int>(0, "wings");
12951339
BombEnable[player.Index] = result.Get<int>(0, "bomb");
12961340
HealthEnable[player.Index] = result.Get<int>(0, "health");
12971341
SelectedTag[player.Index] = result.Get<int>(0, "tag");
@@ -1303,17 +1347,18 @@ public void LoadPlayerData(CCSPlayerController player)
13031347
Selected[player.Index] = 0;
13041348
MySqlQueryValue values = new MySqlQueryValue()
13051349
.Add("steamid", player.SteamID.ToString())
1306-
.Add("shots", "0")
1350+
.Add("shots", "1")
13071351
.Add("trials", "0")
1308-
.Add("bhop", "0")
1309-
.Add("enable_djump", "0")
1310-
.Add("enable_nade", "0")
1311-
.Add("enable_quake", "0")
1352+
.Add("bhop", "1")
1353+
.Add("enable_djump", "1")
1354+
.Add("enable_nade", "1")
1355+
.Add("enable_quake", "1")
13121356
.Add("free_vip", "0")
13131357
.Add("model", "0")
13141358
.Add("credits", "1")
1315-
.Add("bomb", "0")
1316-
.Add("health", "0")
1359+
.Add("bomb", "1")
1360+
.Add("wings", "0")
1361+
.Add("health", "1")
13171362
.Add("tag", "0")
13181363
.Add("tag2", "0")
13191364
.Add("guns", "0");

CustomPluginAPI.cs

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
using CounterStrikeSharp.API.Core;
1+
using CounterStrikeSharp.API;
2+
using CounterStrikeSharp.API.Core;
23
using CustomPlugin;
4+
using Nexd.MySQL;
35
using VIPAPI;
46
namespace CustomPlugin
57
{
@@ -8,7 +10,7 @@ public class CoreAPI : IAPI
810
private CustomPlugin _api;
911
public CoreAPI(CustomPlugin cp)
1012
{
11-
_api = cp; // Initialize it through the constructor
13+
_api = cp;
1214
}
1315

1416
public string GetVIPGroup(CCSPlayerController player)
@@ -22,5 +24,55 @@ public bool IsVIP(CCSPlayerController player)
2224
var vip = _api.IsPlayerVip(player);
2325
return vip;
2426
}
27+
public void OpenTagMenu(CCSPlayerController player)
28+
{
29+
_api.OpenTagMenu(player);
30+
}
31+
public void OpenVIPMenu(CCSPlayerController player)
32+
{
33+
_api.OpenVIPMenu(player);
34+
}
35+
public void OpenModelsMenu(CCSPlayerController player)
36+
{
37+
_api.OpenModelsMenu(player);
38+
}
39+
public void SwitchQuake(CCSPlayerController player)
40+
{
41+
_api.quake(player);
42+
}
43+
public string GenerateVIP(CCSPlayerController target, string? type, string? Time)
44+
{
45+
if (target != null)
46+
{
47+
var token = _api.CreatePassword(20);
48+
var group = type;
49+
var time_vip = Time;
50+
if (group == null || group == "") { return "**VIP API ERROR** Group must be included! (1=VIP, 2=M-VIP, 3=MODELS)"; }
51+
if (time_vip == null || time_vip == "") { return "**VIP API ERROR** Time must be incuded! (0=FOREVER, >1 = HOURS)"; }
52+
53+
var TimeToUTC = DateTime.UtcNow.AddDays(Convert.ToInt32(time_vip)).GetUnixEpoch();
54+
var timeofvip = 0;
55+
if (time_vip == "0")
56+
{
57+
timeofvip = 0;
58+
}
59+
else
60+
{
61+
timeofvip = DateTime.UtcNow.AddDays(Convert.ToInt32(time_vip)).GetUnixEpoch();
62+
}
63+
MySqlDb MySql = new MySqlDb(_api.Config.DBHost, _api.Config.DBUser, _api.Config.DBPassword, _api.Config.DBDatabase);
64+
MySqlQueryValue values = new MySqlQueryValue()
65+
.Add("token", token)
66+
.Add("end", $"{timeofvip}")
67+
.Add("`group`", group);
68+
MySql.Table($"deadswim_users_key_vip").Insert(values);
69+
70+
return token;
71+
}
72+
else
73+
{
74+
return "error";
75+
}
76+
}
2577
}
2678
}

0 commit comments

Comments
 (0)