ZSkills: initial delay for zcleanse

This commit is contained in:
dogan 2020-08-10 14:08:15 +02:00
parent 9a4b654ba8
commit 7ad3dd83bf

View File

@ -20,10 +20,12 @@ ConVar g_hCVar_ZCleanse_Enabled;
ConVar g_hCVar_ZCleanse_Duration;
ConVar g_hCVar_ZCleanse_Uses;
ConVar g_hCVar_ZCleanse_Cooldown;
ConVar g_hCVar_ZCleanse_Delay;
/* INTEGERS */
int g_bZCleanse_Uses[MAXPLAYERS+1];
int g_iLastZCleanse_Used[MAXPLAYERS+1];
int g_iLastInfection[MAXPLAYERS+1];
int g_iLastZAmmo_Used[MAXPLAYERS+1];
//----------------------------------------------------------------------------------------------------
@ -42,18 +44,19 @@ public Plugin myinfo =
//----------------------------------------------------------------------------------------------------
public void OnPluginStart()
{
g_hCVar_ZAmmo_Enabled = CreateConVar("zr_zammo_enabled", "1", "", FCVAR_NONE, true, 0.0, true, 1.0);
g_hCVar_ZAmmo_Duration = CreateConVar("zr_zammo_duration", "6", "", FCVAR_NONE, true, 1.0);
g_hCVar_ZAmmo_Cost = CreateConVar("zr_zammo_cost", "4500", "", FCVAR_NONE, true, 1.0);
g_hCVar_ZAmmo_Enabled = CreateConVar("zr_zammo_enabled", "1", "", FCVAR_NONE, true, 0.0, true, 1.0);
g_hCVar_ZAmmo_Duration = CreateConVar("zr_zammo_duration", "6", "", FCVAR_NONE, true, 1.0);
g_hCVar_ZAmmo_Cost = CreateConVar("zr_zammo_cost", "4500", "", FCVAR_NONE, true, 1.0);
g_hCVar_ZAmmo_Cooldown = CreateConVar("zr_zammo_cooldown", "8", "", FCVAR_NONE, true, 1.0);
g_bZAmmo_Enabled = g_hCVar_ZAmmo_Enabled.BoolValue;
g_bZAmmo_Enabled = g_hCVar_ZAmmo_Enabled.BoolValue;
g_hCVar_ZAmmo_Enabled.AddChangeHook(ConVarChanged);
g_hCVar_ZCleanse_Enabled = CreateConVar("zr_zcleanse_enabled", "1", "", FCVAR_NONE, true, 0.0, true, 1.0);
g_hCVar_ZCleanse_Duration = CreateConVar("zr_zcleanse_duration", "4", "", FCVAR_NONE, true, 1.0);
g_hCVar_ZCleanse_Uses = CreateConVar("zr_zcleanse_uses", "2", "", FCVAR_NONE, true, 1.0);
g_hCVar_ZCleanse_Cooldown = CreateConVar("zr_zcleanse_cooldown", "8", "", FCVAR_NONE, true, 1.0);
g_bZCleanse_Enabled = g_hCVar_ZCleanse_Enabled.BoolValue;
g_hCVar_ZCleanse_Enabled = CreateConVar("zr_zcleanse_enabled", "1", "", FCVAR_NONE, true, 0.0, true, 1.0);
g_hCVar_ZCleanse_Duration = CreateConVar("zr_zcleanse_duration", "4", "", FCVAR_NONE, true, 1.0);
g_hCVar_ZCleanse_Uses = CreateConVar("zr_zcleanse_uses", "2", "", FCVAR_NONE, true, 1.0);
g_hCVar_ZCleanse_Cooldown = CreateConVar("zr_zcleanse_cooldown", "8", "", FCVAR_NONE, true, 1.0);
g_hCVar_ZCleanse_Delay = CreateConVar("zr_zcleanse_delay", "4", "", FCVAR_NONE, true, 1.0);
g_bZCleanse_Enabled = g_hCVar_ZCleanse_Enabled.BoolValue;
g_hCVar_ZCleanse_Enabled.AddChangeHook(ConVarChanged);
HookEvent("weapon_fire", Event_WeaponFire);
@ -178,8 +181,15 @@ public Action Command_ZCleanse(int client, int args)
PrintToChat(client, "[ZCleanse] Already used (%d/%d) times this round.", g_bZCleanse_Uses[client], iMaxUses);
return Plugin_Handled;
}
int iTimeSinceLastInfection = GetTime() - g_iLastInfection[client];
int iCooldown = g_hCVar_ZCleanse_Delay.IntValue;
if (iTimeSinceLastInfection < iCooldown)
{
PrintToChat(client, "[ZCleanse] You need to wait another %d Seconds before you can use ZCleanse right after an infection.", iCooldown - iTimeSinceLastInfection);
return Plugin_Handled;
}
int iTimeSinceLastZCleanse = GetTime() - g_iLastZCleanse_Used[client];
int iCooldown = g_hCVar_ZCleanse_Cooldown.IntValue;
iCooldown = g_hCVar_ZCleanse_Cooldown.IntValue;
if (iTimeSinceLastZCleanse < iCooldown)
{
PrintToChat(client, "[ZCleanse] You need to wait another %d Seconds before you can use ZCleanse again.", iCooldown - iTimeSinceLastZCleanse);
@ -209,6 +219,7 @@ public void OnClientDisconnect(int client)
g_bZCleanse_Active[client] = false;
g_bZCleanse_Uses[client] = 0;
g_iLastZCleanse_Used[client] = 0;
g_iLastInfection[client] = 0;
g_iLastZAmmo_Used[client] = 0;
}
@ -223,6 +234,7 @@ public void Event_RoundStart(Handle hEvent, char[] name, bool dontBroadcast)
g_bZCleanse_Active[client] = false;
g_bZCleanse_Uses[client] = 0;
g_iLastZCleanse_Used[client] = 0;
g_iLastInfection[client] = 0;
g_iLastZAmmo_Used[client] = 0;
}
}
@ -281,6 +293,8 @@ public void Event_WeaponFire(Handle hEvent, char[] name, bool dontBroadcast)
//----------------------------------------------------------------------------------------------------
public void ZR_OnClientInfected(int client, int attacker, bool motherInfect, bool respawnOverride, bool respawn)
{
g_iLastInfection[client] = GetTime();
if (!g_bZAmmo_Active[client])
return;