Add ZTeleStopTimer to reduce duplicated code.

This change also requires that timers are stopped when clients disconnects.
This commit is contained in:
Richard Helgeby 2015-03-22 17:42:02 +01:00
parent 8e6d4f0f35
commit 918dd3100b
2 changed files with 19 additions and 26 deletions

View File

@ -335,6 +335,7 @@ public OnClientDisconnect(client)
ZSpawnOnClientDisconnect(client);
VolOnPlayerDisconnect(client);
ImmunityOnClientDisconnect(client);
ZTeleOnClientDisconnect(client);
}
/**

View File

@ -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;
}