From 4396d5982afe0ceaa9ed93c654b32dcf4fe68a76 Mon Sep 17 00:00:00 2001 From: NotnHeavy <94223272+NotnHeavy@users.noreply.github.com> Date: Fri, 14 Apr 2023 20:41:19 +0100 Subject: [PATCH] Few changes: - Fixed fixed-size array syntax error in tf2utils.inc - Fixed few warnings in cwx.sp - Moved IsEmpty() check in GetLoadoutItem so if we no longer equip a custom weapon, it equips our loadout's instead. --- scripting/cwx.sp | 18 ++++++++++-------- third_party/vendored/tf2utils.inc | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/scripting/cwx.sp b/scripting/cwx.sp index a95fb0b..60af42f 100644 --- a/scripting/cwx.sp +++ b/scripting/cwx.sp @@ -354,6 +354,7 @@ Action OnPlayerLoadoutUpdated(UserMsg msg_id, BfRead msg, const int[] players, int playersNum, bool reliable, bool init) { int client = msg.ReadByte(); s_LastUpdatedClient = GetClientSerial(client); + return Plugin_Continue; } /** @@ -431,18 +432,17 @@ MRESReturn OnGetLoadoutItemPost(int client, Handle hReturn, Handle hParams) { if (loadoutSlot < 0 || loadoutSlot >= NUM_ITEMS) { return MRES_Ignored; } + + if (g_CurrentLoadout[client][playerClass][loadoutSlot].IsEmpty()) { + // we don't have nor want a custom item; let the game process it + return MRES_Ignored; + } + // the loadout entity we keep track of isn't valid, so we may need to make one + // we expect to have to equip something new at this point int storedItem = g_CurrentLoadout[client][playerClass][loadoutSlot].entity; if (!IsValidEntity(storedItem) || GetEntityFlags(storedItem) & FL_KILLME || !HasEntProp(storedItem, Prop_Send, "m_Item")) { - // the loadout entity we keep track of isn't valid, so we may need to make one - // we expect to have to equip something new at this point - - if (g_CurrentLoadout[client][playerClass][loadoutSlot].IsEmpty()) { - // we don't have nor want a custom item; let the game process it - return MRES_Ignored; - } - /** * We have a custom item we'd like to spawn in; don't return a loadout item, otherwise * we may equip / unequip a user's inventory weapon that has side effects @@ -546,6 +546,7 @@ public Action OnClientCommandKeyValues(int client, KeyValues kv) { if (StrEqual(cmd, "MVM_Respec")) { g_bForceReequipItems[client] = true; } + return Plugin_Continue; } public void OnClientCommandKeyValues_Post(int client, KeyValues kv) { @@ -632,6 +633,7 @@ int Native_RemovePlayerLoadoutItem(Handle plugin, int argc) { int flags = GetNativeCell(4); UnsetClientCustomLoadoutItem(client, playerClass, itemSlot, flags); + return true; } /** diff --git a/third_party/vendored/tf2utils.inc b/third_party/vendored/tf2utils.inc index 3fa3c60..a7596e3 100644 --- a/third_party/vendored/tf2utils.inc +++ b/third_party/vendored/tf2utils.inc @@ -143,7 +143,7 @@ native void TF2Util_UpdatePlayerSpeed(int client, bool immediate = false); * the position is in an active spawn room. Has no effect if no * entity is provided. */ -native bool TF2Util_IsPointInRespawnRoom(const float[3] position, +native bool TF2Util_IsPointInRespawnRoom(const float position[3], int entity = INVALID_ENT_REFERENCE, bool bRestrictToSameTeam = false); // compile-time compatibility shim for tf2wearables natives