initial commit

This commit is contained in:
jenz 2023-01-01 23:39:45 +01:00
parent 121db6b607
commit 205bdd6d07

View File

@ -0,0 +1,68 @@
#include <sourcemod>
#include <zombiereloaded>
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;
}