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

This commit is contained in:
jenz 2023-11-20 18:02:42 +01:00
parent 2d1ae71634
commit d6bf3799dd

View File

@ -16,6 +16,8 @@ int g_iZone_fought_or_ct_controlled[MAXZONES];
int g_iLast_Client_In_Zone[MAXPLAYERS + 1]; int g_iLast_Client_In_Zone[MAXPLAYERS + 1];
int ping_ents[MAXPLAYERS + 1]; int ping_ents[MAXPLAYERS + 1];
bool round_start_delay;
//spawning the markers //spawning the markers
float ping_coorindates[MAXZONES][3]; float ping_coorindates[MAXZONES][3];
int zone_pings[MAXZONES]; int zone_pings[MAXZONES];
@ -62,6 +64,7 @@ public void OnPluginStart()
HookEvent("player_death", OnClientDeath); HookEvent("player_death", OnClientDeath);
hText = CreateHudSynchronizer(); hText = CreateHudSynchronizer();
round_start_delay = true;
//timer for ZM zone benefits //timer for ZM zone benefits
g_hZMZoneTimer = CreateTimer(5.0, give_zm_zone_boosts, _, TIMER_REPEAT); 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) public void OnRoundEnd(Event hEvent, const char[] sEvent, bool bDontBroadcast)
{ {
round_start_delay = true;
bool found_alive_zm = false; bool found_alive_zm = false;
for (int client = 0; client < MaxClients; client++) 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_iZone_fought_or_ct_controlled[i] = -1;
g_iLast_Client_In_Zone[i] = 0; 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) public void unloze_zoneLeave(int client, char[] zone)
{ {
int index = g_client_in_zone[client]; int index = g_client_in_zone[client];
if (index < 0)
{
return;
}
g_client_in_zone[client] = -1; g_client_in_zone[client] = -1;
g_iCT_Damage_in_zone[client] = 0; g_iCT_Damage_in_zone[client] = 0;
if (GetClientTeam(client) == CS_TEAM_CT) 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) 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++) for (int j = zone_pings[i]; j < zone_pings[i + 1]; j++)
{ {
//the ping is atm not the skull, will be changed to skull. //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]; char msg[256];
if (g_cZones_CT_count[index] > 0 && g_cZones_ZM_count[index] > 0) 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); SetHudTextParams(0.35, 0.85, 2.5, 255, 255, 255, 85);
ShowSyncHudText(client, hText, msg); ShowSyncHudText(client, hText, msg);
} }