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)) if (IsValidClient(client))
{ {
int userid = GetClientUserId(client); int userid = GetClientUserId(client);
ServerCommand("sm_forceinputplayer #%i Clearparent", userid); 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 //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 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 player Clearparent;");
ServerCommand("sm_forceinput heli kill; sm_forceinput moblie kill; sm_forceinput car kill; sm_forceinput battery kill;"); 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); int userid = GetClientUserId(client);
ServerCommand("sm_forceinputplayer #%i Clearparent", userid); 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
@ -77,6 +79,8 @@ public void OnPluginStart()
} }
public Action announce_zone_controlls(Handle hTimer) public Action announce_zone_controlls(Handle hTimer)
{
if (g_is_zh_map)
{ {
float fought_zone = 0.0; float fought_zone = 0.0;
float ct_controlled_zone = 0.0; float ct_controlled_zone = 0.0;
@ -182,26 +186,39 @@ public Action announce_zone_controlls(Handle hTimer)
{ {
g_iAnnounce_zone_controll = 0; g_iAnnounce_zone_controll = 0;
} }
}
return Plugin_Handled; return Plugin_Handled;
} }
public void OnClientPutInServer(int client) public void OnClientPutInServer(int client)
{
if (g_is_zh_map)
{ {
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage); 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 (g_is_zh_map)
{ {
if (IsValidClient(attacker) && GetClientTeam(attacker) == CS_TEAM_CT && g_human_damage_addition != 1.0) if (IsValidClient(attacker) && GetClientTeam(attacker) == CS_TEAM_CT && g_human_damage_addition != 1.0)
{ {
damage += (g_human_damage_addition * damage); damage += (g_human_damage_addition * damage);
return Plugin_Changed; 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)
@ -237,6 +254,8 @@ public void OnPluginEnd()
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void OnClientDisconnect(int client) public void OnClientDisconnect(int client)
{
if (g_is_zh_map)
{ {
g_iCT_Damage_in_zone[client] = 0; g_iCT_Damage_in_zone[client] = 0;
client_target[client] = 0; client_target[client] = 0;
@ -245,9 +264,14 @@ public void OnClientDisconnect(int client)
g_bBlockRespawn[client] = 0; g_bBlockRespawn[client] = 0;
SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage); 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;
@ -275,6 +299,8 @@ 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_is_zh_map)
{ {
if(g_hZoneBenefits != INVALID_HANDLE) if(g_hZoneBenefits != INVALID_HANDLE)
{ {
@ -305,9 +331,14 @@ public void OnRoundEnd(Event hEvent, const char[] sEvent, bool bDontBroadcast)
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;
} }
@ -316,6 +347,8 @@ public Action permit_zone_benefits(Handle hTimer)
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast) public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast)
{
if (g_is_zh_map)
{ {
g_permit_zone_benefits = false; g_permit_zone_benefits = false;
g_hZoneBenefits = CreateTimer(35.0, permit_zone_benefits); g_hZoneBenefits = CreateTimer(35.0, permit_zone_benefits);
@ -340,9 +373,14 @@ public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast)
round_start_delay = true; round_start_delay = true;
CreateTimer(5.0, enable_pings); 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;
} }
@ -351,6 +389,8 @@ public Action enable_pings(Handle timer, any data)
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void OnClientDeath(Event hEvent, const char[] sEvent, bool bDontBroadcast) public void OnClientDeath(Event hEvent, const char[] sEvent, bool bDontBroadcast)
{
if (g_is_zh_map)
{ {
int victim = GetClientOfUserId(hEvent.GetInt("userid")); int victim = GetClientOfUserId(hEvent.GetInt("userid"));
g_client_in_zone[victim] = -1; g_client_in_zone[victim] = -1;
@ -361,8 +401,11 @@ public void OnClientDeath(Event hEvent, const char[] sEvent, bool bDontBroadcast
PrintToChat(victim, "\x04[ZR]\x01 You have %i respawns left for this round.", g_hRespawnTreshold.IntValue - g_bBlockRespawn[victim]); PrintToChat(victim, "\x04[ZR]\x01 You have %i respawns left for this round.", g_hRespawnTreshold.IntValue - g_bBlockRespawn[victim]);
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)
{
if (g_is_zh_map)
{ {
int index = g_client_in_zone[client]; int index = g_client_in_zone[client];
if (index != -1) if (index != -1)
@ -376,6 +419,7 @@ public void ZR_OnClientInfected(int client, int attacker, bool motherInfect, boo
UpdateMarkers(); UpdateMarkers();
} }
} }
}
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
@ -390,21 +434,32 @@ 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);
} }
public Action ZR_OnClientRespawn(&client, &ZR_RespawnCondition:condition) public Action ZR_OnClientRespawn(&client, &ZR_RespawnCondition:condition)
{
if (g_is_zh_map)
{ {
if (g_bBlockRespawn[client] > g_hRespawnTreshold.IntValue) if (g_bBlockRespawn[client] > g_hRespawnTreshold.IntValue)
return Plugin_Handled; return Plugin_Handled;
find_teleport_target(client); 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;
@ -471,14 +526,21 @@ public bool TraceRayHitOnlyEnt(int entityhit, int mask, any data) {
} }
public void OnClientPostAdminCheck(int client) public void OnClientPostAdminCheck(int client)
{
if (g_is_zh_map)
{ {
g_iCT_Damage_in_zone[client] = 0; g_iCT_Damage_in_zone[client] = 0;
client_target[client] = 0; client_target[client] = 0;
g_client_in_zone[client] = -1; 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];
@ -491,6 +553,8 @@ public Action tp_client(Handle timer, int client)
} }
public void unloze_zoneLeave(int client, char[] zone) public void unloze_zoneLeave(int client, char[] zone)
{
if (g_is_zh_map)
{ {
int index = g_client_in_zone[client]; int index = g_client_in_zone[client];
if (index < 0) if (index < 0)
@ -517,14 +581,22 @@ public void unloze_zoneLeave(int client, char[] zone)
SetEntityRenderColor(client, 255, 255, 255, 255); SetEntityRenderColor(client, 255, 255, 255, 255);
UpdateMarkers(); UpdateMarkers();
} }
}
public void unloze_zoneCreated() public void unloze_zoneCreated()
{
if (g_is_zh_map)
{ {
ReadZoneFile(); 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));
@ -541,6 +613,8 @@ public Action retry_zoneEntry(Handle timer, DataPack data)
} }
public void unloze_zoneEntry(int client, char[] zone) public void unloze_zoneEntry(int client, char[] zone)
{
if (g_is_zh_map)
{ {
int index = -1; int index = -1;
//unfortunately it can happen that a zone is entered before the current one is left, which can lead to -1 index //unfortunately it can happen that a zone is entered before the current one is left, which can lead to -1 index
@ -580,9 +654,14 @@ public void unloze_zoneEntry(int client, char[] zone)
display_hud_text(index, client); display_hud_text(index, client);
UpdateMarkers(); 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];
@ -634,6 +717,8 @@ public void display_hud_text(int index, int client)
// Purpose: Reads from file // Purpose: Reads from file
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public Action ReadZoneFile() public Action ReadZoneFile()
{
if (g_is_zh_map)
{ {
int i_zoneTemp; int i_zoneTemp;
char l_cMapName[MAXZONES]; char l_cMapName[MAXZONES];
@ -680,11 +765,42 @@ public Action ReadZoneFile()
} }
g_zoneCount = i_zoneTemp; g_zoneCount = i_zoneTemp;
delete l_hZoneFile; 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