Save recent infections via SteamID.
Change SteamID cache to AccountID. Fix error which broke shotgun knockback. Add roundend stats to console. Renamed some global variables to have g_ prefix
This commit is contained in:
parent
dd1ba186eb
commit
e7597639c2
@ -107,6 +107,7 @@
|
|||||||
#include "zr/api/api"
|
#include "zr/api/api"
|
||||||
|
|
||||||
new bool:g_bLate = false;
|
new bool:g_bLate = false;
|
||||||
|
new bool:g_bServerStarted = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Record plugin info.
|
* Record plugin info.
|
||||||
@ -155,7 +156,6 @@ public OnPluginStart()
|
|||||||
LogInit(); // Doesn't depend on CVARs.
|
LogInit(); // Doesn't depend on CVARs.
|
||||||
TranslationInit();
|
TranslationInit();
|
||||||
CvarsInit();
|
CvarsInit();
|
||||||
ToolsInit();
|
|
||||||
CookiesInit();
|
CookiesInit();
|
||||||
CommandsInit();
|
CommandsInit();
|
||||||
WeaponsInit();
|
WeaponsInit();
|
||||||
@ -194,6 +194,11 @@ public OnLibraryRemoved(const String:name[])
|
|||||||
*/
|
*/
|
||||||
public OnMapStart()
|
public OnMapStart()
|
||||||
{
|
{
|
||||||
|
if(!g_bServerStarted)
|
||||||
|
{
|
||||||
|
ToolsInit();
|
||||||
|
g_bServerStarted = true;
|
||||||
|
}
|
||||||
// Forward event to modules.
|
// Forward event to modules.
|
||||||
ClassOnMapStart();
|
ClassOnMapStart();
|
||||||
OverlaysOnMapStart();
|
OverlaysOnMapStart();
|
||||||
@ -384,3 +389,11 @@ public OnEntityCreated(entity, const String:classname[])
|
|||||||
{
|
{
|
||||||
NapalmOnEntityCreated(entity, classname);
|
NapalmOnEntityCreated(entity, classname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called before every server frame. Note that you should avoid
|
||||||
|
* doing expensive computations or declaring large local arrays.
|
||||||
|
*/
|
||||||
|
public void OnGameFrame()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
@ -69,7 +69,7 @@ DamageLoad()
|
|||||||
TrimString(arrayCmds[x]);
|
TrimString(arrayCmds[x]);
|
||||||
|
|
||||||
// Prepare intercept for this command.
|
// Prepare intercept for this command.
|
||||||
RegConsoleCmd(arrayCmds[x], DamageSuicideIntercept);
|
AddCommandListener(DamageSuicideIntercept, arrayCmds[x]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Important: If ZR can be unloaded some day, make sure to remove the listeners and set this to false.
|
// Important: If ZR can be unloaded some day, make sure to remove the listeners and set this to false.
|
||||||
@ -367,7 +367,7 @@ public Action:DamageOnTakeDamage(client, &attacker, &inflictor, &Float:damage, &
|
|||||||
* @param client The client index.
|
* @param client The client index.
|
||||||
* @param argc The number of arguments in command string.
|
* @param argc The number of arguments in command string.
|
||||||
*/
|
*/
|
||||||
public Action:DamageSuicideIntercept(client, argc)
|
public Action:DamageSuicideIntercept(int client, const char[] command, int argc)
|
||||||
{
|
{
|
||||||
// Get suicide interception settings.
|
// Get suicide interception settings.
|
||||||
new bool:suicideAfterInfect = GetConVarBool(g_hCvarsList[CVAR_SUICIDE_AFTER_INFECT]);
|
new bool:suicideAfterInfect = GetConVarBool(g_hCvarsList[CVAR_SUICIDE_AFTER_INFECT]);
|
||||||
|
@ -278,7 +278,7 @@ Action:ImmunityOnClientDamage(client, attacker, &Float:damage)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if spawn protection is on.
|
// Check if spawn protection is on.
|
||||||
if (bInfectImmune[client])
|
if (g_bInfectImmune[client])
|
||||||
{
|
{
|
||||||
// Block damage.
|
// Block damage.
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
|
@ -48,8 +48,8 @@
|
|||||||
/**
|
/**
|
||||||
* @section Global variables to store infect timer handles.
|
* @section Global variables to store infect timer handles.
|
||||||
*/
|
*/
|
||||||
new Handle:tInfect = INVALID_HANDLE;
|
new Handle:g_tInfect = INVALID_HANDLE;
|
||||||
new Handle:tInfectCountdown = INVALID_HANDLE;
|
new Handle:g_tInfectCountdown = INVALID_HANDLE;
|
||||||
/**
|
/**
|
||||||
* @endsection
|
* @endsection
|
||||||
*/
|
*/
|
||||||
@ -57,32 +57,27 @@ new Handle:tInfectCountdown = INVALID_HANDLE;
|
|||||||
/**
|
/**
|
||||||
* Infection countdown data pack.
|
* Infection countdown data pack.
|
||||||
*/
|
*/
|
||||||
new Handle:hInfectCountdownData = INVALID_HANDLE;
|
new Handle:g_hInfectCountdownData = INVALID_HANDLE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array for flagging client as zombie.
|
* Array for flagging client as zombie.
|
||||||
*/
|
*/
|
||||||
new bool:bZombie[MAXPLAYERS + 1];
|
new bool:g_bZombie[MAXPLAYERS + 1];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array for flagging client to be protected.
|
* Array for flagging client to be protected.
|
||||||
*/
|
*/
|
||||||
new bool:bInfectImmune[MAXPLAYERS + 1];
|
new bool:g_bInfectImmune[MAXPLAYERS + 1];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Available mother zombie infection status.
|
* Array for storing client mother zombie last flag.
|
||||||
*/
|
*/
|
||||||
enum InfectMotherStatus
|
new bool:g_bInfectMotherLast[MAXPLAYERS + 1];
|
||||||
{
|
|
||||||
MotherStatus_None = 0,
|
|
||||||
MotherStatus_Chosen = 1,
|
|
||||||
MotherStatus_Last = 2
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array for storing client mother zombie protection status.
|
* SteamID cache for storing client mother zombie protection status.
|
||||||
*/
|
*/
|
||||||
new InfectMotherStatus:g_InfectMotherStatus[MAXPLAYERS + 1];
|
new Handle:g_hInfectMotherCycle = INVALID_HANDLE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Available mother zombie infection modes.
|
* Available mother zombie infection modes.
|
||||||
@ -102,9 +97,12 @@ InfectOnMapEnd()
|
|||||||
{
|
{
|
||||||
// Reset timers. Infect timers are invalidated on a map change if they are
|
// Reset timers. Infect timers are invalidated on a map change if they are
|
||||||
// still running.
|
// still running.
|
||||||
ZREndTimer(tInfect);
|
ZREndTimer(g_tInfect);
|
||||||
ZREndTimer(tInfectCountdown);
|
ZREndTimer(g_tInfectCountdown);
|
||||||
InfectStopCountdown();
|
InfectStopCountdown();
|
||||||
|
|
||||||
|
// Clear mother zombie round-robin cycle storage.
|
||||||
|
SteamidCacheReset(g_hInfectMotherCycle);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -127,6 +125,9 @@ InfectLoad()
|
|||||||
|
|
||||||
// Add sound file to downloads table.
|
// Add sound file to downloads table.
|
||||||
AddFileToDownloadsTable(sound);
|
AddFileToDownloadsTable(sound);
|
||||||
|
|
||||||
|
// Create mother zombie round-robin cycle storage.
|
||||||
|
g_hInfectMotherCycle = SteamidCacheCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -146,10 +147,10 @@ InfectOnCommandsCreate()
|
|||||||
InfectClientInit(client)
|
InfectClientInit(client)
|
||||||
{
|
{
|
||||||
// Reset infect immunity flag.
|
// Reset infect immunity flag.
|
||||||
bInfectImmune[client] = false;
|
g_bInfectImmune[client] = false;
|
||||||
|
|
||||||
// Reset mother zombie protection.
|
// Reset mother zombie last flag.
|
||||||
g_InfectMotherStatus[client] = MotherStatus_None;
|
g_bInfectMotherLast[client] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -264,7 +265,7 @@ InfectOnClientTeam(client, team)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Disable zombie flag on client.
|
// Disable zombie flag on client.
|
||||||
bZombie[client] = false;
|
g_bZombie[client] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -275,7 +276,7 @@ InfectOnClientTeam(client, team)
|
|||||||
InfectOnClientSpawn(client)
|
InfectOnClientSpawn(client)
|
||||||
{
|
{
|
||||||
// Disable zombie flag on client.
|
// Disable zombie flag on client.
|
||||||
bZombie[client] = false;
|
g_bZombie[client] = false;
|
||||||
|
|
||||||
// Check if client is spawning on the terrorist team.
|
// Check if client is spawning on the terrorist team.
|
||||||
if (ZRIsClientOnTeam(client, CS_TEAM_T) && InfectHasZombieSpawned())
|
if (ZRIsClientOnTeam(client, CS_TEAM_T) && InfectHasZombieSpawned())
|
||||||
@ -347,7 +348,7 @@ InfectOnClientHurt(client, attacker, const String:weapon[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If client has infect immunity, then stop.
|
// If client has infect immunity, then stop.
|
||||||
if (bInfectImmune[client])
|
if (g_bInfectImmune[client])
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -375,8 +376,8 @@ InfectOnClientHurt(client, attacker, const String:weapon[])
|
|||||||
InfectOnRoundStart()
|
InfectOnRoundStart()
|
||||||
{
|
{
|
||||||
// Stop infect timers if running.
|
// Stop infect timers if running.
|
||||||
ZREndTimer(tInfect);
|
ZREndTimer(g_tInfect);
|
||||||
ZREndTimer(tInfectCountdown);
|
ZREndTimer(g_tInfectCountdown);
|
||||||
|
|
||||||
// Tell plugin there are no zombies.
|
// Tell plugin there are no zombies.
|
||||||
g_bZombieSpawned = false;
|
g_bZombieSpawned = false;
|
||||||
@ -388,8 +389,8 @@ InfectOnRoundStart()
|
|||||||
InfectOnRoundFreezeEnd()
|
InfectOnRoundFreezeEnd()
|
||||||
{
|
{
|
||||||
// Stop infect timers if running.
|
// Stop infect timers if running.
|
||||||
ZREndTimer(tInfect);
|
ZREndTimer(g_tInfect);
|
||||||
ZREndTimer(tInfectCountdown);
|
ZREndTimer(g_tInfectCountdown);
|
||||||
|
|
||||||
// If the zombie has spawned already (had to be through admin) then stop.
|
// If the zombie has spawned already (had to be through admin) then stop.
|
||||||
if (InfectHasZombieSpawned())
|
if (InfectHasZombieSpawned())
|
||||||
@ -404,10 +405,7 @@ InfectOnRoundFreezeEnd()
|
|||||||
// Pick random time between min and max.
|
// Pick random time between min and max.
|
||||||
new Float:randomtime = GetRandomFloat(infectspawntimemin, infectspawntimemax);
|
new Float:randomtime = GetRandomFloat(infectspawntimemin, infectspawntimemax);
|
||||||
|
|
||||||
// Round to the nearest whole number (and convert back to a float) so the countdown is synched with it.
|
g_tInfect = CreateTimer(randomtime, InfectMotherZombie, _, TIMER_FLAG_NO_MAPCHANGE);
|
||||||
float(RoundToNearest(randomtime));
|
|
||||||
|
|
||||||
tInfect = CreateTimer(randomtime, InfectMotherZombie, _, TIMER_FLAG_NO_MAPCHANGE);
|
|
||||||
|
|
||||||
// Check cvar and start a countdown timer if enabled.
|
// Check cvar and start a countdown timer if enabled.
|
||||||
new bool:countdown = GetConVarBool(g_hCvarsList[CVAR_INFECT_MZOMBIE_COUNTDOWN]);
|
new bool:countdown = GetConVarBool(g_hCvarsList[CVAR_INFECT_MZOMBIE_COUNTDOWN]);
|
||||||
@ -417,13 +415,13 @@ InfectOnRoundFreezeEnd()
|
|||||||
InfectStopCountdown();
|
InfectStopCountdown();
|
||||||
|
|
||||||
// Store the time until infection, and initialize the counter.
|
// Store the time until infection, and initialize the counter.
|
||||||
hInfectCountdownData = CreateDataPack();
|
g_hInfectCountdownData = CreateDataPack();
|
||||||
WritePackFloat(hInfectCountdownData, randomtime);
|
WritePackFloat(g_hInfectCountdownData, randomtime);
|
||||||
WritePackFloat(hInfectCountdownData, 0.0);
|
WritePackFloat(g_hInfectCountdownData, 0.0);
|
||||||
tInfectCountdown = CreateTimer(1.0, InfectCountdown, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
|
g_tInfectCountdown = CreateTimer(1.0, InfectCountdown, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
|
||||||
|
|
||||||
// Display initial tick.
|
// Display initial tick.
|
||||||
InfectCountdown(tInfectCountdown);
|
InfectCountdown(g_tInfectCountdown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -433,14 +431,14 @@ InfectOnRoundFreezeEnd()
|
|||||||
InfectOnRoundEnd()
|
InfectOnRoundEnd()
|
||||||
{
|
{
|
||||||
// Stop infect timers if running.
|
// Stop infect timers if running.
|
||||||
ZREndTimer(tInfect);
|
ZREndTimer(g_tInfect);
|
||||||
ZREndTimer(tInfectCountdown);
|
ZREndTimer(g_tInfectCountdown);
|
||||||
|
|
||||||
// x = client index.
|
// x = client index.
|
||||||
for (new x = 1; x <= MaxClients; x++)
|
for (new x = 1; x <= MaxClients; x++)
|
||||||
{
|
{
|
||||||
// Disable zombie flag on client.
|
// Disable zombie flag on client.
|
||||||
bZombie[x] = false;
|
g_bZombie[x] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -452,7 +450,7 @@ InfectOnRoundEnd()
|
|||||||
public Action:InfectMotherZombie(Handle:timer)
|
public Action:InfectMotherZombie(Handle:timer)
|
||||||
{
|
{
|
||||||
// Reset timer handle.
|
// Reset timer handle.
|
||||||
tInfect = INVALID_HANDLE;
|
g_tInfect = INVALID_HANDLE;
|
||||||
|
|
||||||
// Create eligible player list.
|
// Create eligible player list.
|
||||||
new Handle:arrayEligibleClients = INVALID_HANDLE;
|
new Handle:arrayEligibleClients = INVALID_HANDLE;
|
||||||
@ -546,7 +544,7 @@ public Action:InfectMotherZombie(Handle:timer)
|
|||||||
new client = GetArrayCell(arrayEligibleClients, n);
|
new client = GetArrayCell(arrayEligibleClients, n);
|
||||||
|
|
||||||
// If client hasn't been chosen this cycle, put into aCandidates array.
|
// If client hasn't been chosen this cycle, put into aCandidates array.
|
||||||
if (g_InfectMotherStatus[client] == MotherStatus_None)
|
if (!SteamidCacheClientExists(g_hInfectMotherCycle, client))
|
||||||
{
|
{
|
||||||
PushArrayCell(aCandidates, client);
|
PushArrayCell(aCandidates, client);
|
||||||
candidates++;
|
candidates++;
|
||||||
@ -563,7 +561,7 @@ public Action:InfectMotherZombie(Handle:timer)
|
|||||||
|
|
||||||
// If client hasn't been chosen last round, put into aCandidates array,
|
// If client hasn't been chosen last round, put into aCandidates array,
|
||||||
// but only until we have enough candidates.
|
// but only until we have enough candidates.
|
||||||
if (!(g_InfectMotherStatus[client] & MotherStatus_Last))
|
if (!g_bInfectMotherLast[client])
|
||||||
{
|
{
|
||||||
PushArrayCell(aCandidates, client);
|
PushArrayCell(aCandidates, client);
|
||||||
candidates++;
|
candidates++;
|
||||||
@ -575,20 +573,17 @@ public Action:InfectMotherZombie(Handle:timer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Restart the cycle.
|
// Restart the cycle.
|
||||||
// Reset all players MotherStatus.
|
// Clear mother zombie round-robin cycle storage.
|
||||||
for (int client = 0; client <= MAXPLAYERS; client++)
|
SteamidCacheReset(g_hInfectMotherCycle);
|
||||||
{
|
|
||||||
g_InfectMotherStatus[client] = MotherStatus_None;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Announce start of new cycle
|
// Announce start of new cycle
|
||||||
TranslationPrintToChatAll(true, false, "Mother zombie infect cycle reset");
|
TranslationPrintToChatAll(true, false, "Mother zombie infect cycle reset");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove MotherStatus_Last flag from all players.
|
// Remove mother zombie last flag from all players.
|
||||||
for (int client = 0; client <= MAXPLAYERS; client++)
|
for (int client = 0; client <= MAXPLAYERS; client++)
|
||||||
{
|
{
|
||||||
g_InfectMotherStatus[client] &= ~MotherStatus_Last;
|
g_bInfectMotherLast[client] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Infect players.
|
// Infect players.
|
||||||
@ -662,9 +657,9 @@ public Action:InfectCountdown(Handle:timer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read the info from the datapack.
|
// Read the info from the datapack.
|
||||||
ResetPack(hInfectCountdownData);
|
ResetPack(g_hInfectCountdownData);
|
||||||
new Float:length = ReadPackFloat(hInfectCountdownData);
|
new Float:length = ReadPackFloat(g_hInfectCountdownData);
|
||||||
new Float:counter = ReadPackFloat(hInfectCountdownData);
|
new Float:counter = ReadPackFloat(g_hInfectCountdownData);
|
||||||
|
|
||||||
// Check if the countdown has finished.
|
// Check if the countdown has finished.
|
||||||
if (counter >= length)
|
if (counter >= length)
|
||||||
@ -679,9 +674,9 @@ public Action:InfectCountdown(Handle:timer)
|
|||||||
counter++;
|
counter++;
|
||||||
|
|
||||||
// Write the new counter value to the datapack.
|
// Write the new counter value to the datapack.
|
||||||
ResetPack(hInfectCountdownData);
|
ResetPack(g_hInfectCountdownData);
|
||||||
WritePackFloat(hInfectCountdownData, length);
|
WritePackFloat(g_hInfectCountdownData, length);
|
||||||
WritePackFloat(hInfectCountdownData, counter);
|
WritePackFloat(g_hInfectCountdownData, counter);
|
||||||
|
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
@ -692,13 +687,13 @@ public Action:InfectCountdown(Handle:timer)
|
|||||||
InfectStopCountdown()
|
InfectStopCountdown()
|
||||||
{
|
{
|
||||||
// Kill the timer.
|
// Kill the timer.
|
||||||
ZREndTimer(tInfectCountdown);
|
ZREndTimer(g_tInfectCountdown);
|
||||||
|
|
||||||
// Destroy data pack.
|
// Destroy data pack.
|
||||||
if (hInfectCountdownData != INVALID_HANDLE)
|
if (g_hInfectCountdownData != INVALID_HANDLE)
|
||||||
{
|
{
|
||||||
CloseHandle(hInfectCountdownData);
|
CloseHandle(g_hInfectCountdownData);
|
||||||
hInfectCountdownData = INVALID_HANDLE;
|
g_hInfectCountdownData = INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -724,7 +719,7 @@ InfectHumanToZombie(client, attacker = -1, bool:motherinfect = false, bool:respa
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mark player as zombie.
|
// Mark player as zombie.
|
||||||
bZombie[client] = true;
|
g_bZombie[client] = true;
|
||||||
|
|
||||||
// Check if consecutive infection protection is enabled.
|
// Check if consecutive infection protection is enabled.
|
||||||
new bool:infectconsecutiveblock = GetConVarBool(g_hCvarsList[CVAR_INFECT_CONSECUTIVE_BLOCK]);
|
new bool:infectconsecutiveblock = GetConVarBool(g_hCvarsList[CVAR_INFECT_CONSECUTIVE_BLOCK]);
|
||||||
@ -733,13 +728,14 @@ InfectHumanToZombie(client, attacker = -1, bool:motherinfect = false, bool:respa
|
|||||||
// If this is a mother infect, update the mother zombie protection status
|
// If this is a mother infect, update the mother zombie protection status
|
||||||
if (motherinfect)
|
if (motherinfect)
|
||||||
{
|
{
|
||||||
g_InfectMotherStatus[client] = MotherStatus_Chosen | MotherStatus_Last;
|
g_bInfectMotherLast[client] = true;
|
||||||
|
SteamidCacheAddClient(g_hInfectMotherCycle, client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Consecutive infection protection is disabled. No immunity.
|
// Consecutive infection protection is disabled. No immunity.
|
||||||
g_InfectMotherStatus[client] = MotherStatus_None;
|
g_bInfectMotherLast[client] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply effects.
|
// Apply effects.
|
||||||
@ -837,7 +833,7 @@ InfectZombieToHuman(client, bool:respawn = false, bool:protect = false)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mark player as human.
|
// Mark player as human.
|
||||||
bZombie[client] = false;
|
g_bZombie[client] = false;
|
||||||
|
|
||||||
// Switch the player to counter-terrorists.
|
// Switch the player to counter-terrorists.
|
||||||
CS_SwitchTeam(client, CS_TEAM_CT);
|
CS_SwitchTeam(client, CS_TEAM_CT);
|
||||||
@ -1115,7 +1111,7 @@ bool:InfectIsClientInfected(client)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return client's zombie flag.
|
// Return client's zombie flag.
|
||||||
return bZombie[client];
|
return g_bZombie[client];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1133,7 +1129,7 @@ bool:InfectIsClientHuman(client)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Return opposite of client's zombie flag.
|
// Return opposite of client's zombie flag.
|
||||||
return !bZombie[client];
|
return !g_bZombie[client];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1153,10 +1149,10 @@ stock InfectManualInfect(client, targets[], count, bool:respawnoverride = false,
|
|||||||
if (!zombiespawned)
|
if (!zombiespawned)
|
||||||
{
|
{
|
||||||
// Stop mother infect timer.
|
// Stop mother infect timer.
|
||||||
if (tInfect != INVALID_HANDLE)
|
if (g_tInfect != INVALID_HANDLE)
|
||||||
{
|
{
|
||||||
KillTimer(tInfect);
|
KillTimer(g_tInfect);
|
||||||
tInfect = INVALID_HANDLE;
|
g_tInfect = INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move all clients to CT
|
// Move all clients to CT
|
||||||
|
@ -73,6 +73,10 @@ RespawnOnClientSpawn(client)
|
|||||||
|
|
||||||
// Reset timer handle.
|
// Reset timer handle.
|
||||||
tRespawn[client] = INVALID_HANDLE;
|
tRespawn[client] = INVALID_HANDLE;
|
||||||
|
|
||||||
|
// Reset player velocity
|
||||||
|
float fResetVelocity[3] = {0.0, 0.0, 0.0};
|
||||||
|
ToolsClientVelocity(client, fResetVelocity, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -184,10 +188,6 @@ bool:RespawnSpawnClient(client, bool:zombie = false, bool:zombieIfSuicide = fals
|
|||||||
// Spawn player.
|
// Spawn player.
|
||||||
CS_RespawnPlayer(client);
|
CS_RespawnPlayer(client);
|
||||||
|
|
||||||
// Reset player velocity
|
|
||||||
float fResetVelocity[3] = {0.0, 0.0, 0.0};
|
|
||||||
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, fResetVelocity);
|
|
||||||
|
|
||||||
// Check if first zombie has spawned.
|
// Check if first zombie has spawned.
|
||||||
if (InfectHasZombieSpawned())
|
if (InfectHasZombieSpawned())
|
||||||
{
|
{
|
||||||
|
@ -67,7 +67,7 @@ enum RoundEndOutcome
|
|||||||
/**
|
/**
|
||||||
* Global variable to store round win timer handle.
|
* Global variable to store round win timer handle.
|
||||||
*/
|
*/
|
||||||
new Handle:tRoundEnd = INVALID_HANDLE;
|
new Handle:g_tRoundEnd = INVALID_HANDLE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map is starting.
|
* Map is starting.
|
||||||
@ -75,7 +75,7 @@ new Handle:tRoundEnd = INVALID_HANDLE;
|
|||||||
RoundEndOnMapStart()
|
RoundEndOnMapStart()
|
||||||
{
|
{
|
||||||
// Reset timer handle.
|
// Reset timer handle.
|
||||||
tRoundEnd = INVALID_HANDLE;
|
g_tRoundEnd = INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,13 +113,13 @@ RoundEndOnRoundStart()
|
|||||||
RoundEndOverlayStop();
|
RoundEndOverlayStop();
|
||||||
|
|
||||||
// If round end timer is running, then kill it.
|
// If round end timer is running, then kill it.
|
||||||
if (tRoundEnd != INVALID_HANDLE)
|
if (g_tRoundEnd != INVALID_HANDLE)
|
||||||
{
|
{
|
||||||
// Kill timer.
|
// Kill timer.
|
||||||
KillTimer(tRoundEnd);
|
KillTimer(g_tRoundEnd);
|
||||||
|
|
||||||
// Reset timer handle.
|
// Reset timer handle.
|
||||||
tRoundEnd = INVALID_HANDLE;
|
g_tRoundEnd = INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ RoundEndOnRoundFreezeEnd()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start timer.
|
// Start timer.
|
||||||
tRoundEnd = CreateTimer(roundtime, RoundEndTimer, _, TIMER_FLAG_NO_MAPCHANGE);
|
g_tRoundEnd = CreateTimer(roundtime, RoundEndTimer, _, TIMER_FLAG_NO_MAPCHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -155,13 +155,13 @@ RoundEndOnRoundFreezeEnd()
|
|||||||
RoundEndOnRoundEnd(reason)
|
RoundEndOnRoundEnd(reason)
|
||||||
{
|
{
|
||||||
// If round end timer is running, then kill it.
|
// If round end timer is running, then kill it.
|
||||||
if (tRoundEnd != INVALID_HANDLE)
|
if (g_tRoundEnd != INVALID_HANDLE)
|
||||||
{
|
{
|
||||||
// Kill timer.
|
// Kill timer.
|
||||||
KillTimer(tRoundEnd);
|
KillTimer(g_tRoundEnd);
|
||||||
|
|
||||||
// Reset timer handle.
|
// Reset timer handle.
|
||||||
tRoundEnd = INVALID_HANDLE;
|
g_tRoundEnd = INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tell plugin no zombies have been spawned.
|
// Tell plugin no zombies have been spawned.
|
||||||
@ -193,6 +193,8 @@ RoundEndOnRoundEnd(reason)
|
|||||||
// Display the overlay to all clients.
|
// Display the overlay to all clients.
|
||||||
RoundEndOverlayStart(outcome);
|
RoundEndOverlayStart(outcome);
|
||||||
|
|
||||||
|
RoundEndDisplayStats();
|
||||||
|
|
||||||
// Balance teams if enabled.
|
// Balance teams if enabled.
|
||||||
if (GetConVarBool(g_hCvarsList[CVAR_ROUNDEND_BALANCE_TEAMS]))
|
if (GetConVarBool(g_hCvarsList[CVAR_ROUNDEND_BALANCE_TEAMS]))
|
||||||
{
|
{
|
||||||
@ -200,6 +202,46 @@ RoundEndOnRoundEnd(reason)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RoundEndDisplayStats()
|
||||||
|
{
|
||||||
|
for(int player = 1; player <= MaxClients; player++)
|
||||||
|
{
|
||||||
|
if(!IsClientInGame(player))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
static char sPlayerID[8];
|
||||||
|
static char sPlayerName[MAX_NAME_LENGTH + 2];
|
||||||
|
static char sPlayerAuth[24];
|
||||||
|
static char sPlayerTeam[8];
|
||||||
|
static char sPlayerState[8];
|
||||||
|
|
||||||
|
FormatEx(sPlayerID, sizeof(sPlayerID), "%d", GetClientUserId(player));
|
||||||
|
FormatEx(sPlayerName, sizeof(sPlayerName), "\"%N\"", player);
|
||||||
|
|
||||||
|
if(!GetClientAuthId(player, AuthId_Steam2, sPlayerAuth, sizeof(sPlayerAuth)))
|
||||||
|
FormatEx(sPlayerAuth, sizeof(sPlayerAuth), "STEAM_ID_PENDING");
|
||||||
|
|
||||||
|
if(IsPlayerAlive(player))
|
||||||
|
FormatEx(sPlayerState, sizeof(sPlayerState), "alive");
|
||||||
|
else
|
||||||
|
FormatEx(sPlayerState, sizeof(sPlayerState), "dead");
|
||||||
|
|
||||||
|
if(InfectIsClientInfected(player))
|
||||||
|
FormatEx(sPlayerTeam, sizeof(sPlayerTeam), "zombie");
|
||||||
|
else
|
||||||
|
FormatEx(sPlayerTeam, sizeof(sPlayerTeam), "human");
|
||||||
|
|
||||||
|
for(int client = 1; client <= MaxClients; client++)
|
||||||
|
{
|
||||||
|
if(!IsClientInGame(client))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
PrintToConsole(client, "# %8s %40s %24s %5s %6s",
|
||||||
|
sPlayerID, sPlayerName, sPlayerAuth, sPlayerState, sPlayerTeam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a round_end reason, to a round winner, or draw.
|
* Convert a round_end reason, to a round winner, or draw.
|
||||||
*
|
*
|
||||||
@ -239,7 +281,7 @@ RoundEndOutcome:RoundEndReasonToOutcome(reason)
|
|||||||
public Action:RoundEndTimer(Handle:timer)
|
public Action:RoundEndTimer(Handle:timer)
|
||||||
{
|
{
|
||||||
// Set the global timer handle variable to INVALID_HANDLE.
|
// Set the global timer handle variable to INVALID_HANDLE.
|
||||||
tRoundEnd = INVALID_HANDLE;
|
g_tRoundEnd = INVALID_HANDLE;
|
||||||
|
|
||||||
// If there aren't clients on both teams, then stop.
|
// If there aren't clients on both teams, then stop.
|
||||||
if (!ZRTeamHasClients())
|
if (!ZRTeamHasClients())
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
/**
|
/**
|
||||||
* Array for storing spawn protect timer handles per client.
|
* Array for storing spawn protect timer handles per client.
|
||||||
*/
|
*/
|
||||||
new Handle:tSpawnProtect[MAXPLAYERS + 1];
|
new Handle:g_tSpawnProtect[MAXPLAYERS + 1];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Array for storing time left for spawn protection per client.
|
* Array for storing time left for spawn protection per client.
|
||||||
@ -43,7 +43,7 @@ new pSpawnProtectTime[MAXPLAYERS + 1];
|
|||||||
SpawnProtectClientInit(client)
|
SpawnProtectClientInit(client)
|
||||||
{
|
{
|
||||||
// Reset timer handle.
|
// Reset timer handle.
|
||||||
tSpawnProtect[client] = INVALID_HANDLE;
|
g_tSpawnProtect[client] = INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,13 +60,13 @@ SpawnProtectOnClientSpawnPost(client)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If timer is currently running, kill it.
|
// If timer is currently running, kill it.
|
||||||
if (tSpawnProtect[client] != INVALID_HANDLE)
|
if (g_tSpawnProtect[client] != INVALID_HANDLE)
|
||||||
{
|
{
|
||||||
KillTimer(tSpawnProtect[client]);
|
KillTimer(g_tSpawnProtect[client]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset timer handle.
|
// Reset timer handle.
|
||||||
tSpawnProtect[client] = INVALID_HANDLE;
|
g_tSpawnProtect[client] = INVALID_HANDLE;
|
||||||
|
|
||||||
// If protect cvar is disabled, then stop.
|
// If protect cvar is disabled, then stop.
|
||||||
new bool:protect = GetConVarBool(g_hCvarsList[CVAR_SPAWNPROTECT]);
|
new bool:protect = GetConVarBool(g_hCvarsList[CVAR_SPAWNPROTECT]);
|
||||||
@ -76,7 +76,7 @@ SpawnProtectOnClientSpawnPost(client)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Disable spawn protection on client.
|
// Disable spawn protection on client.
|
||||||
bInfectImmune[client] = false;
|
g_bInfectImmune[client] = false;
|
||||||
|
|
||||||
// Start spawn protection.
|
// Start spawn protection.
|
||||||
SpawnProtectStart(client);
|
SpawnProtectStart(client);
|
||||||
@ -90,13 +90,13 @@ SpawnProtectOnClientSpawnPost(client)
|
|||||||
SpawnProtectOnClientDeath(client)
|
SpawnProtectOnClientDeath(client)
|
||||||
{
|
{
|
||||||
// If timer is running, kill it.
|
// If timer is running, kill it.
|
||||||
if (tSpawnProtect[client] != INVALID_HANDLE)
|
if (g_tSpawnProtect[client] != INVALID_HANDLE)
|
||||||
{
|
{
|
||||||
KillTimer(tSpawnProtect[client]);
|
KillTimer(g_tSpawnProtect[client]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset timer handle.
|
// Reset timer handle.
|
||||||
tSpawnProtect[client] = INVALID_HANDLE;
|
g_tSpawnProtect[client] = INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -158,7 +158,7 @@ SpawnProtectStart(client)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set spawn protect flag on client.
|
// Set spawn protect flag on client.
|
||||||
bInfectImmune[client] = true;
|
g_bInfectImmune[client] = true;
|
||||||
|
|
||||||
// Set spawn protect attributes.
|
// Set spawn protect attributes.
|
||||||
ClassApplySpeedEx(client, speed);
|
ClassApplySpeedEx(client, speed);
|
||||||
@ -175,7 +175,7 @@ SpawnProtectStart(client)
|
|||||||
TranslationPrintHintText(client, "Spawn Protect", pSpawnProtectTime[client]);
|
TranslationPrintHintText(client, "Spawn Protect", pSpawnProtectTime[client]);
|
||||||
|
|
||||||
// Start repeating timer.
|
// Start repeating timer.
|
||||||
tSpawnProtect[client] = CreateTimer(1.0, SpawnProtectTimer, client, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT);
|
g_tSpawnProtect[client] = CreateTimer(1.0, SpawnProtectTimer, client, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -190,7 +190,7 @@ public Action:SpawnProtectTimer(Handle:timer, any:client)
|
|||||||
if (!IsClientInGame(client))
|
if (!IsClientInGame(client))
|
||||||
{
|
{
|
||||||
// Reset timer handle.
|
// Reset timer handle.
|
||||||
tSpawnProtect[client] = INVALID_HANDLE;
|
g_tSpawnProtect[client] = INVALID_HANDLE;
|
||||||
return Plugin_Stop;
|
return Plugin_Stop;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ public Action:SpawnProtectTimer(Handle:timer, any:client)
|
|||||||
if (!InfectIsClientHuman(client))
|
if (!InfectIsClientHuman(client))
|
||||||
{
|
{
|
||||||
// Reset timer handle.
|
// Reset timer handle.
|
||||||
tSpawnProtect[client] = INVALID_HANDLE;
|
g_tSpawnProtect[client] = INVALID_HANDLE;
|
||||||
return Plugin_Stop;
|
return Plugin_Stop;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,7 +212,7 @@ public Action:SpawnProtectTimer(Handle:timer, any:client)
|
|||||||
if (pSpawnProtectTime[client] <= 0)
|
if (pSpawnProtectTime[client] <= 0)
|
||||||
{
|
{
|
||||||
// Remove protect flag.
|
// Remove protect flag.
|
||||||
bInfectImmune[client] = false;
|
g_bInfectImmune[client] = false;
|
||||||
|
|
||||||
// Tell client spawn protection is over.
|
// Tell client spawn protection is over.
|
||||||
TranslationPrintHintText(client, "Spawn protection end");
|
TranslationPrintHintText(client, "Spawn protection end");
|
||||||
@ -222,7 +222,7 @@ public Action:SpawnProtectTimer(Handle:timer, any:client)
|
|||||||
ClassApplySpeedEx(client, ClassGetSpeed(client));
|
ClassApplySpeedEx(client, ClassGetSpeed(client));
|
||||||
|
|
||||||
// Clear timer handle.
|
// Clear timer handle.
|
||||||
tSpawnProtect[client] = INVALID_HANDLE;
|
g_tSpawnProtect[client] = INVALID_HANDLE;
|
||||||
|
|
||||||
// Stop timer.
|
// Stop timer.
|
||||||
return Plugin_Stop;
|
return Plugin_Stop;
|
||||||
|
@ -25,11 +25,6 @@
|
|||||||
* ============================================================================
|
* ============================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* The maximum length of a SteamID
|
|
||||||
*/
|
|
||||||
#define STEAMIDCACHE_MAX_LENGTH 16
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a steamid cache.
|
* Creates a steamid cache.
|
||||||
*
|
*
|
||||||
@ -38,7 +33,7 @@
|
|||||||
stock Handle:SteamidCacheCreate()
|
stock Handle:SteamidCacheCreate()
|
||||||
{
|
{
|
||||||
// Return steamid cache handle.
|
// Return steamid cache handle.
|
||||||
return CreateArray(STEAMIDCACHE_MAX_LENGTH);
|
return CreateArray(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,11 +52,12 @@ stock bool:SteamidCacheAddClient(Handle:steamidcache, client)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get client's SteamID.
|
// Get client's SteamID.
|
||||||
new String:steamid[STEAMIDCACHE_MAX_LENGTH];
|
new steamid = GetSteamAccountID(client);
|
||||||
GetClientAuthId(client, AuthId_SteamID64, steamid, sizeof(steamid), true);
|
if (!steamid)
|
||||||
|
return false;
|
||||||
|
|
||||||
// Push SteamID into the SteamID cache.
|
// Push SteamID into the SteamID cache.
|
||||||
PushArrayString(steamidcache, steamid);
|
PushArrayCell(steamidcache, steamid);
|
||||||
|
|
||||||
// Client added successfully.
|
// Client added successfully.
|
||||||
return true;
|
return true;
|
||||||
@ -77,11 +73,12 @@ stock bool:SteamidCacheAddClient(Handle:steamidcache, client)
|
|||||||
stock bool:SteamidCacheClientExists(Handle:steamidcache, client)
|
stock bool:SteamidCacheClientExists(Handle:steamidcache, client)
|
||||||
{
|
{
|
||||||
// Get client's SteamID.
|
// Get client's SteamID.
|
||||||
decl String:steamid[STEAMIDCACHE_MAX_LENGTH];
|
new steamid = GetSteamAccountID(client);
|
||||||
GetClientAuthId(client, AuthId_SteamID64, steamid, sizeof(steamid), true);
|
if (!steamid)
|
||||||
|
return false;
|
||||||
|
|
||||||
// Return true if client was found, false otherwise.
|
// Return true if client was found, false otherwise.
|
||||||
return (FindStringInArray(steamidcache, steamid) != -1);
|
return (FindValueInArray(steamidcache, steamid) != -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,11 +55,11 @@ ToolsInit()
|
|||||||
*/
|
*/
|
||||||
ToolsFindOffsets()
|
ToolsFindOffsets()
|
||||||
{
|
{
|
||||||
// If offset "m_vecVelocity[0]" can't be found, then stop the plugin.
|
// If offset "m_vecAbsVelocity" can't be found, then stop the plugin.
|
||||||
g_iToolsVelocity = FindSendPropInfo("CBasePlayer", "m_vecVelocity[0]");
|
g_iToolsVelocity = FindDataMapInfo(0, "m_vecAbsVelocity");
|
||||||
if (g_iToolsVelocity == -1)
|
if (g_iToolsVelocity == -1)
|
||||||
{
|
{
|
||||||
LogEvent(false, LogType_Fatal, LOG_CORE_EVENTS, LogModule_Tools, "Offsets", "Offset \"CBasePlayer::m_vecVelocity[0]\" was not found.");
|
LogEvent(false, LogType_Fatal, LOG_CORE_EVENTS, LogModule_Tools, "Offsets", "Offset \"CBaseEntity::m_vecAbsVelocity\" was not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// If offset "m_flLaggedMovementValue" can't be found, then stop the plugin.
|
// If offset "m_flLaggedMovementValue" can't be found, then stop the plugin.
|
||||||
@ -90,7 +90,6 @@ ToolsFindOffsets()
|
|||||||
LogEvent(false, LogType_Fatal, LOG_CORE_EVENTS, LogModule_Tools, "Offsets", "Offset \"CBasePlayer::m_iFOV\" was not found.");
|
LogEvent(false, LogType_Fatal, LOG_CORE_EVENTS, LogModule_Tools, "Offsets", "Offset \"CBasePlayer::m_iFOV\" was not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// void CBaseEntity::SetAbsVelocity( const Vector &vecAbsVelocity )
|
|
||||||
Handle hGameConf = LoadGameConfigFile("zombiereloaded");
|
Handle hGameConf = LoadGameConfigFile("zombiereloaded");
|
||||||
if (hGameConf != INVALID_HANDLE)
|
if (hGameConf != INVALID_HANDLE)
|
||||||
{
|
{
|
||||||
|
@ -35,16 +35,6 @@
|
|||||||
*/
|
*/
|
||||||
stock ToolsClientVelocity(client, Float:vecVelocity[3], bool:apply = true, bool:stack = true)
|
stock ToolsClientVelocity(client, Float:vecVelocity[3], bool:apply = true, bool:stack = true)
|
||||||
{
|
{
|
||||||
static bool:gotoffset = false;
|
|
||||||
static offset = -1;
|
|
||||||
|
|
||||||
if(!gotoffset)
|
|
||||||
{
|
|
||||||
offset = FindDataMapInfo(client, "m_vecAbsVelocity");
|
|
||||||
if(offset != -1)
|
|
||||||
gotoffset = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If retrieve is true, then get client's velocity.
|
// If retrieve is true, then get client's velocity.
|
||||||
if (!apply)
|
if (!apply)
|
||||||
{
|
{
|
||||||
@ -66,10 +56,7 @@ stock ToolsClientVelocity(client, Float:vecVelocity[3], bool:apply = true, bool:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Apply velocity on client.
|
// Apply velocity on client.
|
||||||
if(gotoffset) // Fixes trigger OnStartTouch/OnEndTouch bug
|
SetEntDataVector(client, g_iToolsVelocity, vecVelocity);
|
||||||
SetEntDataVector(client, offset, vecVelocity);
|
|
||||||
else // Fallback to old one
|
|
||||||
TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, vecVelocity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user