updated icecap plugins so its not interfering with ztele and events. also made zombie hunting plugin aln always active

This commit is contained in:
jenz 2024-08-01 20:24:16 +02:00
parent 983652c974
commit f420bfc7ed
2 changed files with 391 additions and 260 deletions

View File

@ -51,17 +51,14 @@ public void OnPluginStart()
public Action Command_ztele(int client, const char[] Command, int Args) public Action Command_ztele(int client, const char[] Command, int Args)
{ {
if (!g_b_is_icecap_act2) if (g_b_is_icecap_act2)
{ {
return Plugin_Handled; if (IsValidClient(client))
{
int userid = GetClientUserId(client);
ServerCommand("sm_forceinputplayer #%i Clearparent", userid);
}
} }
if (IsValidClient(client))
{
int userid = GetClientUserId(client);
ServerCommand("sm_forceinputplayer #%i Clearparent", userid);
}
return Plugin_Handled;
} }
public void OnClientPostAdminCheck(int client) public void OnClientPostAdminCheck(int client)
@ -78,25 +75,23 @@ stock bool IsValidClient(int client)
//right before round end deactivate gameUI and unparent players from moving vehicles. //right before round end deactivate gameUI and unparent players from moving vehicles.
public void OnRoundEnd(Handle event, const char[] name, bool dontBroadcast) public void OnRoundEnd(Handle event, const char[] name, bool dontBroadcast)
{ {
if (!g_b_is_icecap_act2) if (g_b_is_icecap_act2)
{ {
return; //its the correct map if it contains icecap_escape_act2
ServerCommand("sm_forceinput Game Deactivate; sm_forceinput Game2 Deactivate;sm_forceinput Game3 Deactivate;sm_forceinput Game4 Deactivate; sm_forceinput Gameleft Deactivate; sm_forceinput Gameright Deactivate; sm_forceinput Gameseat Deactivate; sm_forceinput Gameseat2 Deactivate; sm_forceinput Gameseat3 Deactivate; sm_forceinput Gameseat4 Deactivate; sm_forceinput Gameseat5 Deactivate; sm_forceinput Gameseat6 Deactivate;");
ServerCommand("sm_forceinput player Clearparent;");
ServerCommand("sm_forceinput heli kill; sm_forceinput moblie kill; sm_forceinput car kill; sm_forceinput battery kill;");
} }
//its the correct map if it contains icecap_escape_act2
ServerCommand("sm_forceinput Game Deactivate; sm_forceinput Game2 Deactivate;sm_forceinput Game3 Deactivate;sm_forceinput Game4 Deactivate; sm_forceinput Gameleft Deactivate; sm_forceinput Gameright Deactivate; sm_forceinput Gameseat Deactivate; sm_forceinput Gameseat2 Deactivate; sm_forceinput Gameseat3 Deactivate; sm_forceinput Gameseat4 Deactivate; sm_forceinput Gameseat5 Deactivate; sm_forceinput Gameseat6 Deactivate;");
ServerCommand("sm_forceinput player Clearparent;");
ServerCommand("sm_forceinput heli kill; sm_forceinput moblie kill; sm_forceinput car kill; sm_forceinput battery kill;");
} }
public void trigger_teleport(const char[] output, int entity_index, int client, float delay) public void trigger_teleport(const char[] output, int entity_index, int client, float delay)
{ {
if (!g_b_is_icecap_act2) if (g_b_is_icecap_act2)
{ {
return; if (IsValidClient(client))
} {
if (IsValidClient(client)) int userid = GetClientUserId(client);
{ ServerCommand("sm_forceinputplayer #%i Clearparent", userid);
int userid = GetClientUserId(client); }
ServerCommand("sm_forceinputplayer #%i Clearparent", userid);
} }
} }

View File

@ -19,6 +19,8 @@ int ping_ents[MAXPLAYERS + 1];
int g_iAnnounce_zone_controll = 0; int g_iAnnounce_zone_controll = 0;
bool g_permit_zone_benefits = false; bool g_permit_zone_benefits = false;
bool g_is_zh_map = false;
bool round_start_delay; bool round_start_delay;
//spawning the markers //spawning the markers
@ -78,130 +80,145 @@ public void OnPluginStart()
public Action announce_zone_controlls(Handle hTimer) public Action announce_zone_controlls(Handle hTimer)
{ {
float fought_zone = 0.0; if (g_is_zh_map)
float ct_controlled_zone = 0.0;
float zm_controlled_zone = 0.0;
if (g_zoneCount == 0 || !g_permit_zone_benefits)
{ {
g_human_damage_addition = 1.0; //indicating no damage buffs float fought_zone = 0.0;
for (int i = 0; i < MaxClients; i++) float ct_controlled_zone = 0.0;
float zm_controlled_zone = 0.0;
if (g_zoneCount == 0 || !g_permit_zone_benefits)
{ {
if (IsValidClient(i) && IsPlayerAlive(i)) g_human_damage_addition = 1.0; //indicating no damage buffs
for (int i = 0; i < MaxClients; i++)
{ {
SetEntityGravity(i, 1.0); if (IsValidClient(i) && IsPlayerAlive(i))
{
SetEntityGravity(i, 1.0);
}
}
return Plugin_Handled;
}
for (int i = 0; i < g_zoneCount; i++)
{
if (g_iZone_fought_or_ct_controlled[i] == 1) //fought over zone
{
fought_zone++;
}
if (g_iZone_fought_or_ct_controlled[i] == 2) //CT zone
{
ct_controlled_zone++;
}
if (g_iZone_fought_or_ct_controlled[i] == 3) //ZM zone
{
zm_controlled_zone++;
} }
} }
return Plugin_Handled; g_iAnnounce_zone_controll++;
} int ct_control_percentage = RoundToFloor((ct_controlled_zone/ g_zoneCount) * 100);
for (int i = 0; i < g_zoneCount; i++) int zm_control_percentage = RoundToFloor((zm_controlled_zone/ g_zoneCount) * 100);
{ int fought_percentage = RoundToFloor((fought_zone/ g_zoneCount) * 100);
if (g_iZone_fought_or_ct_controlled[i] == 1) //fought over zone if (g_iAnnounce_zone_controll >= 3)
{ {
fought_zone++; PrintToChatAll("CT controll %i%s of zones. ZM controll %i%s of zones. %i%s of zones are fought over",
ct_control_percentage, "%", zm_control_percentage, "%", fought_percentage, "%");
} }
if (g_iZone_fought_or_ct_controlled[i] == 2) //CT zone
{
ct_controlled_zone++;
}
if (g_iZone_fought_or_ct_controlled[i] == 3) //ZM zone
{
zm_controlled_zone++;
}
}
g_iAnnounce_zone_controll++;
int ct_control_percentage = RoundToFloor((ct_controlled_zone/ g_zoneCount) * 100);
int zm_control_percentage = RoundToFloor((zm_controlled_zone/ g_zoneCount) * 100);
int fought_percentage = RoundToFloor((fought_zone/ g_zoneCount) * 100);
if (g_iAnnounce_zone_controll >= 3)
{
PrintToChatAll("CT controll %i%s of zones. ZM controll %i%s of zones. %i%s of zones are fought over",
ct_control_percentage, "%", zm_control_percentage, "%", fought_percentage, "%");
}
if (zm_control_percentage > 70) if (zm_control_percentage > 70)
{
for (int i = 0; i < MaxClients; i++)
{ {
if (IsValidClient(i) && IsPlayerAlive(i)) for (int i = 0; i < MaxClients; i++)
{ {
if (GetClientTeam(i) == CS_TEAM_T) if (IsValidClient(i) && IsPlayerAlive(i))
{ {
SetEntityGravity(i, 0.7); if (GetClientTeam(i) == CS_TEAM_T)
{
SetEntityGravity(i, 0.7);
}
else
{
SetEntityGravity(i, 1.0);
}
} }
else }
if (g_iAnnounce_zone_controll >= 3)
{
PrintToChatAll("ZM controll over 70%s of zones. Applying 30%s low grav", "%", "%");
}
}
else
{
for (int i = 0; i < MaxClients; i++)
{
if (IsValidClient(i) && IsPlayerAlive(i))
{ {
SetEntityGravity(i, 1.0); SetEntityGravity(i, 1.0);
} }
} }
} }
if (g_iAnnounce_zone_controll >= 3)
if (ct_control_percentage > 90)
{ {
PrintToChatAll("ZM controll over 70%s of zones. Applying 30%s low grav", "%", "%"); g_human_damage_addition = 0.6;
} if (g_iAnnounce_zone_controll >= 3)
}
else
{
for (int i = 0; i < MaxClients; i++)
{
if (IsValidClient(i) && IsPlayerAlive(i))
{ {
SetEntityGravity(i, 1.0); PrintToChatAll("CT controll over 90%s of zones. Applying 60%s extra damage", "%", "%");
} }
} }
} else if (ct_control_percentage > 70)
{
if (ct_control_percentage > 90) g_human_damage_addition = 0.40;
{ if (g_iAnnounce_zone_controll >= 3)
g_human_damage_addition = 0.6; {
PrintToChatAll("CT controll over 70%s of zones. Applying 40%s extra damage", "%", "%");
}
}
else if (ct_control_percentage > 50)
{
g_human_damage_addition = 0.2;
if (g_iAnnounce_zone_controll >= 3)
{
PrintToChatAll("CT controll over 50%s of zones. Applying 20%s extra damage", "%", "%");
}
}
else
{
g_human_damage_addition = 1.0; //indicating no damage buffs
}
if (g_iAnnounce_zone_controll >= 3) if (g_iAnnounce_zone_controll >= 3)
{ {
PrintToChatAll("CT controll over 90%s of zones. Applying 60%s extra damage", "%", "%"); g_iAnnounce_zone_controll = 0;
} }
} }
else if (ct_control_percentage > 70)
{
g_human_damage_addition = 0.40;
if (g_iAnnounce_zone_controll >= 3)
{
PrintToChatAll("CT controll over 70%s of zones. Applying 40%s extra damage", "%", "%");
}
}
else if (ct_control_percentage > 50)
{
g_human_damage_addition = 0.2;
if (g_iAnnounce_zone_controll >= 3)
{
PrintToChatAll("CT controll over 50%s of zones. Applying 20%s extra damage", "%", "%");
}
}
else
{
g_human_damage_addition = 1.0; //indicating no damage buffs
}
if (g_iAnnounce_zone_controll >= 3)
{
g_iAnnounce_zone_controll = 0;
}
return Plugin_Handled; return Plugin_Handled;
} }
public void OnClientPutInServer(int client) public void OnClientPutInServer(int client)
{ {
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage); if (g_is_zh_map)
{
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
}
} }
public Action OnTakeDamage(int client, int &attacker, int &inflictor, float &damage, int &damagetype) public Action OnTakeDamage(int client, int &attacker, int &inflictor, float &damage, int &damagetype)
{ {
if (IsValidClient(attacker) && GetClientTeam(attacker) == CS_TEAM_CT && g_human_damage_addition != 1.0) if (g_is_zh_map)
{ {
damage += (g_human_damage_addition * damage); if (IsValidClient(attacker) && GetClientTeam(attacker) == CS_TEAM_CT && g_human_damage_addition != 1.0)
return Plugin_Changed; {
damage += (g_human_damage_addition * damage);
return Plugin_Changed;
}
} }
return Plugin_Continue; return Plugin_Continue;
} }
public Action give_zm_zone_boosts(Handle hTimer) public Action give_zm_zone_boosts(Handle hTimer)
{ {
if (!g_is_zh_map)
{
return Plugin_Handled;
}
for (int client; client < MaxClients; client++) for (int client; client < MaxClients; client++)
{ {
if (IsValidClient(client) && IsPlayerAlive(client) && GetClientTeam(client) == CS_TEAM_T) if (IsValidClient(client) && IsPlayerAlive(client) && GetClientTeam(client) == CS_TEAM_T)
@ -238,16 +255,23 @@ public void OnPluginEnd()
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void OnClientDisconnect(int client) public void OnClientDisconnect(int client)
{ {
g_iCT_Damage_in_zone[client] = 0; if (g_is_zh_map)
client_target[client] = 0; {
g_client_in_zone[client] = -1; g_iCT_Damage_in_zone[client] = 0;
adjust_clients(); //calling GetClientTeam inside adjust_clients complaints that client already disconnected. client_target[client] = 0;
g_bBlockRespawn[client] = 0; g_client_in_zone[client] = -1;
SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage); adjust_clients(); //calling GetClientTeam inside adjust_clients complaints that client already disconnected.
g_bBlockRespawn[client] = 0;
SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage);
}
} }
public void adjust_clients() public void adjust_clients()
{ {
if (!g_is_zh_map)
{
return;
}
for (int i = 0; i < MAXZONES; i++) for (int i = 0; i < MAXZONES; i++)
{ {
g_cZones_CT_count[i] = 0; g_cZones_CT_count[i] = 0;
@ -276,38 +300,45 @@ public void adjust_clients()
public void OnRoundEnd(Event hEvent, const char[] sEvent, bool bDontBroadcast) public void OnRoundEnd(Event hEvent, const char[] sEvent, bool bDontBroadcast)
{ {
if(g_hZoneBenefits != INVALID_HANDLE) if (g_is_zh_map)
{ {
KillTimer(g_hZoneBenefits); if(g_hZoneBenefits != INVALID_HANDLE)
g_hZoneBenefits = INVALID_HANDLE;
}
round_start_delay = true;
bool found_alive_zm = false;
for (int client = 0; client < MaxClients; client++)
{
if (IsValidClient(client) && GetClientTeam(client) == CS_TEAM_T && IsPlayerAlive(client))
{ {
found_alive_zm = true; KillTimer(g_hZoneBenefits);
g_hZoneBenefits = INVALID_HANDLE;
} }
} round_start_delay = true;
bool found_alive_zm = false;
if (found_alive_zm)
{
for (int client = 0; client < MaxClients; client++) for (int client = 0; client < MaxClients; client++)
{ {
if (IsValidClient(client) && GetClientTeam(client) == CS_TEAM_CT) if (IsValidClient(client) && GetClientTeam(client) == CS_TEAM_T && IsPlayerAlive(client))
{ {
ForcePlayerSuicide(client); found_alive_zm = true;
} }
} }
PrintToChatAll("Humans failed!");
PrintToChatAll("Humans failed!"); if (found_alive_zm)
PrintToChatAll("Humans failed!"); {
for (int client = 0; client < MaxClients; client++)
{
if (IsValidClient(client) && GetClientTeam(client) == CS_TEAM_CT)
{
ForcePlayerSuicide(client);
}
}
PrintToChatAll("Humans failed!");
PrintToChatAll("Humans failed!");
PrintToChatAll("Humans failed!");
}
} }
} }
public Action permit_zone_benefits(Handle hTimer) public Action permit_zone_benefits(Handle hTimer)
{ {
if (!g_is_zh_map)
{
return Plugin_Handled;
}
g_permit_zone_benefits = true; g_permit_zone_benefits = true;
return Plugin_Handled; return Plugin_Handled;
} }
@ -317,32 +348,39 @@ public Action permit_zone_benefits(Handle hTimer)
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast) public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast)
{ {
g_permit_zone_benefits = false; if (g_is_zh_map)
g_hZoneBenefits = CreateTimer(35.0, permit_zone_benefits);
g_human_damage_addition = 1.0;
for (int client = 0; client < MaxClients; client++)
{ {
g_bBlockRespawn[client] = 0; g_permit_zone_benefits = false;
if (IsValidClient(client)) g_hZoneBenefits = CreateTimer(35.0, permit_zone_benefits);
g_human_damage_addition = 1.0;
for (int client = 0; client < MaxClients; client++)
{ {
g_iCT_Damage_in_zone[client] = 0; g_bBlockRespawn[client] = 0;
if (IsValidClient(client))
{
g_iCT_Damage_in_zone[client] = 0;
}
g_client_in_zone[client] = -1;
} }
g_client_in_zone[client] = -1;
}
for (int i = 0; i < MAXZONES; i++) for (int i = 0; i < MAXZONES; i++)
{ {
g_cZones_CT_count[i] = 0; g_cZones_CT_count[i] = 0;
g_cZones_ZM_count[i] = 0; g_cZones_ZM_count[i] = 0;
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);
} }
round_start_delay = true;
CreateTimer(5.0, enable_pings);
} }
public Action enable_pings(Handle timer, any data) public Action enable_pings(Handle timer, any data)
{ {
if (!g_is_zh_map)
{
return Plugin_Handled;
}
round_start_delay = false; round_start_delay = false;
return Plugin_Handled; return Plugin_Handled;
} }
@ -352,28 +390,34 @@ public Action enable_pings(Handle timer, any data)
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void OnClientDeath(Event hEvent, const char[] sEvent, bool bDontBroadcast) public void OnClientDeath(Event hEvent, const char[] sEvent, bool bDontBroadcast)
{ {
int victim = GetClientOfUserId(hEvent.GetInt("userid")); if (g_is_zh_map)
g_client_in_zone[victim] = -1; {
adjust_clients(); int victim = GetClientOfUserId(hEvent.GetInt("userid"));
SetEntityRenderColor(victim, 255, 255, 255, 255); g_client_in_zone[victim] = -1;
if (g_bBlockRespawn[victim] > g_hRespawnTreshold.IntValue) adjust_clients();
return; SetEntityRenderColor(victim, 255, 255, 255, 255);
PrintToChat(victim, "\x04[ZR]\x01 You have %i respawns left for this round.", g_hRespawnTreshold.IntValue - g_bBlockRespawn[victim]); if (g_bBlockRespawn[victim] > g_hRespawnTreshold.IntValue)
g_bBlockRespawn[victim]++; return;
PrintToChat(victim, "\x04[ZR]\x01 You have %i respawns left for this round.", g_hRespawnTreshold.IntValue - g_bBlockRespawn[victim]);
g_bBlockRespawn[victim]++;
}
} }
public void ZR_OnClientInfected(int client, int attacker, bool motherInfect, bool respawnOverride, bool respawn) public void ZR_OnClientInfected(int client, int attacker, bool motherInfect, bool respawnOverride, bool respawn)
{ {
int index = g_client_in_zone[client]; if (g_is_zh_map)
if (index != -1)
{ {
//client got infected inside a specific zone, reduce human count inside that specific zone by 1 int index = g_client_in_zone[client];
if (g_cZones_CT_count[index] > 0) if (index != -1)
{ {
g_cZones_CT_count[index]--; //client got infected inside a specific zone, reduce human count inside that specific zone by 1
if (g_cZones_CT_count[index] > 0)
{
g_cZones_CT_count[index]--;
}
g_cZones_ZM_count[index]++;
UpdateMarkers();
} }
g_cZones_ZM_count[index]++;
UpdateMarkers();
} }
} }
@ -390,6 +434,10 @@ stock bool IsValidClient(int client)
public float get_power_distance(int target_player, float pos[3]) public float get_power_distance(int target_player, float pos[3])
{ {
if (!g_is_zh_map)
{
return 0.0;
}
float vec[3]; float vec[3];
GetClientAbsOrigin(target_player, vec); GetClientAbsOrigin(target_player, vec);
return GetVectorDistance(vec, pos); return GetVectorDistance(vec, pos);
@ -397,14 +445,21 @@ public float get_power_distance(int target_player, float pos[3])
public Action ZR_OnClientRespawn(&client, &ZR_RespawnCondition:condition) public Action ZR_OnClientRespawn(&client, &ZR_RespawnCondition:condition)
{ {
if (g_bBlockRespawn[client] > g_hRespawnTreshold.IntValue) if (g_is_zh_map)
return Plugin_Handled; {
find_teleport_target(client); if (g_bBlockRespawn[client] > g_hRespawnTreshold.IntValue)
return Plugin_Handled;
find_teleport_target(client);
}
return Plugin_Continue; return Plugin_Continue;
} }
public void find_teleport_target(int client) public void find_teleport_target(int client)
{ {
if (!g_is_zh_map)
{
return;
}
//teleport player to team members with farthest distance to enemy just. //teleport player to team members with farthest distance to enemy just.
//checking all alive clients to determine which client has highest dist_target to its closest enemy //checking all alive clients to determine which client has highest dist_target to its closest enemy
float total_furthest_distance = -1.0; float total_furthest_distance = -1.0;
@ -472,13 +527,20 @@ public bool TraceRayHitOnlyEnt(int entityhit, int mask, any data) {
public void OnClientPostAdminCheck(int client) public void OnClientPostAdminCheck(int client)
{ {
g_iCT_Damage_in_zone[client] = 0; if (g_is_zh_map)
client_target[client] = 0; {
g_client_in_zone[client] = -1; g_iCT_Damage_in_zone[client] = 0;
client_target[client] = 0;
g_client_in_zone[client] = -1;
}
} }
public Action tp_client(Handle timer, int client) public Action tp_client(Handle timer, int client)
{ {
if (!g_is_zh_map)
{
return Plugin_Handled;
}
if (IsValidClient(client) && IsValidClient(client_target[client])) if (IsValidClient(client) && IsValidClient(client_target[client]))
{ {
float posd[3]; float posd[3];
@ -492,39 +554,49 @@ 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]; if (g_is_zh_map)
if (index < 0)
{ {
return; 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)
{
if (g_cZones_CT_count[index] > 0)
{ {
g_cZones_CT_count[index]--; if (g_cZones_CT_count[index] > 0)
{
g_cZones_CT_count[index]--;
}
} }
} else
else
{
if (g_cZones_ZM_count[index] > 0)
{ {
g_cZones_ZM_count[index]--; if (g_cZones_ZM_count[index] > 0)
{
g_cZones_ZM_count[index]--;
}
} }
SetEntityRenderColor(client, 255, 255, 255, 255);
UpdateMarkers();
} }
SetEntityRenderColor(client, 255, 255, 255, 255);
UpdateMarkers();
} }
public void unloze_zoneCreated() public void unloze_zoneCreated()
{ {
ReadZoneFile(); if (g_is_zh_map)
{
ReadZoneFile();
}
} }
public Action retry_zoneEntry(Handle timer, DataPack data) public Action retry_zoneEntry(Handle timer, DataPack data)
{ {
if (!g_is_zh_map)
{
return Plugin_Handled;
}
ResetPack(data); ResetPack(data);
char zone[256]; char zone[256];
data.ReadString(zone, sizeof(zone)); data.ReadString(zone, sizeof(zone));
@ -542,47 +614,54 @@ public Action retry_zoneEntry(Handle timer, DataPack data)
public void unloze_zoneEntry(int client, char[] zone) public void unloze_zoneEntry(int client, char[] zone)
{ {
int index = -1; if (g_is_zh_map)
//unfortunately it can happen that a zone is entered before the current one is left, which can lead to -1 index
//when leaving the zone again.
//example: Enter new zone before old is left -> leave old zone -> index is -1 -> leave current zone -> leave forward is called before entering new zone is called ->
//tries to do -- on a array index where the index is -1
if (g_client_in_zone[client] != -1)
{ {
//the previous zone has to be left before we recognize the client entering the new zone int index = -1;
//only special cases are roundstart/respawning //unfortunately it can happen that a zone is entered before the current one is left, which can lead to -1 index
DataPack hDataPack = new DataPack(); //when leaving the zone again.
hDataPack.WriteString(zone); //example: Enter new zone before old is left -> leave old zone -> index is -1 -> leave current zone -> leave forward is called before entering new zone is called ->
hDataPack.WriteCell(GetClientSerial(client)); //tries to do -- on a array index where the index is -1
CreateTimer(0.2, retry_zoneEntry, hDataPack); if (g_client_in_zone[client] != -1)
return;
}
for (int i = 0; i < g_zoneCount; i++)
{
if (StrEqual(g_cZones[i], zone))
{ {
index = i; //the previous zone has to be left before we recognize the client entering the new zone
break; //only special cases are roundstart/respawning
DataPack hDataPack = new DataPack();
hDataPack.WriteString(zone);
hDataPack.WriteCell(GetClientSerial(client));
CreateTimer(0.2, retry_zoneEntry, hDataPack);
return;
} }
} for (int i = 0; i < g_zoneCount; i++)
g_client_in_zone[client] = index; {
if (StrEqual(g_cZones[i], zone))
{
index = i;
break;
}
}
g_client_in_zone[client] = index;
g_iCT_Damage_in_zone[client] = PlayerRankings_GetClientDamage(client); g_iCT_Damage_in_zone[client] = PlayerRankings_GetClientDamage(client);
if (GetClientTeam(client) == CS_TEAM_CT) if (GetClientTeam(client) == CS_TEAM_CT)
{ {
g_cZones_CT_count[index]++; g_cZones_CT_count[index]++;
}
else
{
g_cZones_ZM_count[index]++;
}
g_iLast_Client_In_Zone[index] = client;
display_hud_text(index, client);
UpdateMarkers();
} }
else
{
g_cZones_ZM_count[index]++;
}
g_iLast_Client_In_Zone[index] = client;
display_hud_text(index, client);
UpdateMarkers();
} }
public void handle_pings(int i, int pingtype) public void handle_pings(int i, int pingtype)
{ {
if (!g_is_zh_map)
{
return;
}
if (round_start_delay) if (round_start_delay)
{ {
return; //preventing pings from spawning exactly on roundStart as it might cause too many entities return; //preventing pings from spawning exactly on roundStart as it might cause too many entities
@ -604,6 +683,10 @@ public void handle_pings(int i, int pingtype)
public void display_hud_text(int index, int client) public void display_hud_text(int index, int client)
{ {
if (!g_is_zh_map)
{
return;
}
if (hText != INVALID_HANDLE) if (hText != INVALID_HANDLE)
{ {
char msg[256]; char msg[256];
@ -635,56 +718,89 @@ public void display_hud_text(int index, int client)
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public Action ReadZoneFile() public Action ReadZoneFile()
{ {
int i_zoneTemp; if (g_is_zh_map)
char l_cMapName[MAXZONES];
GetCurrentMap(l_cMapName, sizeof(l_cMapName));
Handle l_hZoneFile = INVALID_HANDLE;
char l_cLine[ZONENAMELENGTH];
char sPart[4][32];
BuildPath(Path_SM, g_cConfigZones, sizeof(g_cConfigZones), "configs/unloze_zones/%s.zones.txt", l_cMapName);
l_hZoneFile = OpenFile(g_cConfigZones, "r");
if (l_hZoneFile == INVALID_HANDLE)
{ {
Handle kv = CreateKeyValues("Zones"); int i_zoneTemp;
KeyValuesToFile(kv, g_cConfigZones); char l_cMapName[MAXZONES];
CloseHandle(kv); GetCurrentMap(l_cMapName, sizeof(l_cMapName));
Handle l_hZoneFile = INVALID_HANDLE;
char l_cLine[ZONENAMELENGTH];
char sPart[4][32];
BuildPath(Path_SM, g_cConfigZones, sizeof(g_cConfigZones), "configs/unloze_zones/%s.zones.txt", l_cMapName);
l_hZoneFile = OpenFile(g_cConfigZones, "r");
if (l_hZoneFile == INVALID_HANDLE)
{
Handle kv = CreateKeyValues("Zones");
KeyValuesToFile(kv, g_cConfigZones);
CloseHandle(kv);
delete l_hZoneFile;
return Plugin_Handled;
}
while (!IsEndOfFile(l_hZoneFile) && ReadFileLine(l_hZoneFile, l_cLine, sizeof(l_cLine)))
{
if (StrContains(l_cLine, "name", false) > -1)
{
ReplaceStrings(l_cLine, "name");
Format(g_cZones[i_zoneTemp], sizeof(g_cZones), l_cLine);
}
if (StrContains(l_cLine, "cordinate_a", false) >= 0)
{
ReplaceString(l_cLine, sizeof(l_cLine), "\"", "", true);
ReplaceString(l_cLine, sizeof(l_cLine), "cordinate_a", "", true);
ExplodeString(l_cLine, " ", sPart, 4, 32);
g_fStartPos[i_zoneTemp][0] = StringToFloat(sPart[0]);//reading first vector
g_fStartPos[i_zoneTemp][1] = StringToFloat(sPart[1]);//reading second vector
g_fStartPos[i_zoneTemp][2] = StringToFloat(sPart[2]);//reading third vector
}
if (StrContains(l_cLine, "cordinate_b", false) >= 0)
{
ReplaceString(l_cLine, sizeof(l_cLine), "\"", "", true);
ReplaceString(l_cLine, sizeof(l_cLine), "cordinate_b", "", true);
ExplodeString(l_cLine, " ", sPart, 4, 32);
g_fEndPos[i_zoneTemp][0] = StringToFloat(sPart[0]);
g_fEndPos[i_zoneTemp][1] = StringToFloat(sPart[1]);
g_fEndPos[i_zoneTemp][2] = StringToFloat(sPart[2]);
i_zoneTemp++;
}
}
g_zoneCount = i_zoneTemp;
delete l_hZoneFile; delete l_hZoneFile;
return Plugin_Handled;
} }
while (!IsEndOfFile(l_hZoneFile) && ReadFileLine(l_hZoneFile, l_cLine, sizeof(l_cLine)))
{
if (StrContains(l_cLine, "name", false) > -1)
{
ReplaceStrings(l_cLine, "name");
Format(g_cZones[i_zoneTemp], sizeof(g_cZones), l_cLine);
}
if (StrContains(l_cLine, "cordinate_a", false) >= 0)
{
ReplaceString(l_cLine, sizeof(l_cLine), "\"", "", true);
ReplaceString(l_cLine, sizeof(l_cLine), "cordinate_a", "", true);
ExplodeString(l_cLine, " ", sPart, 4, 32);
g_fStartPos[i_zoneTemp][0] = StringToFloat(sPart[0]);//reading first vector
g_fStartPos[i_zoneTemp][1] = StringToFloat(sPart[1]);//reading second vector
g_fStartPos[i_zoneTemp][2] = StringToFloat(sPart[2]);//reading third vector
}
if (StrContains(l_cLine, "cordinate_b", false) >= 0)
{
ReplaceString(l_cLine, sizeof(l_cLine), "\"", "", true);
ReplaceString(l_cLine, sizeof(l_cLine), "cordinate_b", "", true);
ExplodeString(l_cLine, " ", sPart, 4, 32);
g_fEndPos[i_zoneTemp][0] = StringToFloat(sPart[0]);
g_fEndPos[i_zoneTemp][1] = StringToFloat(sPart[1]);
g_fEndPos[i_zoneTemp][2] = StringToFloat(sPart[2]);
i_zoneTemp++;
}
}
g_zoneCount = i_zoneTemp;
delete l_hZoneFile;
return Plugin_Handled; return Plugin_Handled;
} }
public void OnMapStart() public void OnMapStart()
{ {
g_is_zh_map = false;
char sConfigFile[PLATFORM_MAX_PATH];
BuildPath(Path_SM, sConfigFile, sizeof(sConfigFile), "configs/zh_maps.cfg");
if(!FileExists(sConfigFile))
{
LogMessage("Could not find config: \"%s\"", sConfigFile);
return;
}
char map[PLATFORM_MAX_PATH];
GetCurrentMap(map, PLATFORM_MAX_PATH);
new Handle:fileHandle = OpenFile(sConfigFile, "r" );
char lineBuffer[256];
while( !IsEndOfFile( fileHandle ) && ReadFileLine( fileHandle, lineBuffer, sizeof( lineBuffer ) ) )
{
TrimString( lineBuffer );
if (StrEqual(lineBuffer, map, false))
{
g_is_zh_map = true;
break;
}
}
CloseHandle( fileHandle );
if (!g_is_zh_map)
{
return;
}
g_human_damage_addition = 1.0; g_human_damage_addition = 1.0;
//resetting coordinates and setup. //resetting coordinates and setup.
for (int i = 0; i < MAXZONES; i++) for (int i = 0; i < MAXZONES; i++)
@ -956,6 +1072,10 @@ stock void ReplaceStrings(char[] str, char[] strReplace)
public void SpawnPing(int skin, float pos[3], int index) public void SpawnPing(int skin, float pos[3], int index)
{ {
if (!g_is_zh_map)
{
return;
}
int Ent = CreateEntityByName("prop_dynamic"); int Ent = CreateEntityByName("prop_dynamic");
SetEntityModel(Ent, "models/unloze/unloze_ping.mdl"); SetEntityModel(Ent, "models/unloze/unloze_ping.mdl");
DispatchKeyValue(Ent, "modelscale", "1.5"); DispatchKeyValue(Ent, "modelscale", "1.5");
@ -978,6 +1098,10 @@ public void SpawnPing(int skin, float pos[3], int index)
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void RemovePing(int index) public void RemovePing(int index)
{ {
if (!g_is_zh_map)
{
return;
}
if (ping_ents[index] != -1 && IsValidEdict(ping_ents[index])) if (ping_ents[index] != -1 && IsValidEdict(ping_ents[index]))
{ {
char m_szClassname[64]; char m_szClassname[64];
@ -992,6 +1116,10 @@ public void RemovePing(int index)
public void UpdateMarkers() public void UpdateMarkers()
{ {
if (!g_is_zh_map)
{
return;
}
//this only works because of knowing that order of ping coordinates match with zone order. //this only works because of knowing that order of ping coordinates match with zone order.
for (int i = 0; i <= g_zoneCount; i++) for (int i = 0; i <= g_zoneCount; i++)
{ {
@ -1063,6 +1191,10 @@ public void UpdateMarkers()
public void reward_zm_zone_points(int i) public void reward_zm_zone_points(int i)
{ {
if (!g_is_zh_map)
{
return;
}
for (int j = 0; j < MaxClients; j++) for (int j = 0; j < MaxClients; j++)
{ {
//is validclient, is ct, is alive, is inside the zone that just changed from fought to T controlled //is validclient, is ct, is alive, is inside the zone that just changed from fought to T controlled
@ -1078,6 +1210,10 @@ public void reward_zm_zone_points(int i)
public void reward_ct_zone_points(int i) public void reward_ct_zone_points(int i)
{ {
if (!g_is_zh_map)
{
return;
}
for (int j = 0; j < MaxClients; j++) for (int j = 0; j < MaxClients; j++)
{ {
//is validclient, is ct, is alive, is inside the zone that just changed from fought to CT controlled //is validclient, is ct, is alive, is inside the zone that just changed from fought to CT controlled