From 44177f18fe1805c74755d9daa32bd0e5758c7bcb Mon Sep 17 00:00:00 2001 From: Dawid Bepierszcz <41084667+daffyyyy@users.noreply.github.com> Date: Tue, 5 Mar 2024 12:27:19 +0100 Subject: [PATCH] 2.2b - Small fixes :pizza: --- Commands.cs | 1 - Config.cs | 2 ++ Events.cs | 10 ++++----- Utility.cs | 6 ++++++ VERSION | 2 +- WeaponAction.cs | 5 +++-- WeaponPaints.cs | 2 +- WeaponSynchronization.cs | 6 +++--- gamedata/weaponpaints.json | 42 +++++++++++++++++++------------------- website/data/agents.json | 2 +- 10 files changed, 43 insertions(+), 35 deletions(-) diff --git a/Commands.cs b/Commands.cs index f424a143..b5cef8b7 100644 --- a/Commands.cs +++ b/Commands.cs @@ -234,7 +234,6 @@ namespace WeaponPaints return false; }); - string selectedSkin = opt.Text; string selectedPaintID = selectedSkin.Substring(selectedSkin.LastIndexOf('(') + 1).Trim(')'); diff --git a/Config.cs b/Config.cs index a109d825..537fd616 100644 --- a/Config.cs +++ b/Config.cs @@ -10,6 +10,7 @@ namespace WeaponPaints [JsonPropertyName("GloveEnabled")] public bool GloveEnabled { get; set; } = true; + [JsonPropertyName("AgentEnabled")] public bool AgentEnabled { get; set; } = true; @@ -27,6 +28,7 @@ namespace WeaponPaints [JsonPropertyName("CommandGlove")] public string CommandGlove { get; set; } = "gloves"; + [JsonPropertyName("CommandAgent")] public string CommandAgent { get; set; } = "agents"; diff --git a/Events.cs b/Events.cs index f75030b2..3a7aae47 100644 --- a/Events.cs +++ b/Events.cs @@ -1,6 +1,7 @@ using CounterStrikeSharp.API; using CounterStrikeSharp.API.Core; using CounterStrikeSharp.API.Core.Attributes.Registration; +using CounterStrikeSharp.API.Modules.Memory; using CounterStrikeSharp.API.Modules.Memory.DynamicFunctions; namespace WeaponPaints @@ -265,10 +266,10 @@ namespace WeaponPaints Server.NextFrame(() => { var weapon = new CBasePlayerWeapon(entity.Handle); - if (!weapon.IsValid) return; + if (weapon == null || !weapon.IsValid || weapon.OwnerEntity.Value == null) return; - var player = Utilities.GetPlayerFromSteamId(weapon.OriginalOwnerXuidLow); - if (player == null || !Utility.IsPlayerValid(player)) return; + CCSPlayerController? player = Utilities.GetPlayerFromIndex((int)weapon.OwnerEntity.Value.Index); + if (player == null || !player.IsValid || !Utility.IsPlayerValid(player)) return; GivePlayerWeaponSkin(player, weapon); }); @@ -291,7 +292,6 @@ namespace WeaponPaints } } - private void RegisterListeners() { RegisterListener(OnMapStart); @@ -301,7 +301,7 @@ namespace WeaponPaints RegisterEventHandler(OnRoundEnd); RegisterListener(OnEntitySpawned); RegisterListener(OnTick); - //VirtualFunctions.GiveNamedItemFunc.Hook(OnGiveNamedItemPost, HookMode.Post); + VirtualFunctions.GiveNamedItemFunc.Hook(OnGiveNamedItemPost, HookMode.Post); } } } \ No newline at end of file diff --git a/Utility.cs b/Utility.cs index 1a9c4685..5dc86957 100644 --- a/Utility.cs +++ b/Utility.cs @@ -59,6 +59,12 @@ namespace WeaponPaints `steamid` varchar(64) NOT NULL, `weapon_defindex` int(11) NOT NULL, UNIQUE (`steamid`) + ) ENGINE=InnoDB", + @"CREATE TABLE `wp_player_agents` ( + `steamid` varchar(64) NOT NULL, + `agent_ct` varchar(64) DEFAULT NULL, + `agent_t` varchar(64) DEFAULT NULL, + UNIQUE KEY `steamid` (`steamid`) ) ENGINE=InnoDB" }; diff --git a/VERSION b/VERSION index b6242554..bac91872 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.2a \ No newline at end of file +2.2b \ No newline at end of file diff --git a/WeaponAction.cs b/WeaponAction.cs index d003b2ea..64120557 100644 --- a/WeaponAction.cs +++ b/WeaponAction.cs @@ -183,7 +183,6 @@ namespace WeaponPaints }); } } - }, TimerFlags.STOP_ON_MAPCHANGE); } @@ -297,8 +296,10 @@ namespace WeaponPaints } } - public void GivePlayerAgent(CCSPlayerController player) + public static void GivePlayerAgent(CCSPlayerController player) { + if (!g_playersAgent.ContainsKey(player.Slot)) return; + try { Server.NextFrame(() => diff --git a/WeaponPaints.cs b/WeaponPaints.cs index 74729365..5217f07e 100644 --- a/WeaponPaints.cs +++ b/WeaponPaints.cs @@ -158,7 +158,7 @@ public partial class WeaponPaints : BasePlugin, IPluginConfig "Nereziel & daffyy"; public override string ModuleDescription => "Skin, gloves, agents and knife selector, standalone and web-based"; public override string ModuleName => "WeaponPaints"; - public override string ModuleVersion => "2.2a"; + public override string ModuleVersion => "2.2b"; public static WeaponPaintsConfig GetWeaponPaintsConfig() { diff --git a/WeaponSynchronization.cs b/WeaponSynchronization.cs index 61329947..057dd2a2 100644 --- a/WeaponSynchronization.cs +++ b/WeaponSynchronization.cs @@ -170,9 +170,9 @@ namespace WeaponPaints { await using var connection = await _database.GetConnectionAsync(); string query = @" - INSERT INTO `wp_player_agents` (`steamid`, `agent_ct`, `agent_t`) - VALUES(@steamid, @agent_ct, @agent_t) - ON DUPLICATE KEY UPDATE + INSERT INTO `wp_player_agents` (`steamid`, `agent_ct`, `agent_t`) + VALUES(@steamid, @agent_ct, @agent_t) + ON DUPLICATE KEY UPDATE `agent_ct` = @agent_ct, `agent_t` = @agent_t"; diff --git a/gamedata/weaponpaints.json b/gamedata/weaponpaints.json index e9422f6a..69f8c130 100644 --- a/gamedata/weaponpaints.json +++ b/gamedata/weaponpaints.json @@ -1,23 +1,23 @@ { - "ChangeSubclass": { - "signatures": { - "library": "server", - "windows": "\\x48\\x89\\x5C\\x24\\x08\\x57\\x48\\x83\\xEC\\x20\\x48\\x8B\\xDA\\x48\\x8B\\xF9\\xE8\\x2A\\x2A\\x2A\\x2A\\x84\\xC0\\x74\\x2A\\x41\\xB0\\x01", - "linux": "\\x55\\x48\\x89\\xE5\\x41\\x57\\x41\\x56\\x41\\x55\\x49\\x89\\xF5\\x41\\x54\\x49\\x89\\xFC\\x53\\x48\\x81\\xEC\\xA8\\x00\\x00\\x00" - } - }, - "CAttributeList_SetOrAddAttributeValueByName": { - "signatures": { - "library": "server", - "windows": "\\x40\\x53\\x41\\x56\\x41\\x57\\x48\\x81\\xEC\\x90\\x00\\x00\\x00\\x0F\\x29\\x74\\x24\\x70", - "linux": "\\x55\\x48\\x89\\xE5\\x41\\x57\\x41\\x56\\x49\\x89\\xFE\\x41\\x55\\x41\\x54\\x49\\x89\\xF4\\x53\\x48\\x83\\xEC\\x78" - } - }, - "CBaseModelEntity_SetBodygroup": { - "signatures": { - "library": "server", - "windows": "\\x48\\x89\\x5C\\x24\\x08\\x48\\x89\\x74\\x24\\x10\\x57\\x48\\x83\\xEC\\x20\\x41\\x8B\\xF8\\x48\\x8B\\xF2\\x48\\x8B\\xD9\\xE8\\x2A\\x2A\\x2A\\x2A", - "linux": "\\x55\\x48\\x89\\xE5\\x41\\x56\\x49\\x89\\xF6\\x41\\x55\\x41\\x89\\xD5\\x41\\x54\\x49\\x89\\xFC\\x48\\x83\\xEC\\x08" - } - } + "ChangeSubclass": { + "signatures": { + "library": "server", + "windows": "\\x48\\x89\\x5C\\x24\\x08\\x57\\x48\\x83\\xEC\\x20\\x48\\x8B\\xDA\\x48\\x8B\\xF9\\xE8\\x2A\\x2A\\x2A\\x2A\\x84\\xC0\\x74\\x2A\\x41\\xB0\\x01", + "linux": "\\x55\\x48\\x89\\xE5\\x41\\x57\\x41\\x56\\x41\\x55\\x49\\x89\\xF5\\x41\\x54\\x49\\x89\\xFC\\x53\\x48\\x81\\xEC\\xA8\\x00\\x00\\x00" + } + }, + "CAttributeList_SetOrAddAttributeValueByName": { + "signatures": { + "library": "server", + "windows": "\\x40\\x53\\x41\\x56\\x41\\x57\\x48\\x81\\xEC\\x90\\x00\\x00\\x00\\x0F\\x29\\x74\\x24\\x70", + "linux": "\\x55\\x48\\x89\\xE5\\x41\\x57\\x41\\x56\\x49\\x89\\xFE\\x41\\x55\\x41\\x54\\x49\\x89\\xF4\\x53\\x48\\x83\\xEC\\x78" + } + }, + "CBaseModelEntity_SetBodygroup": { + "signatures": { + "library": "server", + "windows": "\\x48\\x89\\x5C\\x24\\x08\\x48\\x89\\x74\\x24\\x10\\x57\\x48\\x83\\xEC\\x20\\x41\\x8B\\xF8\\x48\\x8B\\xF2\\x48\\x8B\\xD9\\xE8\\x2A\\x2A\\x2A\\x2A", + "linux": "\\x55\\x48\\x89\\xE5\\x41\\x56\\x49\\x89\\xF6\\x41\\x55\\x41\\x89\\xD5\\x41\\x54\\x49\\x89\\xFC\\x48\\x83\\xEC\\x08" + } + } } \ No newline at end of file diff --git a/website/data/agents.json b/website/data/agents.json index 0a69f519..f68e1378 100644 --- a/website/data/agents.json +++ b/website/data/agents.json @@ -4,7 +4,7 @@ "image": "", "model": "null", "agent_name": "Agent | Default" - }, + }, { "team": 3, "image": "",