2009-04-29 01:58:41 +02:00
/*
* ============================================================================
*
2009-07-05 08:49:23 +02:00
* Zombie : Reloaded
2009-04-29 01:58:41 +02:00
*
2009-06-12 05:51:26 +02:00
* File : zspawn . inc
* Type : Module
* Description : Handles zspawn command , spawns late - joining clients into the game .
*
2013-01-12 08:47:36 +01:00
* Copyright ( C ) 2009 - 2013 Greyscale , Richard Helgeby
2009-06-12 05:51:26 +02:00
*
* This program is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2009-04-29 01:58:41 +02:00
*
* ============================================================================
*/
2018-08-28 14:54:42 +02:00
/**
2018-08-29 16:21:27 +02:00
* Conditions for zspawning players .
2018-08-28 14:54:42 +02:00
*/
enum ZSpawnCondition
{
2018-08-29 16:21:27 +02:00
ZSpawn_Block = - 1 , /** Block ZSpawn. */
ZSpawn_Human = 0 , /** ZSpawn as a human. */
ZSpawn_Zombie /** ZSpawn as a zombie. */
2018-08-28 14:54:42 +02:00
}
2009-05-06 03:04:55 +02:00
/**
* Global variable to store infect timer handle .
*/
new Handle : tZSpawn = INVALID_HANDLE ;
2009-06-21 07:24:31 +02:00
/**
* Global variable to store SteamID cache handle .
*/
new Handle : g_hZSpawnSteamIDCache = INVALID_HANDLE ;
2020-12-05 20:38:16 +01:00
new Handle : g_hZspawnInfectedSteamIDCache = INVALID_HANDLE ;
2009-06-21 07:24:31 +02:00
2016-02-17 00:48:42 +01:00
new bool : g_bZSpawnClientInfected [ MAXPLAYERS + 1 ] = { false , ... };
2009-06-17 23:32:46 +02:00
/**
* Create commands specific to ZSpawn .
*/
ZSpawnOnCommandsCreate ()
{
// Register ZSpawn command.
RegConsoleCmd ( SAYHOOKS_KEYWORD_ZSPAWN , ZSpawnCommand , " Spawn into the game after joining late. " );
2016-02-06 00:47:47 +01:00
2009-06-26 02:03:34 +02:00
// Register admin command to force ZSpawn.
2009-10-26 23:17:22 +01:00
RegConsoleCmd ( " zr_zspawn_force " , ZSpawnForceCommand , " Force ZSpawn on a client. Usage: zr_zspawn_force <client> ['0' = Spawn as human | '1' = Spawn as zombie] " );
2009-06-17 23:32:46 +02:00
}
2009-05-06 03:04:55 +02:00
/**
* Map is starting .
*/
ZSpawnOnMapStart ()
{
// Reset timer handle.
tZSpawn = INVALID_HANDLE ;
2016-02-06 00:47:47 +01:00
2009-06-21 07:24:31 +02:00
// If SteamID cache hasn't been created yet, then create.
if ( g_hZSpawnSteamIDCache == INVALID_HANDLE )
{
g_hZSpawnSteamIDCache = SteamidCacheCreate ();
}
2020-12-05 20:38:16 +01:00
if ( g_hZspawnInfectedSteamIDCache == INVALID_HANDLE )
{
g_hZspawnInfectedSteamIDCache = SteamidCacheCreate ();
}
2016-02-06 00:47:47 +01:00
2009-06-21 07:24:31 +02:00
// Reset the SteamID cache.
SteamidCacheReset ( g_hZSpawnSteamIDCache );
2020-12-05 20:38:16 +01:00
SteamidCacheReset ( g_hZspawnInfectedSteamIDCache );
2016-02-17 00:48:42 +01:00
for ( new client = 1 ; client <= MAXPLAYERS ; client ++ )
g_bZSpawnClientInfected [ client ] = false ;
2009-05-06 03:04:55 +02:00
}
2020-12-05 20:38:16 +01:00
/**
* Client is joining the server .
*
* @ param client The client index .
*/
ZSpawnOnClientPutInServer ( client )
{
g_bZSpawnClientInfected [ client ] = SteamidCacheRemoveClient ( g_hZspawnInfectedSteamIDCache , client );
}
2009-04-29 01:58:41 +02:00
/**
* Client is leaving the server .
2016-02-06 00:47:47 +01:00
*
2009-04-29 01:58:41 +02:00
* @ param client The client index .
*/
ZSpawnOnClientDisconnect ( client )
{
2009-07-09 08:22:53 +02:00
// So people who are connecting that click "cancel" aren't added to the list.
if ( ! IsClientInGame ( client ))
{
return ;
}
2016-02-06 00:47:47 +01:00
2009-05-09 17:45:19 +02:00
// Check if client is a bot.
2009-05-10 01:32:53 +02:00
if ( IsFakeClient ( client ))
2009-05-09 17:45:19 +02:00
{
return ;
}
2016-02-06 00:47:47 +01:00
2009-06-21 07:24:31 +02:00
// Add client to the SteamID cache.
SteamidCacheAddClient ( g_hZSpawnSteamIDCache , client );
2016-02-17 00:48:42 +01:00
2020-12-05 20:38:16 +01:00
// If this client was infected, remember until the next round or until they rejoin.
if ( g_bZSpawnClientInfected [ client ])
SteamidCacheAddClient ( g_hZspawnInfectedSteamIDCache , client );
2016-02-17 00:48:42 +01:00
g_bZSpawnClientInfected [ client ] = false ;
2009-04-29 01:58:41 +02:00
}
2009-05-06 03:04:55 +02:00
/**
* Client has been killed .
2016-02-06 00:47:47 +01:00
*
2009-05-06 03:04:55 +02:00
* @ param client The client index .
*/
ZSpawnOnClientDeath ( client )
{
2009-06-21 07:24:31 +02:00
// Add client to the SteamID cache.
SteamidCacheAddClient ( g_hZSpawnSteamIDCache , client );
2009-05-06 03:04:55 +02:00
}
2019-03-10 19:59:20 +01:00
/**
2019-03-10 21:39:27 +01:00
* Client joined a class .
2019-03-10 19:59:20 +01:00
*
* @ param client The client index .
*/
2019-03-10 21:39:27 +01:00
ZSpawnOnClientClassPost ( client )
2019-03-10 19:59:20 +01:00
{
2019-09-20 12:18:42 +02:00
// If client isn't on a team, then stop.
if ( ! ZRIsClientOnTeam ( client ))
{
return ;
}
2019-08-19 15:24:17 +02:00
// If zspawn is disabled, then stop.
new bool : zspawn = GetConVarBool ( g_hCvarsList [ CVAR_ZSPAWN ]);
if ( ! zspawn )
{
return ;
}
// If auto zspawn is disabled, then stop.
2019-03-10 19:59:20 +01:00
new bool : autozspawn = GetConVarBool ( g_hCvarsList [ CVAR_ZSPAWN_AUTO ]);
2019-08-19 15:24:17 +02:00
if ( ! autozspawn )
{
return ;
}
2019-10-16 22:54:16 +02:00
// Is the client dead and not source-tv?
2019-08-19 15:24:17 +02:00
if ( ! IsPlayerAlive ( client ) && ! IsClientSourceTV ( client ))
2019-03-10 19:59:20 +01:00
{
// Get our zspawn condition.
2019-10-16 22:54:16 +02:00
new ZSpawnCondition : condition = GetZSpawnCondition ( client );
2019-03-10 19:59:20 +01:00
switch ( condition )
{
case ZSpawn_Human , ZSpawn_Zombie :
{
2019-10-16 22:54:16 +02:00
// ZSpawn client.
ZSpawnClient ( client , false , false , false );
2019-03-10 19:59:20 +01:00
}
}
}
}
2009-05-06 03:04:55 +02:00
2018-08-28 14:54:42 +02:00
/**
* Client is spawning into the game .
*
* @ param client The client index .
*/
ZSpawnOnClientSpawn ( client )
{
2018-09-08 16:03:32 +02:00
// Check if client is spawning on a team.
if ( ZRIsClientOnTeam ( client ) && InfectHasZombieSpawned ())
2018-08-28 14:54:42 +02:00
{
// Get our zspawn condition.
2019-10-16 22:54:16 +02:00
new ZSpawnCondition : condition = GetZSpawnCondition ( client );
2018-08-28 14:54:42 +02:00
switch ( condition )
{
case ZSpawn_Zombie :
{
2018-09-08 16:03:32 +02:00
// Infect client.
2018-09-06 13:50:30 +02:00
InfectHumanToZombie ( client );
2018-08-28 14:54:42 +02:00
}
}
}
}
2016-02-17 00:48:42 +01:00
/**
* Client has been infected .
*
* @ param client The client index .
*/
ZSpawnOnClientInfected ( client )
{
g_bZSpawnClientInfected [ client ] = true ;
}
/**
* Client was turned back into a human .
*
* @ param client The client index .
*/
ZSpawnOnClientHuman ( client )
{
g_bZSpawnClientInfected [ client ] = false ;
}
2009-04-29 01:58:41 +02:00
/**
* The round is starting .
*/
ZSpawnOnRoundStart ()
{
2009-06-21 07:24:31 +02:00
// Reset the SteamID cache.
SteamidCacheReset ( g_hZSpawnSteamIDCache );
2020-12-05 20:38:16 +01:00
SteamidCacheReset ( g_hZspawnInfectedSteamIDCache );
2016-02-06 00:47:47 +01:00
2016-02-17 00:48:42 +01:00
for ( new client = 1 ; client <= MAXPLAYERS ; client ++ )
g_bZSpawnClientInfected [ client ] = false ;
2009-05-06 03:04:55 +02:00
// If zspawn timer is running, then kill it.
if ( tZSpawn != INVALID_HANDLE )
{
// Kill timer.
KillTimer ( tZSpawn );
2016-02-06 00:47:47 +01:00
2009-05-06 03:04:55 +02:00
// Reset timer handle.
tZSpawn = INVALID_HANDLE ;
}
}
/**
* The freeze time is ending .
*/
ZSpawnOnRoundFreezeEnd ()
{
// If infect timer is running, then kill it.
if ( tZSpawn != INVALID_HANDLE )
{
// Kill timer.
KillTimer ( tZSpawn );
}
2016-02-06 00:47:47 +01:00
2009-05-06 03:04:55 +02:00
// If zspawn is disabled, then stop.
new bool : zspawn = GetConVarBool ( g_hCvarsList [ CVAR_ZSPAWN ]);
if ( ! zspawn )
{
return ;
}
2016-02-06 00:47:47 +01:00
2009-05-06 03:04:55 +02:00
// If timelimit is disabled, then stop.
new bool : zspawntimelimit = GetConVarBool ( g_hCvarsList [ CVAR_ZSPAWN_TIMELIMIT ]);
if ( ! zspawntimelimit )
{
return ;
}
2016-02-06 00:47:47 +01:00
2009-05-06 03:04:55 +02:00
// Get timelimit
new Float : zspawntime = GetConVarFloat ( g_hCvarsList [ CVAR_ZSPAWN_TIMELIMIT_TIME ]);
2016-02-06 00:47:47 +01:00
2009-05-06 03:04:55 +02:00
// Start timer.
tZSpawn = CreateTimer ( zspawntime , ZSpawnTimer , _ , TIMER_FLAG_NO_MAPCHANGE );
}
/**
* The round is ending .
*/
ZSpawnOnRoundEnd ()
{
// If zspawn timer is running, then kill it.
if ( tZSpawn != INVALID_HANDLE )
{
// Kill timer.
KillTimer ( tZSpawn );
2016-02-06 00:47:47 +01:00
2009-05-06 03:04:55 +02:00
// Reset timer handle.
tZSpawn = INVALID_HANDLE ;
}
2009-04-29 01:58:41 +02:00
}
2009-05-06 02:28:09 +02:00
/**
* Spawns a late - joining client into the game .
2016-02-06 00:47:47 +01:00
*
2009-05-06 02:28:09 +02:00
* @ param client The client index .
2009-06-26 02:03:34 +02:00
* @ param force ( Optional ) True to force spawning of the client , false to follow rules .
* @ param zombie ( Optional ) If you are forcing spawn , you must override the team here .
2009-05-06 02:28:09 +02:00
* @ return True if successful , false otherwise .
*/
2019-10-16 22:54:16 +02:00
bool : ZSpawnClient ( client , bool : force = false , bool : zombie = false , bool error = true )
2009-04-29 01:58:41 +02:00
{
// If zspawn is disabled, then stop.
new bool : zspawn = GetConVarBool ( g_hCvarsList [ CVAR_ZSPAWN ]);
2009-06-26 02:03:34 +02:00
if ( ! force && ! zspawn )
2009-04-29 01:58:41 +02:00
{
2019-10-16 22:54:16 +02:00
if ( error )
{
TranslationPrintToChat ( client , " Feature is disabled " );
}
2009-05-06 02:28:09 +02:00
return false ;
2009-04-29 01:58:41 +02:00
}
2016-02-06 00:47:47 +01:00
2009-05-06 03:04:55 +02:00
// If client isn't on a team, then stop.
if ( ! ZRIsClientOnTeam ( client ))
{
2019-10-16 22:54:16 +02:00
if ( ! force && error )
2009-06-26 02:03:34 +02:00
{
// Tell client the command may only be used when on a team.
TranslationPrintToChat ( client , " Must be on team " );
}
2016-02-06 00:47:47 +01:00
2009-05-06 03:04:55 +02:00
return false ;
}
2016-02-06 00:47:47 +01:00
2009-04-29 01:58:41 +02:00
// If client is alive, then stop.
if ( IsPlayerAlive ( client ))
{
2019-10-16 22:54:16 +02:00
if ( ! force && error )
2009-06-26 02:03:34 +02:00
{
// Tell client the command may only be used when dead.
TranslationPrintToChat ( client , " Must be dead " );
}
2016-02-06 00:47:47 +01:00
2009-05-06 02:28:09 +02:00
return false ;
2009-04-29 01:58:41 +02:00
}
2016-02-06 00:47:47 +01:00
2009-04-29 01:58:41 +02:00
// Block if client has already played during this round.
2009-07-24 00:41:39 +02:00
new blockrejoin = GetConVarBool ( g_hCvarsList [ CVAR_ZSPAWN_BLOCK_REJOIN ]);
if ( ! force && SteamidCacheClientExists ( g_hZSpawnSteamIDCache , client ) && blockrejoin )
2009-04-29 01:58:41 +02:00
{
2019-10-16 22:54:16 +02:00
if ( error )
{
// Tell client the command may only be used when joining late.
TranslationPrintToChat ( client , " ZSpawn double spawn " );
}
2009-05-06 02:28:09 +02:00
return false ;
2009-04-29 01:58:41 +02:00
}
2016-02-06 00:47:47 +01:00
2016-03-01 23:36:47 +01:00
// Client has been infected this round, respawning as a zombie
2009-06-26 02:03:34 +02:00
new bool : teamzombie ;
2016-02-06 00:47:47 +01:00
2009-06-26 02:03:34 +02:00
if ( ! force )
2009-05-06 03:04:55 +02:00
{
2018-08-28 14:54:42 +02:00
// Get our zspawn condition.
2019-10-16 22:54:16 +02:00
new ZSpawnCondition : condition = GetZSpawnCondition ( client );
2016-02-06 00:47:47 +01:00
2018-08-28 14:54:42 +02:00
switch ( condition )
2009-05-06 03:04:55 +02:00
{
2018-08-28 14:54:42 +02:00
case ZSpawn_Block :
2009-06-15 21:43:06 +02:00
{
2018-08-28 14:54:42 +02:00
// Get timelimit.
new Float : zspawntime = GetConVarFloat ( g_hCvarsList [ CVAR_ZSPAWN_TIMELIMIT_TIME ]);
2019-10-16 22:54:16 +02:00
if ( error )
{
// Tell client the timelimit for this command has expired.
TranslationPrintToChat ( client , " ZSpawn timelimit " , RoundToNearest ( zspawntime ));
}
2018-08-28 14:54:42 +02:00
return false ;
}
case ZSpawn_Human :
{
teamzombie = false ;
}
case ZSpawn_Zombie :
{
teamzombie = true ;
2009-06-15 21:43:06 +02:00
}
2009-05-06 03:04:55 +02:00
}
}
2009-06-26 02:03:34 +02:00
else
{
// Use the override team in the function if were forcing the spawn.
2018-08-28 14:54:42 +02:00
teamzombie = zombie ;
2009-06-26 02:03:34 +02:00
}
2016-02-06 00:47:47 +01:00
2009-04-29 01:58:41 +02:00
// Tell respawn module to respawn client.
2010-11-14 15:17:19 +01:00
return RespawnSpawnClient ( client , teamzombie , false );
2009-05-01 11:22:45 +02:00
}
2009-05-06 03:04:55 +02:00
2009-06-26 02:03:34 +02:00
/**
* Menu callback ( zspawn_force )
* Forces ZSpawn on a client .
2016-02-06 00:47:47 +01:00
*
2009-06-26 02:03:34 +02:00
* @ param menu The menu handle .
* @ param action Action client is doing in menu .
* @ param client The client index .
* @ param slot The menu slot selected . ( starting from 0 )
*/
public ZSpawnForceHandle ( Handle : menu_zspawn_force , MenuAction : action , client , slot )
{
// Client selected an option.
if ( action == MenuAction_Select )
{
// Get the client index of the selected client.
new target = MenuGetClientIndex ( menu_zspawn_force , slot );
2016-02-06 00:47:47 +01:00
2010-02-14 16:13:30 +01:00
// If the target is 0, then the client left before being selected from the menu.
if ( target == 0 )
{
// Re-send the menu.
MenuClientList ( client , ZSpawnForceHandle , true , true , false , " ZSpawn clients title " );
2016-02-06 00:47:47 +01:00
2010-02-14 16:13:30 +01:00
return ;
}
2016-02-06 00:47:47 +01:00
2009-06-26 02:03:34 +02:00
// Get the target's name for future use.
2017-05-01 23:59:38 +02:00
decl String : targetname [ MAX_NAME_LENGTH ], String : adminname [ MAX_NAME_LENGTH ];
2009-06-26 02:03:34 +02:00
GetClientName ( target , targetname , sizeof ( targetname ));
2016-02-06 00:47:47 +01:00
2017-05-01 23:59:38 +02:00
// Get admin's name for future use.
if ( client > 0 )
GetClientName ( client , adminname , sizeof ( adminname ));
else
strcopy ( adminname , sizeof ( adminname ), " Console " );
2009-06-26 02:03:34 +02:00
// Force ZSpawn on the target.
new bool : success = ZSpawnClient ( target , true );
2016-02-06 00:47:47 +01:00
2009-06-26 02:03:34 +02:00
// Tell admin the outcome of the action.
if ( success )
{
2017-05-01 23:59:38 +02:00
// Log action to game events.
LogEvent ( false , LogType_Normal , LOG_GAME_EVENTS , LogModule_ZSpawn , " Force ZSpawn " , " \" %L \" force zspawned \" %L \" as human " , client , target );
2009-06-26 02:03:34 +02:00
TranslationReplyToCommand ( client , " ZSpawn command force successful " , targetname );
2017-05-01 23:59:38 +02:00
TranslationPrintToChatAllExcept ( false , false , client , " ZSpawn command force successful public " , adminname , targetname , " human " );
2009-06-26 02:03:34 +02:00
}
else
{
TranslationReplyToCommand ( client , " ZSpawn command force unsuccessful " , targetname );
}
2016-02-06 00:47:47 +01:00
2009-06-26 02:03:34 +02:00
// Re-send the menu.
2009-07-21 22:25:11 +02:00
MenuClientList ( client , ZSpawnForceHandle , true , false , true , " ZSpawn clients title " );
2009-06-26 02:03:34 +02:00
}
// Client closed the menu.
if ( action == MenuAction_Cancel )
{
// Client hit "Back" button.
if ( slot == MenuCancel_ExitBack )
{
// Re-open admin menu.
ZAdminMenu ( client );
}
}
// Client exited menu.
if ( action == MenuAction_End )
{
CloseHandle ( menu_zspawn_force );
}
}
2009-06-17 23:32:46 +02:00
/**
* Command callback ( zspawn )
* Spawn into the game after joining late .
2016-02-06 00:47:47 +01:00
*
2009-06-17 23:32:46 +02:00
* @ param client The client index .
* @ param argc Argument count .
*/
public Action : ZSpawnCommand ( client , argc )
{
// If client is console, then stop and tell them this feature is for players only.
if ( ZRIsConsole ( client ))
{
TranslationPrintToServer ( " Must be player " );
return Plugin_Handled ;
}
2016-02-06 00:47:47 +01:00
2009-06-17 23:32:46 +02:00
// Spawn client.
ZSpawnClient ( client );
2016-02-06 00:47:47 +01:00
2009-06-17 23:32:46 +02:00
// This stops the "Unknown command" message in client's console.
return Plugin_Handled ;
}
2009-06-26 02:03:34 +02:00
/**
* Command callback ( zr_zspawn_force )
* Force ZSpawn on a client .
2016-02-06 00:47:47 +01:00
*
2009-06-26 02:03:34 +02:00
* @ param client The client index .
* @ param argc Argument count .
*/
public Action : ZSpawnForceCommand ( client , argc )
{
2009-10-28 23:39:58 +01:00
// Check if privileged.
if ( ! ZRIsClientPrivileged ( client , OperationType_Generic ))
{
TranslationReplyToCommand ( client , " No access to command " );
return Plugin_Handled ;
}
2016-02-06 00:47:47 +01:00
2009-06-26 02:03:34 +02:00
// If not enough arguments given, then stop.
if ( argc < 1 )
{
TranslationReplyToCommand ( client , " ZSpawn command force syntax " );
return Plugin_Handled ;
}
2016-02-06 00:47:47 +01:00
2016-04-22 01:24:10 +02:00
decl String : target [ MAX_NAME_LENGTH ], String : targetname [ MAX_NAME_LENGTH ], String : adminname [ MAX_NAME_LENGTH ];
2009-06-26 02:03:34 +02:00
new targets [ MAXPLAYERS ], bool : tn_is_ml , result ;
2016-02-06 00:47:47 +01:00
2009-06-26 02:03:34 +02:00
// Get targetname.
GetCmdArg ( 1 , target , sizeof ( target ));
2016-02-06 00:47:47 +01:00
2016-04-22 01:24:10 +02:00
// Get admin's name for later use.
if ( client > 0 )
GetClientName ( client , adminname , sizeof ( adminname ));
else
strcopy ( adminname , sizeof ( adminname ), " Console " );
2009-06-26 02:03:34 +02:00
// Find a target.
result = ProcessTargetString ( target , client , targets , sizeof ( targets ), COMMAND_FILTER_DEAD , targetname , sizeof ( targetname ), tn_is_ml );
2016-02-06 00:47:47 +01:00
2009-06-26 02:03:34 +02:00
// Check if there was a problem finding a client.
if ( result <= 0 )
{
ZRReplyToTargetError ( client , result );
return Plugin_Handled ;
}
2016-02-06 00:47:47 +01:00
2009-06-26 02:03:34 +02:00
// Get item to give to client.
decl String : strZombie [ 4 ];
GetCmdArg ( 2 , strZombie , sizeof ( strZombie ));
2016-02-06 00:47:47 +01:00
2009-06-26 02:03:34 +02:00
// Copy value of second (optional) parameter to 'zombie'.
// It will be false if the parameter wasn't specified.
new bool : zombie = bool : StringToInt ( strZombie );
2017-05-01 23:59:38 +02:00
new bool : success = false ;
2016-02-06 00:47:47 +01:00
2009-06-26 02:03:34 +02:00
// x = Client index.
for ( new x = 0 ; x < result ; x ++ )
{
2017-05-01 23:59:38 +02:00
// Spawn client
if ( ZSpawnClient ( targets [ x ], true , zombie ))
2016-04-22 01:24:10 +02:00
{
2017-05-01 23:59:38 +02:00
// Log action to game events.
LogEvent ( false , LogType_Normal , LOG_GAME_EVENTS , LogModule_ZSpawn , " Force ZSpawn " , " \" %L \" force zspawned \" %L \" as %s " , client , targets [ x ], zombie ? " zombie " : " human " );
2016-02-06 00:47:47 +01:00
2017-05-01 23:59:38 +02:00
success = true ;
2009-06-26 02:03:34 +02:00
}
}
2016-02-06 00:47:47 +01:00
2017-05-01 23:59:38 +02:00
// Tell admin the outcome of the command.
if ( success )
{
TranslationReplyToCommand ( client , " ZSpawn command force successful " , targetname );
TranslationPrintToChatAllExcept ( false , false , client , " ZSpawn command force successful public " , adminname , targetname , zombie ? " zombie " : " human " );
}
else
{
TranslationReplyToCommand ( client , " ZSpawn command force unsuccessful " , targetname );
}
2016-02-06 00:47:47 +01:00
2009-06-26 02:03:34 +02:00
return Plugin_Handled ;
}
2009-05-06 03:04:55 +02:00
/**
* Timer callback , resets handle .
2016-02-06 00:47:47 +01:00
*
2009-05-06 03:04:55 +02:00
* @ param timer The timer handle .
*/
public Action : ZSpawnTimer ( Handle : timer )
{
// Reset timer handle.
tZSpawn = INVALID_HANDLE ;
2009-06-12 15:52:51 +02:00
}
2018-08-28 14:54:42 +02:00
/**
* Get ZSpawn condition .
*/
2019-10-16 22:54:16 +02:00
ZSpawnCondition : GetZSpawnCondition ( int client )
2018-08-28 14:54:42 +02:00
{
new ZSpawnCondition : condition ;
// Check if zspawn override is enabled, and if so use overriden value.
if ( GetConVarBool ( g_hCvarsList [ CVAR_ZSPAWN_TEAM_OVERRIDE ]))
{
// Convert boolean to zspawn condition.
condition = GetConVarBool ( g_hCvarsList [ CVAR_ZSPAWN_TEAM_ZOMBIE ]) ? ZSpawn_Zombie : ZSpawn_Human ;
}
else
{
// Convert boolean to zspawn condition.
condition = GetConVarBool ( g_hCvarsList [ CVAR_RESPAWN_TEAM_ZOMBIE ]) ? ZSpawn_Zombie : ZSpawn_Human ;
}
// Check if zspawn timelimit is enabled.
if ( GetConVarBool ( g_hCvarsList [ CVAR_ZSPAWN_TIMELIMIT ]))
{
2020-12-05 20:06:21 +01:00
new zspawntimelimitzombie = GetConVarInt ( g_hCvarsList [ CVAR_ZSPAWN_TIMELIMIT_ZOMBIE ]);
2018-08-28 14:54:42 +02:00
// Check if zspawn timelimit is expired.
if ( ! ZRIsTimerRunning ( tZSpawn ))
{
switch ( zspawntimelimitzombie )
{
2018-09-06 13:50:30 +02:00
case ZSpawn_Block :
2018-08-28 14:54:42 +02:00
{
condition = ZSpawn_Block ;
}
2018-09-06 13:50:30 +02:00
case ZSpawn_Human :
2018-08-28 14:54:42 +02:00
{
condition = ZSpawn_Human ;
2019-12-02 23:32:16 +01:00
// Client has been infected this round, respawning as a zombie.
2020-12-05 20:06:21 +01:00
if ( g_bZSpawnClientInfected [ client ])
2019-12-02 23:32:16 +01:00
condition = ZSpawn_Zombie ;
2018-08-28 14:54:42 +02:00
}
2018-09-06 13:50:30 +02:00
case ZSpawn_Zombie :
2018-08-28 14:54:42 +02:00
{
condition = ZSpawn_Zombie ;
}
}
}
2020-12-05 20:06:21 +01:00
else
{
// Client has been infected this round, respawning as a zombie.
if ( condition == ZSpawn_Human && g_bZSpawnClientInfected [ client ])
condition = ZSpawn_Zombie ;
}
2018-08-28 14:54:42 +02:00
}
return condition ;
}