sm-zombiereloaded-3/src/zr/zspawn.inc

84 lines
2.0 KiB
PHP
Raw Normal View History

2009-04-29 01:58:41 +02:00
/*
* ============================================================================
*
* Zombie:Reloaded
*
* File: zspawn.inc
* Type: Module
* Description: Handles zspawn command, spawns late-joining clients into the game.
2009-04-29 01:58:41 +02:00
*
* ============================================================================
*/
/**
* Array to block zspawn for a unique client serial number.
*/
new bool:g_bZSpawnBlock[MAXPLAYERS + 1];
/**
* Client is leaving the server.
*
* @param client The client index.
*/
ZSpawnOnClientDisconnect(client)
{
// Get client's unique serial number.
new serial = GetClientSerial(client);
// Block zspawn.
g_bZSpawnBlock[serial] = true;
}
/**
* The round is starting.
*/
ZSpawnOnRoundStart()
{
// Disable flag that blocks zspawn for all clients.
// x = client index.
for (new x = 1; x <= MaxClients; x++)
{
// Unblock zspawn.
g_bZSpawnBlock[x] = false;
}
}
/**
* Spawns a late-joining client into the game.
*
* @param client The client index.
* @return True if successful, false otherwise.
*/
bool:ZSpawnClient(client)
2009-04-29 01:58:41 +02:00
{
// If zspawn is disabled, then stop.
new bool:zspawn = GetConVarBool(g_hCvarsList[CVAR_ZSPAWN]);
if (!zspawn)
{
ZR_PrintToChat(client, "Feature is disabled");
return false;
2009-04-29 01:58:41 +02:00
}
// If client is alive, then stop.
if (IsPlayerAlive(client))
{
// Tell client the command may only be used when joining late.
ZR_PrintToChat(client, "Must be alive");
return false;
2009-04-29 01:58:41 +02:00
}
// Block if client has already played during this round.
new serial = GetClientSerial(client);
if (g_bZSpawnBlock[serial])
{
// Tell client the command may only be used when joining late.
ZR_PrintToChat(client, "ZSpawn double spawn");
return false;
2009-04-29 01:58:41 +02:00
}
// Tell respawn module to respawn client.
RespawnSpawnClient(client);
return true;
}