Add ZTeleStopTimer to reduce duplicated code.
This change also requires that timers are stopped when clients disconnects.
This commit is contained in:
parent
8e6d4f0f35
commit
918dd3100b
|
@ -335,6 +335,7 @@ public OnClientDisconnect(client)
|
|||
ZSpawnOnClientDisconnect(client);
|
||||
VolOnPlayerDisconnect(client);
|
||||
ImmunityOnClientDisconnect(client);
|
||||
ZTeleOnClientDisconnect(client);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -69,8 +69,7 @@ ZTeleOnCommandsCreate()
|
|||
*/
|
||||
ZTeleClientInit(client)
|
||||
{
|
||||
// Reset timer handle.
|
||||
tZTele[client] = INVALID_HANDLE;
|
||||
ZTeleStopTimer(client);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -86,14 +85,7 @@ ZTeleOnClientSpawn(client)
|
|||
// Get spawn location.
|
||||
GetClientAbsOrigin(client, g_vecZTeleSpawn[client]);
|
||||
|
||||
// If timer is running, kill it.
|
||||
if (tZTele[client] != INVALID_HANDLE)
|
||||
{
|
||||
KillTimer(tZTele[client]);
|
||||
}
|
||||
|
||||
// Reset timer handle.
|
||||
tZTele[client] = INVALID_HANDLE;
|
||||
ZTeleStopTimer(client);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -103,14 +95,12 @@ ZTeleOnClientSpawn(client)
|
|||
*/
|
||||
ZTeleOnClientDeath(client)
|
||||
{
|
||||
// If timer is running, kill it.
|
||||
if (tZTele[client] != INVALID_HANDLE)
|
||||
{
|
||||
KillTimer(tZTele[client]);
|
||||
}
|
||||
|
||||
// Reset timer handle.
|
||||
tZTele[client] = INVALID_HANDLE;
|
||||
ZTeleStopTimer(client);
|
||||
}
|
||||
|
||||
ZTeleOnClientDisconnect(client)
|
||||
{
|
||||
ZTeleStopTimer(client);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -120,14 +110,7 @@ ZTeleOnClientDeath(client)
|
|||
*/
|
||||
ZTeleOnClientInfected(client)
|
||||
{
|
||||
// If timer is running, kill it.
|
||||
if (tZTele[client] != INVALID_HANDLE)
|
||||
{
|
||||
KillTimer(tZTele[client]);
|
||||
}
|
||||
|
||||
// Reset timer handle.
|
||||
tZTele[client] = INVALID_HANDLE;
|
||||
ZTeleStopTimer(client);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -460,3 +443,12 @@ public Action:ZTeleTimer(Handle:timer, any:client)
|
|||
// Allow timer to continue repeating.
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
ZTeleStopTimer(client)
|
||||
{
|
||||
if (tZTele[client] != INVALID_HANDLE)
|
||||
{
|
||||
KillTimer(tZTele[client]);
|
||||
}
|
||||
tZTele[client] = INVALID_HANDLE;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user