From 58b91973c16e525c1eb792b25b54042fd680f975 Mon Sep 17 00:00:00 2001 From: jenz Date: Wed, 30 Aug 2023 17:56:15 +0200 Subject: [PATCH] updates for entwatch to work --- entWatch4/scripting/entWatch-core.sp | 66 ++--- entWatch4/scripting/entWatch-interface.sp | 246 ++++++++++--------- entWatch4/scripting/entWatch-messages.sp | 1 + entWatch4/scripting/entWatch-restrictions.sp | 3 +- includes/basic.inc | 4 +- 5 files changed, 163 insertions(+), 157 deletions(-) diff --git a/entWatch4/scripting/entWatch-core.sp b/entWatch4/scripting/entWatch-core.sp index 51a5f956..3f14e412 100644 --- a/entWatch4/scripting/entWatch-core.sp +++ b/entWatch4/scripting/entWatch-core.sp @@ -526,25 +526,26 @@ public void OnClientDeath(Event hEvent, const char[] sEvent, bool bDontBroadcast //---------------------------------------------------------------------------------------------------- public Action OnWeaponPickup(int client, int weapon) { - if (Client_IsValid(client) && Entity_IsValid(weapon) && g_hArray_Items.Length) - { - for (int index; index < g_hArray_Items.Length; index++) - { - CItem item = g_hArray_Items.Get(index); + if (Client_IsValid(client) && Entity_IsValid(weapon) && g_hArray_Items.Length) + { + for (int index; index < g_hArray_Items.Length; index++) + { + CItem item = g_hArray_Items.Get(index); - if (item.bWeapon && item.iWeapon == weapon) - { - item.iClient = client; + if (item.bWeapon && item.iWeapon == weapon) + { + item.iClient = client; - Call_StartForward(g_hFwd_OnClientItemPickup); - Call_PushCell(client); - Call_PushCell(index); - Call_Finish(); + Call_StartForward(g_hFwd_OnClientItemPickup); + Call_PushCell(client); + Call_PushCell(index); + Call_Finish(); - return; - } - } - } + return Plugin_Handled; + } + } + } + return Plugin_Handled; } //---------------------------------------------------------------------------------------------------- @@ -552,25 +553,26 @@ public Action OnWeaponPickup(int client, int weapon) //---------------------------------------------------------------------------------------------------- public Action OnWeaponDrop(int client, int weapon) { - if (Client_IsValid(client) && Entity_IsValid(weapon) && g_hArray_Items.Length) - { - for (int index; index < g_hArray_Items.Length; index++) - { - CItem item = g_hArray_Items.Get(index); + if (Client_IsValid(client) && Entity_IsValid(weapon) && g_hArray_Items.Length) + { + for (int index; index < g_hArray_Items.Length; index++) + { + CItem item = g_hArray_Items.Get(index); - if (item.bWeapon && item.iWeapon == weapon) - { - item.iClient = INVALID_ENT_REFERENCE; + if (item.bWeapon && item.iWeapon == weapon) + { + item.iClient = INVALID_ENT_REFERENCE; - Call_StartForward(g_hFwd_OnClientItemDrop); - Call_PushCell(client); - Call_PushCell(index); - Call_Finish(); + Call_StartForward(g_hFwd_OnClientItemDrop); + Call_PushCell(client); + Call_PushCell(index); + Call_Finish(); - return; - } - } - } + return Plugin_Handled; + } + } + } + return Plugin_Handled; } //---------------------------------------------------------------------------------------------------- diff --git a/entWatch4/scripting/entWatch-interface.sp b/entWatch4/scripting/entWatch-interface.sp index ee505e94..c560b87c 100644 --- a/entWatch4/scripting/entWatch-interface.sp +++ b/entWatch4/scripting/entWatch-interface.sp @@ -9,6 +9,7 @@ #pragma newdecls required +#include #include #include #include @@ -95,141 +96,142 @@ public Action Command_ToggleHUD(int client, int args) //---------------------------------------------------------------------------------------------------- public Action OnDisplayHUD(Handle timer) { - int iHUDPages[3]; - char sHUDPanels[3][8][255] + int iHUDPages[3]; + char sHUDPanels[3][8][255] - for (int index; index < EW_GetItemCount(); index++) - { - CItem item = EW_GetItemData(index); + for (int index; index < EW_GetItemCount(); index++) + { + CItem item = EW_GetItemData(index); - if (item.bClient && item.dConfig.bDisplayInterface) - { - char sShort[32]; - item.dConfig.GetShort(sShort, sizeof(sShort)); + if (item.bClient && item.dConfig.bDisplayInterface) + { + char sShort[32]; + item.dConfig.GetShort(sShort, sizeof(sShort)); - char sLine[96]; - switch(item.dConfig.iMode) - { - case MODE_COOLDOWN: - { - if (item.flTimeReady > GetEngineTime()) - { - Format(sLine, sizeof(sLine), "%s [%d]: %N", sShort, RoundToCeil(item.flTimeReady - GetEngineTime()), item.iClient); - } - else - { - Format(sLine, sizeof(sLine), "%s [%s]: %N", sShort, "R", item.iClient); - } - } - case MODE_MAXUSES: - { - if (item.iTimesUsed < item.dConfig.iMaxUses) - { - Format(sLine, sizeof(sLine), "%s [%d/%d]: %N", sShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient); - } - else - { - Format(sLine, sizeof(sLine), "%s [%s]: %N", sShort, "D", item.iClient); - } - } - case MODE_COOLDOWNMAXUSES: - { - if (item.iTimesUsed < item.dConfig.iMaxUses) - { - if (item.flTimeReady > GetEngineTime()) - { - Format(sLine, sizeof(sLine), "%s [%d]: %N", sShort, RoundToCeil(item.flTimeReady - GetEngineTime()), item.iClient); - } - else - { - Format(sLine, sizeof(sLine), "%s [%d/%d]: %N", sShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient); - } - } - else - { - Format(sLine, sizeof(sLine), "%s [%s]: %N", sShort, "D", item.iClient); - } - } - case MODE_COOLDOWNCHARGES: - { - if (item.flTimeReady > GetEngineTime()) - { - Format(sLine, sizeof(sLine), "%s [%d]: %N", sShort, RoundToCeil(item.flTimeReady - GetEngineTime()), item.iClient); - } - else - { - Format(sLine, sizeof(sLine), "%s [%d/%d]: %N", sShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient); - } - } - default: - { - Format(sLine, sizeof(sLine), "%s [%s]: %N", sShort, "N/A", item.iClient); - } - } + char sLine[96]; + switch(item.dConfig.iMode) + { + case MODE_COOLDOWN: + { + if (item.flTimeReady > GetEngineTime()) + { + Format(sLine, sizeof(sLine), "%s [%d]: %N", sShort, RoundToCeil(item.flTimeReady - GetEngineTime()), item.iClient); + } + else + { + Format(sLine, sizeof(sLine), "%s [%s]: %N", sShort, "R", item.iClient); + } + } + case MODE_MAXUSES: + { + if (item.iTimesUsed < item.dConfig.iMaxUses) + { + Format(sLine, sizeof(sLine), "%s [%d/%d]: %N", sShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient); + } + else + { + Format(sLine, sizeof(sLine), "%s [%s]: %N", sShort, "D", item.iClient); + } + } + case MODE_COOLDOWNMAXUSES: + { + if (item.iTimesUsed < item.dConfig.iMaxUses) + { + if (item.flTimeReady > GetEngineTime()) + { + Format(sLine, sizeof(sLine), "%s [%d]: %N", sShort, RoundToCeil(item.flTimeReady - GetEngineTime()), item.iClient); + } + else + { + Format(sLine, sizeof(sLine), "%s [%d/%d]: %N", sShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient); + } + } + else + { + Format(sLine, sizeof(sLine), "%s [%s]: %N", sShort, "D", item.iClient); + } + } + case MODE_COOLDOWNCHARGES: + { + if (item.flTimeReady > GetEngineTime()) + { + Format(sLine, sizeof(sLine), "%s [%d]: %N", sShort, RoundToCeil(item.flTimeReady - GetEngineTime()), item.iClient); + } + else + { + Format(sLine, sizeof(sLine), "%s [%d/%d]: %N", sShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient); + } + } + default: + { + Format(sLine, sizeof(sLine), "%s [%s]: %N", sShort, "N/A", item.iClient); + } + } - switch(GetClientTeam(item.iClient)) - { - case(2): - { - if (strlen(sHUDPanels[1][iHUDPages[1]]) + strlen(sLine) + 2 >= sizeof(sHUDPanels[][])) iHUDPages[1]++; + switch(GetClientTeam(item.iClient)) + { + case(2): + { + if (strlen(sHUDPanels[1][iHUDPages[1]]) + strlen(sLine) + 2 >= sizeof(sHUDPanels[][])) iHUDPages[1]++; - StrCat(sHUDPanels[1][iHUDPages[1]], sizeof(sHUDPanels[][]), sLine); - StrCat(sHUDPanels[1][iHUDPages[1]], sizeof(sHUDPanels[][]), "\n"); - } - case(3): - { - if (strlen(sHUDPanels[2][iHUDPages[2]]) + strlen(sLine) + 2 >= sizeof(sHUDPanels[][])) iHUDPages[2]++; + StrCat(sHUDPanels[1][iHUDPages[1]], sizeof(sHUDPanels[][]), sLine); + StrCat(sHUDPanels[1][iHUDPages[1]], sizeof(sHUDPanels[][]), "\n"); + } + case(3): + { + if (strlen(sHUDPanels[2][iHUDPages[2]]) + strlen(sLine) + 2 >= sizeof(sHUDPanels[][])) iHUDPages[2]++; - StrCat(sHUDPanels[2][iHUDPages[2]], sizeof(sHUDPanels[][]), sLine); - StrCat(sHUDPanels[2][iHUDPages[2]], sizeof(sHUDPanels[][]), "\n"); - } - } + StrCat(sHUDPanels[2][iHUDPages[2]], sizeof(sHUDPanels[][]), sLine); + StrCat(sHUDPanels[2][iHUDPages[2]], sizeof(sHUDPanels[][]), "\n"); + } + } - if (strlen(sHUDPanels[0][iHUDPages[0]]) + strlen(sLine) + 2 >= sizeof(sHUDPanels[][])) iHUDPages[0]++; + if (strlen(sHUDPanels[0][iHUDPages[0]]) + strlen(sLine) + 2 >= sizeof(sHUDPanels[][])) iHUDPages[0]++; - StrCat(sHUDPanels[0][iHUDPages[0]], sizeof(sHUDPanels[][]), sLine); - StrCat(sHUDPanels[0][iHUDPages[0]], sizeof(sHUDPanels[][]), "\n"); - } - } + StrCat(sHUDPanels[0][iHUDPages[0]], sizeof(sHUDPanels[][]), sLine); + StrCat(sHUDPanels[0][iHUDPages[0]], sizeof(sHUDPanels[][]), "\n"); + } + } - static int iPageUpdate; - static int iPageCurrent[3]; + static int iPageUpdate; + static int iPageCurrent[3]; - if (iPageUpdate >= 5) - { - for (int iPageID; iPageID < 3; iPageID++) - { - if (iPageCurrent[iPageID] >= iHUDPages[iPageID]) - iPageCurrent[iPageID] = 0; - else - iPageCurrent[iPageID]++; - } + if (iPageUpdate >= 5) + { + for (int iPageID; iPageID < 3; iPageID++) + { + if (iPageCurrent[iPageID] >= iHUDPages[iPageID]) + iPageCurrent[iPageID] = 0; + else + iPageCurrent[iPageID]++; + } - iPageUpdate = 0; - } - else - iPageUpdate++; + iPageUpdate = 0; + } + else + iPageUpdate++; - for (int client = 1; client <= MaxClients; client++) - { - if (!IsClientInGame(client) || (IsFakeClient(client) && !IsClientSourceTV(client)) || g_bInterfaceHidden[client]) - continue; + for (int client = 1; client <= MaxClients; client++) + { + if (!IsClientInGame(client) || (IsFakeClient(client) && !IsClientSourceTV(client)) || g_bInterfaceHidden[client]) + continue; - int iPanelID; - switch(GetClientTeam(client)) - { - case(2): iPanelID = 1; - case(3): iPanelID = 2; - } + int iPanelID; + switch(GetClientTeam(client)) + { + case(2): iPanelID = 1; + case(3): iPanelID = 2; + } - if (sHUDPanels[iPanelID][iPageCurrent[iPanelID]][0]) - { - Handle hMessage = StartMessageOne("KeyHintText", client); - BfWriteByte(hMessage, 1); - BfWriteString(hMessage, sHUDPanels[iPanelID][iPageCurrent[iPanelID]]); - EndMessage(); - } - } + if (sHUDPanels[iPanelID][iPageCurrent[iPanelID]][0]) + { + Handle hMessage = StartMessageOne("KeyHintText", client); + BfWriteByte(hMessage, 1); + BfWriteString(hMessage, sHUDPanels[iPanelID][iPageCurrent[iPanelID]]); + EndMessage(); + } + } + return Plugin_Handled; } //---------------------------------------------------------------------------------------------------- @@ -252,4 +254,4 @@ stock bool GetClientCookieBool(int client, Handle hCookie) GetClientCookie(client, hCookie, sValue, sizeof(sValue)); return view_as(StringToInt(sValue)); -} \ No newline at end of file +} diff --git a/entWatch4/scripting/entWatch-messages.sp b/entWatch4/scripting/entWatch-messages.sp index 7439f682..59a2723f 100644 --- a/entWatch4/scripting/entWatch-messages.sp +++ b/entWatch4/scripting/entWatch-messages.sp @@ -9,6 +9,7 @@ #pragma newdecls required +#include #include #include #include diff --git a/entWatch4/scripting/entWatch-restrictions.sp b/entWatch4/scripting/entWatch-restrictions.sp index bd984513..419421dc 100644 --- a/entWatch4/scripting/entWatch-restrictions.sp +++ b/entWatch4/scripting/entWatch-restrictions.sp @@ -9,6 +9,7 @@ #pragma newdecls required +#include #include #include #include @@ -512,4 +513,4 @@ stock int GetClientCookieInt(int client, Handle hCookie) GetClientCookie(client, hCookie, sValue, sizeof(sValue)); return StringToInt(sValue); -} \ No newline at end of file +} diff --git a/includes/basic.inc b/includes/basic.inc index deb286d2..d05f7d7b 100644 --- a/includes/basic.inc +++ b/includes/basic.inc @@ -109,12 +109,12 @@ methodmap Basic < StringMap this.SetValue(membername, value); } - public bool GetVector(const char[] membername, float[3] vector) + public bool GetVector(const char[] membername, float vector[3]) { return this.GetArray(membername, vector, sizeof(vector)); } - public void SetVector(const char[] membername, const float[3] value) + public void SetVector(const char[] membername, const float value[3]) { this.SetArray(membername, value, sizeof(value)); }