This commit is contained in:
Dogan 2020-01-15 17:45:00 +01:00
parent 79afb917ed
commit e412858878
2 changed files with 10 additions and 11 deletions

View File

@ -9,7 +9,7 @@ float g_fDeathTime[MAXPLAYERS+1];
/* CONVARS */ /* CONVARS */
ConVar g_hRespawnDelay; ConVar g_hRespawnDelay;
ConVar g_hRespawnTreshold; ConVar g_hRespawnTreshold; //Test
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
@ -30,12 +30,12 @@ public void OnPluginStart()
{ {
if((g_hRespawnDelay = FindConVar("zr_respawn_delay")) == INVALID_HANDLE) if((g_hRespawnDelay = FindConVar("zr_respawn_delay")) == INVALID_HANDLE)
SetFailState("Failed to find zr_respawn_delay cvar."); SetFailState("Failed to find zr_respawn_delay cvar.");
g_hRespawnTreshold = CreateConVar("zr_repeatkill_threshold", "1.0", "Zombie Reloaded Repeat Kill Detector Threshold", 0, true, 0.0, true, 10.0); g_hRespawnTreshold = CreateConVar("zr_repeatkill_threshold", "1.0", "Zombie Reloaded Repeat Kill Detector Threshold", 0, true, 0.0, true, 10.0);
HookEvent("round_start", OnRoundStart); HookEvent("round_start", OnRoundStart);
HookEvent("player_death", OnClientDeath); HookEvent("player_death", OnClientDeath);
AutoExecConfig(true, "plugin.RepeatKillDetector"); AutoExecConfig(true, "plugin.RepeatKillDetector");
} }
@ -64,23 +64,23 @@ public void OnClientDeath(Event hEvent, const char[] sEvent, bool bDontBroadcast
{ {
char sWeapon[32]; char sWeapon[32];
hEvent.GetString("weapon", sWeapon, sizeof(sWeapon)) hEvent.GetString("weapon", sWeapon, sizeof(sWeapon))
int victim = GetClientOfUserId(hEvent.GetInt("userid")); int victim = GetClientOfUserId(hEvent.GetInt("userid"));
int client = GetClientOfUserId(hEvent.GetInt("attacker")); int client = GetClientOfUserId(hEvent.GetInt("attacker"));
if (g_bBlockRespawn[victim]) if (g_bBlockRespawn[victim])
return; return;
if (victim && !client && StrEqual(sWeapon, "trigger_hurt")) if (victim && !client && StrEqual(sWeapon, "trigger_hurt"))
{ {
float fGameTime = GetGameTime(); float fGameTime = GetGameTime();
if (fGameTime - g_fDeathTime[victim] - g_hRespawnDelay.FloatValue <= g_hRespawnTreshold.FloatValue) if (fGameTime - g_fDeathTime[victim] - g_hRespawnDelay.FloatValue <= g_hRespawnTreshold.FloatValue)
{ {
PrintToChat(victim, "\x04[ZR]\x01 Repeat killer detected. Disabling your respawn for this round."); PrintToChat(victim, "\x04[ZR]\x01 Repeat killer detected. Disabling your respawn for this round.");
g_bBlockRespawn[victim] = true; g_bBlockRespawn[victim] = true;
} }
g_fDeathTime[victim] = fGameTime; g_fDeathTime[victim] = fGameTime;
} }
} }
@ -92,6 +92,6 @@ public Action ZR_OnClientRespawn(&client, &ZR_RespawnCondition:condition)
{ {
if (g_bBlockRespawn[client]) if (g_bBlockRespawn[client])
return Plugin_Handled; return Plugin_Handled;
return Plugin_Continue; return Plugin_Continue;
} }

@ -1 +0,0 @@
Subproject commit e0dfc41273433d455c61411d3c2761f317b72244