diff --git a/zombie_hunting_respawn/zh_respawn_stop.sp b/zombie_hunting_respawn/zh_respawn_stop.sp new file mode 100644 index 00000000..a57c767f --- /dev/null +++ b/zombie_hunting_respawn/zh_respawn_stop.sp @@ -0,0 +1,68 @@ +#include +#include +int g_bBlockRespawn[MAXPLAYERS+1]; +ConVar g_hRespawnTreshold; +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public Plugin myinfo = +{ + name = "zh stop zm respawn", + author = "jenz", + description = "Disables respawning on zombie hunting maps after some deaths", + version = "1.0.0", + url = "www.unloze.com" +}; + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void OnPluginStart() +{ + g_hRespawnTreshold = CreateConVar("zh_respawn_count", "5.0", "zombie hunting respawn count", 0, true, 0.0, true, 100.0); + for (int client; client < MaxClients; client++) + g_bBlockRespawn[client] = 0; + + HookEvent("round_start", OnRoundStart); + HookEvent("player_death", OnClientDeath); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void OnClientDisconnect(int client) +{ + g_bBlockRespawn[client] = 0; +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast) +{ + for (int client; client < MaxClients; client++) + g_bBlockRespawn[client] = 0; +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void OnClientDeath(Event hEvent, const char[] sEvent, bool bDontBroadcast) +{ + int victim = GetClientOfUserId(hEvent.GetInt("userid")); + if (g_bBlockRespawn[victim] > g_hRespawnTreshold.FloatValue) + return; + PrintToChat(victim, "\x04[ZR]\x01 You have %f respawns left for this round.", g_hRespawnTreshold.FloatValue - g_bBlockRespawn[victim]); + g_bBlockRespawn[victim]++; +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public Action ZR_OnClientRespawn(&client, &ZR_RespawnCondition:condition) +{ + if (g_bBlockRespawn[client] > g_hRespawnTreshold.FloatValue) + return Plugin_Handled; + + return Plugin_Continue; +}