From d6bf3799dd1c7183810a534a52eda57b3d1878e3 Mon Sep 17 00:00:00 2001 From: jenz Date: Mon, 20 Nov 2023 18:02:42 +0100 Subject: [PATCH] ignoring index out of bounds cause for when leaving zone. also made pings spawn around 5 seconds into the round to mitigate entity pressure at round start --- zombie_hunting_respawn/zh_respawn_stop.sp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/zombie_hunting_respawn/zh_respawn_stop.sp b/zombie_hunting_respawn/zh_respawn_stop.sp index a864e392..135f8be4 100644 --- a/zombie_hunting_respawn/zh_respawn_stop.sp +++ b/zombie_hunting_respawn/zh_respawn_stop.sp @@ -16,6 +16,8 @@ int g_iZone_fought_or_ct_controlled[MAXZONES]; int g_iLast_Client_In_Zone[MAXPLAYERS + 1]; int ping_ents[MAXPLAYERS + 1]; +bool round_start_delay; + //spawning the markers float ping_coorindates[MAXZONES][3]; int zone_pings[MAXZONES]; @@ -62,6 +64,7 @@ public void OnPluginStart() HookEvent("player_death", OnClientDeath); hText = CreateHudSynchronizer(); + round_start_delay = true; //timer for ZM zone benefits g_hZMZoneTimer = CreateTimer(5.0, give_zm_zone_boosts, _, TIMER_REPEAT); } @@ -137,6 +140,7 @@ public void adjust_clients() public void OnRoundEnd(Event hEvent, const char[] sEvent, bool bDontBroadcast) { + round_start_delay = true; bool found_alive_zm = false; for (int client = 0; client < MaxClients; client++) { @@ -183,6 +187,14 @@ public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast) g_iZone_fought_or_ct_controlled[i] = -1; g_iLast_Client_In_Zone[i] = 0; } + round_start_delay = true; + CreateTimer(5.0, enable_pings); +} + +public Action enable_pings(Handle timer, any data) +{ + round_start_delay = false; + return Plugin_Handled; } //---------------------------------------------------------------------------------------------------- @@ -327,6 +339,11 @@ public Action tp_client(Handle timer, int client) public void unloze_zoneLeave(int client, char[] zone) { int index = g_client_in_zone[client]; + if (index < 0) + { + return; + } + g_client_in_zone[client] = -1; g_iCT_Damage_in_zone[client] = 0; if (GetClientTeam(client) == CS_TEAM_CT) @@ -412,6 +429,10 @@ public void unloze_zoneEntry(int client, char[] zone) public void handle_pings(int i, int pingtype) { + if (round_start_delay) + { + return; //preventing pings from spawning exactly on roundStart as it might cause too many entities + } for (int j = zone_pings[i]; j < zone_pings[i + 1]; j++) { //the ping is atm not the skull, will be changed to skull. @@ -434,7 +455,7 @@ public void display_hud_text(int index, int client) char msg[256]; if (g_cZones_CT_count[index] > 0 && g_cZones_ZM_count[index] > 0) { - Format(msg, sizeof(msg), "Fought over zone"); + Format(msg, sizeof(msg), "Contested zone"); SetHudTextParams(0.35, 0.85, 2.5, 255, 255, 255, 85); ShowSyncHudText(client, hText, msg); }