UptimeRestarts + KnifeRevert
minor fixes
This commit is contained in:
parent
dc04b21eb4
commit
eff26eba30
@ -7,32 +7,31 @@
|
||||
|
||||
bool g_bKnifeRevert;
|
||||
bool g_bSlayKnifer;
|
||||
float g_fMaxDistance;
|
||||
float g_fMaxTime;
|
||||
|
||||
int g_iClientIndexKnifer;
|
||||
int g_iClientIndexKnifedZombie;
|
||||
bool g_bKnife;
|
||||
bool g_bInfectedInRadius[MAXPLAYERS + 1];
|
||||
bool g_bInfectedByKnifeForward[MAXPLAYERS + 1];
|
||||
|
||||
Handle KnifeRevertTimer;
|
||||
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "KnifeRevert",
|
||||
author = "Dogan",
|
||||
description = "Tool for Admins to prevent teamkilling cause of zombie knifing (ZE)",
|
||||
version = "1.1.0",
|
||||
version = "2.0.0",
|
||||
url = ""
|
||||
}
|
||||
|
||||
public void OnPluginStart()
|
||||
{
|
||||
ConVar cvar;
|
||||
HookConVarChange((cvar = CreateConVar("sm_kr_enabled", "1", "1 = sm_kniferevert is available, 0 = sm_kniferevert is not available", FCVAR_NONE, true, 0.0, true, 1.0)), g_cvZAbuse);
|
||||
HookConVarChange((cvar = CreateConVar("sm_kr_enabled", "1", "1 = sm_kniferevert is available, 0 = sm_kniferevert is not available", FCVAR_NONE, true, 0.0, true, 1.0)), g_cvKnifeRevert);
|
||||
g_bKnifeRevert = cvar.BoolValue;
|
||||
HookConVarChange((cvar = CreateConVar("sm_kr_slay", "0", "1 = slays the knifer automatically when sm_kniferevert is used, 0 = don't do anything to the knifer", FCVAR_NONE, true, 0.0, true, 1.0)), g_cvSlayKnifer);
|
||||
g_bSlayKnifer = cvar.BoolValue;
|
||||
HookConVarChange((cvar = CreateConVar("sm_kr_maxdistance", "200.0", "max distance from the zombie that got knifed forward where infected humans will be rezurrected")), g_cvMaxDistance);
|
||||
g_fMaxDistance = cvar.FloatValue;
|
||||
HookConVarChange((cvar = CreateConVar("sm_kr_time", "6.0", "max time until sm_kniferevert is available after a knife")), g_cvMaxTime);
|
||||
g_fMaxTime = cvar.FloatValue;
|
||||
delete cvar;
|
||||
@ -48,7 +47,7 @@ public void OnPluginStart()
|
||||
g_iClientIndexKnifedZombie = -1;
|
||||
}
|
||||
|
||||
public void g_cvZAbuse(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||
public void g_cvKnifeRevert(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||
{
|
||||
g_bKnifeRevert = convar.BoolValue;
|
||||
}
|
||||
@ -58,11 +57,6 @@ public void g_cvSlayKnifer(ConVar convar, const char[] oldValue, const char[] ne
|
||||
g_bSlayKnifer = convar.BoolValue;
|
||||
}
|
||||
|
||||
public void g_cvMaxDistance(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||
{
|
||||
g_fMaxDistance = convar.FloatValue;
|
||||
}
|
||||
|
||||
public void g_cvMaxTime(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||
{
|
||||
g_fMaxTime = convar.FloatValue;
|
||||
@ -70,7 +64,7 @@ public void g_cvMaxTime(ConVar convar, const char[] oldValue, const char[] newVa
|
||||
|
||||
public void OnPlayerHurt(Handle hEvent, const char[] name, bool dontBroadcast)
|
||||
{
|
||||
if(!g_bKnifeRevert)
|
||||
if(!g_bKnifeRevert || g_bKnife)
|
||||
return;
|
||||
|
||||
int attacker;
|
||||
@ -103,7 +97,7 @@ public void OnPlayerHurt(Handle hEvent, const char[] name, bool dontBroadcast)
|
||||
g_iClientIndexKnifedZombie = victim;
|
||||
g_bKnife = true;
|
||||
|
||||
CreateTimer(g_fMaxTime, OnClientKnife, _, TIMER_FLAG_NO_MAPCHANGE);
|
||||
KnifeRevertTimer = CreateTimer(g_fMaxTime, OnClientKnife, _, TIMER_FLAG_NO_MAPCHANGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -116,10 +110,8 @@ public Action OnClientKnife(Handle timer)
|
||||
|
||||
for(int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if(g_bInfectedInRadius[i])
|
||||
{
|
||||
g_bInfectedInRadius[i] = false;
|
||||
}
|
||||
if(g_bInfectedByKnifeForward[i])
|
||||
g_bInfectedByKnifeForward[i] = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,15 +120,11 @@ public void ZR_OnClientInfected(int client, int attacker, bool motherInfect, boo
|
||||
if(!g_bKnifeRevert || !g_bKnife)
|
||||
return;
|
||||
|
||||
static float fVec1[3];
|
||||
static float fVec2[3];
|
||||
GetClientAbsOrigin(g_iClientIndexKnifedZombie, fVec1);
|
||||
GetClientAbsOrigin(client, fVec2);
|
||||
if(g_iClientIndexKnifedZombie == attacker)//originally knifed forward zombies kills ppl
|
||||
g_bInfectedByKnifeForward[client] = true;
|
||||
|
||||
float fDistance = GetVectorDistance(fVec1, fVec2, false);
|
||||
|
||||
if(fDistance <= g_fMaxDistance)
|
||||
g_bInfectedInRadius[client] = true;
|
||||
if(g_bInfectedByKnifeForward[attacker])//follow the infection chain
|
||||
g_bInfectedByKnifeForward[client] = true;
|
||||
}
|
||||
|
||||
public Action Command_KnifeRevert(int client, int argc)
|
||||
@ -159,22 +147,39 @@ public Action Command_KnifeRevert(int client, int argc)
|
||||
|
||||
if(g_bSlayKnifer)
|
||||
{
|
||||
ForcePlayerSuicide(g_iClientIndexKnifer);
|
||||
PrintToChat(g_iClientIndexKnifer, "[SM] You got slayed for knifing a Zombie forward!");
|
||||
if(IsClientInGame(g_iClientIndexKnifer) && IsPlayerAlive(g_iClientIndexKnifer))
|
||||
{
|
||||
ForcePlayerSuicide(g_iClientIndexKnifer);
|
||||
PrintToChat(g_iClientIndexKnifer, "[SM] You got slayed for knifing a Zombie forward!");
|
||||
}
|
||||
}
|
||||
|
||||
int IdKnifedZombie = GetClientUserId(g_iClientIndexKnifedZombie);
|
||||
ServerCommand("zr_ztele_force #%d", IdKnifedZombie);
|
||||
PrintToChat(g_iClientIndexKnifedZombie, "[SM] You got teleported back because you were knifed forward.");
|
||||
if(IsClientInGame(g_iClientIndexKnifedZombie) && IsPlayerAlive(g_iClientIndexKnifedZombie))
|
||||
{
|
||||
int IdKnifedZombie = GetClientUserId(g_iClientIndexKnifedZombie);
|
||||
ServerCommand("zr_ztele_force #%d", IdKnifedZombie);
|
||||
PrintToChat(g_iClientIndexKnifedZombie, "[SM] You got teleported back because you were knifed forward.");
|
||||
}
|
||||
|
||||
for(int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if(IsClientInGame(i) && IsPlayerAlive(i) && g_bInfectedInRadius[i])
|
||||
if(IsClientInGame(i) && IsPlayerAlive(i) && g_bInfectedByKnifeForward[i])
|
||||
{
|
||||
ZR_HumanClient(i, false, false);
|
||||
PrintToChat(i, "[SM] You were rezurrected because you died after a Zombie was knifed forward.");
|
||||
}
|
||||
}
|
||||
|
||||
g_iClientIndexKnifer = -1;
|
||||
g_iClientIndexKnifedZombie = -1;
|
||||
g_bKnife = false;
|
||||
KillTimer(KnifeRevertTimer);
|
||||
|
||||
for(int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if(g_bInfectedByKnifeForward[i])
|
||||
g_bInfectedByKnifeForward[i] = false;
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
@ -147,7 +147,7 @@ public Action CheckRestart(Handle timer)
|
||||
int iPlayers = GetClientCount(false);
|
||||
for(int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if(IsClientConnected(i) && IsFakeClient(i))
|
||||
if(IsFakeClient(i))
|
||||
iPlayers--;
|
||||
}
|
||||
|
||||
@ -157,7 +157,7 @@ public Action CheckRestart(Handle timer)
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
if(!IsItRestartTime())
|
||||
if(!IsItRestartTime() || GetEngineTime() < 57500)
|
||||
return Plugin_Continue;
|
||||
|
||||
if(iPlayers > g_cvarMaxPlayersForControlledRestart.IntValue) //jenz's autism bot
|
||||
|
Loading…
Reference in New Issue
Block a user