2011-02-02 10:49:19 +00:00
/* (c) Shereef Marzouk. See "licence DDRace.txt" and the readme.txt in the root of the distribution for more information. */
2010-11-13 15:31:13 +00:00
# include "gamecontext.h"
2010-11-13 15:41:43 +00:00
# include <engine/shared/config.h>
# include <engine/server/server.h>
# include <game/server/teams.h>
# include <game/server/gamemodes/DDRace.h>
# include <game/version.h>
2011-02-13 18:45:17 +00:00
# if defined(CONF_SQL)
# include <game/server/score/sql_score.h>
# endif
2010-11-13 15:31:13 +00:00
2011-02-08 12:52:23 +00:00
void CGameContext : : ConGoLeft ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-02-08 12:52:23 +00:00
pSelf - > MoveCharacter ( ClientID , pResult - > GetVictim ( ) , - 1 , 0 ) ;
2010-11-13 15:31:13 +00:00
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConGoRight ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-02-08 12:52:23 +00:00
pSelf - > MoveCharacter ( ClientID , pResult - > GetVictim ( ) , 1 , 0 ) ;
2010-11-13 15:31:13 +00:00
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConGoDown ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-02-08 12:52:23 +00:00
pSelf - > MoveCharacter ( ClientID , pResult - > GetVictim ( ) , 0 , 1 ) ;
2010-11-13 15:31:13 +00:00
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConGoUp ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-02-08 12:52:23 +00:00
pSelf - > MoveCharacter ( ClientID , pResult - > GetVictim ( ) , 0 , - 1 ) ;
2010-11-13 15:31:13 +00:00
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConMove ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-02-08 12:52:23 +00:00
pSelf - > MoveCharacter ( ClientID , pResult - > GetVictim ( ) , pResult - > GetInteger ( 0 ) , pResult - > GetInteger ( 1 ) ) ;
2010-11-13 15:31:13 +00:00
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConMoveRaw ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-02-08 12:52:23 +00:00
pSelf - > MoveCharacter ( ClientID , pResult - > GetVictim ( ) , pResult - > GetInteger ( 0 ) , pResult - > GetInteger ( 1 ) , true ) ;
2010-11-13 15:31:13 +00:00
}
2011-02-08 12:52:23 +00:00
void CGameContext : : MoveCharacter ( int ClientID , int Victim , int X , int Y , bool Raw )
2010-11-13 15:31:13 +00:00
{
2011-02-21 17:53:51 +00:00
CCharacter * pChr = GetPlayerChar ( Victim ) ;
2011-02-13 04:45:17 +00:00
2010-11-13 15:31:13 +00:00
if ( ! pChr )
return ;
2011-01-29 00:59:50 +00:00
pChr - > Core ( ) - > m_Pos . x + = ( ( Raw ) ? 1 : 32 ) * X ;
pChr - > Core ( ) - > m_Pos . y + = ( ( Raw ) ? 1 : 32 ) * Y ;
2010-11-13 15:31:13 +00:00
if ( ! g_Config . m_SvCheatTime )
pChr - > m_DDRaceState = DDRACE_CHEAT ;
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConSetlvl3 ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
int Victim = pResult - > GetVictim ( ) ;
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
if ( pSelf - > m_apPlayers [ Victim ] )
{
pSelf - > m_apPlayers [ Victim ] - > m_Authed = 3 ;
pServ - > SetRconLevel ( Victim , 3 ) ;
}
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConSetlvl2 ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
int Victim = pResult - > GetVictim ( ) ;
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
if ( pSelf - > m_apPlayers [ Victim ] )
{
pSelf - > m_apPlayers [ Victim ] - > m_Authed = 2 ;
pServ - > SetRconLevel ( Victim , 2 ) ;
}
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConSetlvl1 ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
int Victim = pResult - > GetVictim ( ) ;
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
if ( pSelf - > m_apPlayers [ Victim ] )
{
pSelf - > m_apPlayers [ Victim ] - > m_Authed = 1 ;
pServ - > SetRconLevel ( Victim , 1 ) ;
}
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConLogOut ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
int Victim = pResult - > GetVictim ( ) ;
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
if ( pSelf - > m_apPlayers [ Victim ] )
{
pSelf - > m_apPlayers [ Victim ] - > m_Authed = - 1 ;
pServ - > SetRconLevel ( Victim , - 1 ) ;
}
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConKillPlayer ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
int Victim = pResult - > GetVictim ( ) ;
if ( pSelf - > m_apPlayers [ Victim ] )
{
pSelf - > m_apPlayers [ Victim ] - > KillCharacter ( WEAPON_GAME ) ;
2011-01-26 21:09:54 +00:00
char aBuf [ 512 ] ;
2011-02-08 12:52:23 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " %s was killed by %s " , pSelf - > Server ( ) - > ClientName ( Victim ) , pSelf - > Server ( ) - > ClientName ( ClientID ) ) ;
2011-01-26 21:09:54 +00:00
pSelf - > SendChat ( - 1 , CGameContext : : CHAT_ALL , aBuf ) ;
2010-11-13 15:31:13 +00:00
}
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConNinja ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-02-08 12:52:23 +00:00
pSelf - > ModifyWeapons ( ClientID , pResult - > GetVictim ( ) , WEAPON_NINJA , false ) ;
2010-11-13 15:31:13 +00:00
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConHammer ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
int Victim = pResult - > GetVictim ( ) ;
2011-01-26 21:09:54 +00:00
char aBuf [ 128 ] ;
int Type = pResult - > GetInteger ( 0 ) ;
2010-11-13 15:31:13 +00:00
2011-01-26 21:09:54 +00:00
CCharacter * pChr = pSelf - > GetPlayerChar ( Victim ) ;
2011-02-13 04:45:17 +00:00
2011-01-26 21:09:54 +00:00
if ( ! pChr )
2010-11-13 15:31:13 +00:00
return ;
2011-02-13 04:45:17 +00:00
2010-11-13 15:31:13 +00:00
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
2011-01-26 21:09:54 +00:00
if ( Type > 3 | | Type < 0 )
2010-11-13 15:31:13 +00:00
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Select hammer between 0 and 3 " ) ;
}
else
{
2011-01-26 21:09:54 +00:00
pChr - > m_HammerType = Type ;
2010-11-13 15:31:13 +00:00
if ( ! g_Config . m_SvCheatTime )
2011-01-26 21:09:54 +00:00
pChr - > m_DDRaceState = DDRACE_CHEAT ;
2011-02-08 12:52:23 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " Hammer of '%s' ClientID=%d setted to %d " , pServ - > ClientName ( ClientID ) , Victim , Type ) ;
2011-01-26 21:09:54 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , aBuf ) ;
2010-11-13 15:31:13 +00:00
}
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConSuper ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
int Victim = pResult - > GetVictim ( ) ;
2011-01-26 21:09:54 +00:00
CCharacter * pChr = pSelf - > GetPlayerChar ( Victim ) ;
if ( pChr & & ! pChr - > m_Super )
{
pChr - > m_Super = true ;
pChr - > UnFreeze ( ) ;
pChr - > m_TeamBeforeSuper = pChr - > Team ( ) ;
pChr - > Teams ( ) - > SetCharacterTeam ( Victim , TEAM_SUPER ) ;
2010-11-13 15:31:13 +00:00
if ( ! g_Config . m_SvCheatTime )
2011-01-26 21:09:54 +00:00
pChr - > m_DDRaceState = DDRACE_CHEAT ;
2010-11-13 15:31:13 +00:00
}
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConUnSuper ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
int Victim = pResult - > GetVictim ( ) ;
2011-01-26 21:09:54 +00:00
CCharacter * pChr = pSelf - > GetPlayerChar ( Victim ) ;
if ( pChr & & pChr - > m_Super )
2010-11-13 15:31:13 +00:00
{
2011-01-26 21:09:54 +00:00
pChr - > m_Super = false ;
pChr - > Teams ( ) - > SetForceCharacterTeam ( Victim , pChr - > m_TeamBeforeSuper ) ;
2010-11-13 15:31:13 +00:00
}
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConShotgun ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-02-08 12:52:23 +00:00
pSelf - > ModifyWeapons ( ClientID , pResult - > GetVictim ( ) , WEAPON_SHOTGUN , false ) ;
2010-11-13 15:31:13 +00:00
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConGrenade ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-02-08 12:52:23 +00:00
pSelf - > ModifyWeapons ( ClientID , pResult - > GetVictim ( ) , WEAPON_GRENADE , false ) ;
2010-11-13 15:31:13 +00:00
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConRifle ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-02-08 12:52:23 +00:00
pSelf - > ModifyWeapons ( ClientID , pResult - > GetVictim ( ) , WEAPON_RIFLE , false ) ;
2010-11-13 15:31:13 +00:00
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConWeapons ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-02-08 12:52:23 +00:00
pSelf - > ModifyWeapons ( ClientID , pResult - > GetVictim ( ) , - 1 , false ) ;
2010-11-13 15:31:13 +00:00
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConUnShotgun ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-02-08 12:52:23 +00:00
pSelf - > ModifyWeapons ( ClientID , pResult - > GetVictim ( ) , WEAPON_SHOTGUN , true ) ;
2010-11-13 15:31:13 +00:00
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConUnGrenade ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-02-08 12:52:23 +00:00
pSelf - > ModifyWeapons ( ClientID , pResult - > GetVictim ( ) , WEAPON_GRENADE , true ) ;
2010-11-13 15:31:13 +00:00
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConUnRifle ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-02-08 12:52:23 +00:00
pSelf - > ModifyWeapons ( ClientID , pResult - > GetVictim ( ) , WEAPON_RIFLE , true ) ;
2010-11-13 15:31:13 +00:00
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConUnWeapons ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-02-08 12:52:23 +00:00
pSelf - > ModifyWeapons ( ClientID , pResult - > GetVictim ( ) , - 1 , true ) ;
2010-11-13 15:31:13 +00:00
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConAddWeapon ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-02-08 12:52:23 +00:00
pSelf - > ModifyWeapons ( ClientID , pResult - > GetVictim ( ) , pResult - > GetInteger ( 0 ) , false ) ;
2010-11-13 15:31:13 +00:00
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConRemoveWeapon ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-02-08 12:52:23 +00:00
pSelf - > ModifyWeapons ( ClientID , pResult - > GetVictim ( ) , pResult - > GetInteger ( 0 ) , true ) ;
2010-11-13 15:31:13 +00:00
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ModifyWeapons ( int ClientID , int Victim , int Weapon , bool Remove )
2010-11-13 15:31:13 +00:00
{
if ( clamp ( Weapon , - 1 , NUM_WEAPONS - 1 ) ! = Weapon )
{
Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " invalid weapon id " ) ;
return ;
}
2011-02-13 04:45:17 +00:00
2010-11-13 15:31:13 +00:00
CCharacter * pChr = GetPlayerChar ( Victim ) ;
if ( ! pChr )
return ;
2011-02-13 04:45:17 +00:00
2010-11-13 15:31:13 +00:00
if ( Weapon = = - 1 )
{
2011-01-29 00:59:50 +00:00
if ( Remove & & ( pChr - > GetActiveWeapon ( ) = = WEAPON_SHOTGUN | | pChr - > GetActiveWeapon ( ) = = WEAPON_GRENADE | | pChr - > GetActiveWeapon ( ) = = WEAPON_RIFLE ) )
pChr - > SetActiveWeapon ( WEAPON_GUN ) ;
2011-02-13 04:45:17 +00:00
2010-11-13 15:31:13 +00:00
if ( Remove )
{
2011-01-29 00:59:50 +00:00
pChr - > SetWeaponGot ( WEAPON_SHOTGUN , false ) ;
pChr - > SetWeaponGot ( WEAPON_GRENADE , false ) ;
pChr - > SetWeaponGot ( WEAPON_RIFLE , false ) ;
2010-11-13 15:31:13 +00:00
}
else
2011-02-13 04:45:17 +00:00
pChr - > GiveAllWeapons ( ) ;
2010-11-13 15:31:13 +00:00
}
else if ( Weapon ! = WEAPON_NINJA )
{
2011-01-29 00:59:50 +00:00
if ( Remove & & pChr - > GetActiveWeapon ( ) = = Weapon )
pChr - > SetActiveWeapon ( WEAPON_GUN ) ;
2011-02-13 04:45:17 +00:00
2010-11-13 15:31:13 +00:00
if ( Remove )
2011-01-29 00:59:50 +00:00
pChr - > SetWeaponGot ( Weapon , false ) ;
2010-11-13 15:31:13 +00:00
else
pChr - > GiveWeapon ( Weapon , - 1 ) ;
}
else
{
if ( Remove )
{
Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " you can't remove ninja " ) ;
return ;
}
2011-02-13 04:45:17 +00:00
2010-11-13 15:31:13 +00:00
pChr - > GiveNinja ( ) ;
}
if ( ! Remove & & ! g_Config . m_SvCheatTime )
pChr - > m_DDRaceState = DDRACE_CHEAT ;
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConTeleport ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
int Victim = pResult - > GetVictim ( ) ;
int TeleTo = clamp ( pResult - > GetInteger ( 0 ) , 0 , ( int ) MAX_CLIENTS - 1 ) ;
if ( pSelf - > m_apPlayers [ TeleTo ] )
{
{
2011-01-26 21:09:54 +00:00
CCharacter * pChr = pSelf - > GetPlayerChar ( Victim ) ;
if ( pChr )
2010-11-13 15:31:13 +00:00
{
2011-01-29 00:59:50 +00:00
pChr - > Core ( ) - > m_Pos = pSelf - > m_apPlayers [ TeleTo ] - > m_ViewPos ;
2010-11-13 15:31:13 +00:00
if ( ! g_Config . m_SvCheatTime )
2011-01-26 21:09:54 +00:00
pChr - > m_DDRaceState = DDRACE_CHEAT ;
2010-11-13 15:31:13 +00:00
}
}
}
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConTimerStop ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
int Victim = pResult - > GetVictim ( ) ;
2011-01-26 21:09:54 +00:00
char aBuf [ 128 ] ;
CCharacter * pChr = pSelf - > GetPlayerChar ( Victim ) ;
if ( ! pChr )
2010-11-13 15:31:13 +00:00
return ;
if ( pSelf - > m_apPlayers [ Victim ] )
{
2011-01-26 21:09:54 +00:00
pChr - > m_DDRaceState = DDRACE_CHEAT ;
2011-02-08 12:52:23 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " '%s' ClientID=%d Hasn't time now (Timer Stopped) " , pServ - > ClientName ( ClientID ) , Victim ) ;
2011-01-26 21:09:54 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , aBuf ) ;
2010-11-13 15:31:13 +00:00
}
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConTimerStart ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
int Victim = pResult - > GetVictim ( ) ;
2011-01-26 21:09:54 +00:00
char aBuf [ 128 ] ;
CCharacter * pChr = pSelf - > GetPlayerChar ( Victim ) ;
if ( ! pChr )
2010-11-13 15:31:13 +00:00
return ;
if ( pSelf - > m_apPlayers [ Victim ] )
{
2011-01-26 21:09:54 +00:00
pChr - > m_DDRaceState = DDRACE_STARTED ;
2011-02-08 12:52:23 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " '%s' ClientID=%d Has time now (Timer Started) " , pServ - > ClientName ( ClientID ) , Victim ) ;
2011-01-26 21:09:54 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , aBuf ) ;
2010-11-13 15:31:13 +00:00
}
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConTimerZero ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
int Victim = pResult - > GetVictim ( ) ;
2011-01-26 21:09:54 +00:00
char aBuf [ 128 ] ;
CCharacter * pChr = pSelf - > GetPlayerChar ( Victim ) ;
if ( ! pChr )
2010-11-13 15:31:13 +00:00
return ;
if ( pSelf - > m_apPlayers [ Victim ] )
{
2011-01-26 21:09:54 +00:00
pChr - > m_StartTime = pSelf - > Server ( ) - > Tick ( ) ;
pChr - > m_RefreshTime = pSelf - > Server ( ) - > Tick ( ) ;
pChr - > m_DDRaceState = DDRACE_CHEAT ;
2011-02-08 12:52:23 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " '%s' ClientID=%d time has been reset & stopped. " , pServ - > ClientName ( ClientID ) , Victim ) ;
2011-01-26 21:09:54 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , aBuf ) ;
2010-11-13 15:31:13 +00:00
}
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConTimerReStart ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
int Victim = pResult - > GetVictim ( ) ;
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
2011-01-26 21:09:54 +00:00
char aBuf [ 128 ] ;
CCharacter * pChr = pSelf - > GetPlayerChar ( Victim ) ;
if ( ! pChr )
2010-11-13 15:31:13 +00:00
return ;
if ( pSelf - > m_apPlayers [ Victim ] )
{
2011-01-26 21:09:54 +00:00
pChr - > m_StartTime = pSelf - > Server ( ) - > Tick ( ) ;
pChr - > m_RefreshTime = pSelf - > Server ( ) - > Tick ( ) ;
pChr - > m_DDRaceState = DDRACE_STARTED ;
2011-02-08 12:52:23 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " '%s' ClientID=%d time has been reset & stopped. " , pServ - > ClientName ( ClientID ) , Victim ) ;
2011-01-26 21:09:54 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , aBuf ) ;
2010-11-13 15:31:13 +00:00
}
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConFreeze ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-01-25 09:34:14 +00:00
int Seconds = - 1 ;
2010-11-13 15:31:13 +00:00
int Victim = pResult - > GetVictim ( ) ;
2011-01-26 21:09:54 +00:00
char aBuf [ 128 ] ;
2010-11-13 15:31:13 +00:00
2011-01-25 09:34:14 +00:00
if ( pResult - > NumArguments ( ) )
Seconds = clamp ( pResult - > GetInteger ( 0 ) , - 2 , 9999 ) ;
2011-02-13 04:45:17 +00:00
2011-01-25 09:34:14 +00:00
CCharacter * pChr = pSelf - > GetPlayerChar ( Victim ) ;
if ( ! pChr )
2010-11-13 15:31:13 +00:00
return ;
2011-02-13 04:45:17 +00:00
2010-11-13 15:31:13 +00:00
if ( pSelf - > m_apPlayers [ Victim ] )
{
2011-01-25 09:34:14 +00:00
pChr - > Freeze ( Seconds ) ;
2011-01-29 00:59:50 +00:00
pChr - > GetPlayer ( ) - > m_RconFreeze = Seconds ! = - 2 ;
2010-11-13 15:31:13 +00:00
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
2011-01-25 09:34:14 +00:00
if ( Seconds > = 0 )
2011-02-08 12:52:23 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " '%s' ClientID=%d has been Frozen for %d. " , pServ - > ClientName ( ClientID ) , Victim , Seconds ) ;
2011-01-25 09:34:14 +00:00
else if ( Seconds = = - 2 )
{
pChr - > m_DeepFreeze = true ;
2011-02-08 12:52:23 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " '%s' ClientID=%d has been Deep Frozen. " , pServ - > ClientName ( ClientID ) , Victim ) ;
2011-01-25 09:34:14 +00:00
}
else
2011-02-08 12:52:23 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " '%s' ClientID=%d is Frozen until you unfreeze him. " , pServ - > ClientName ( ClientID ) , Victim ) ;
2011-01-26 21:09:54 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , aBuf ) ;
2010-11-13 15:31:13 +00:00
}
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConUnFreeze ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
int Victim = pResult - > GetVictim ( ) ;
2011-01-25 09:34:14 +00:00
static bool Warning = false ;
2011-01-26 21:09:54 +00:00
char aBuf [ 128 ] ;
2011-01-25 09:34:14 +00:00
CCharacter * pChr = pSelf - > GetPlayerChar ( Victim ) ;
if ( ! pChr )
return ;
if ( pChr - > m_DeepFreeze & & ! Warning )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " warning " , " This client is deeply frozen, repeat the command to defrost him. " ) ;
Warning = true ;
2010-11-13 15:31:13 +00:00
return ;
2011-01-25 09:34:14 +00:00
}
if ( pChr - > m_DeepFreeze & & Warning )
{
pChr - > m_DeepFreeze = false ;
Warning = false ;
}
pChr - > m_FreezeTime = 2 ;
2011-01-29 00:59:50 +00:00
pChr - > GetPlayer ( ) - > m_RconFreeze = false ;
2010-11-13 15:31:13 +00:00
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
2011-02-08 12:52:23 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " '%s' ClientID=%d has been defrosted. " , pServ - > ClientName ( ClientID ) , Victim ) ;
2011-01-26 21:09:54 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , aBuf ) ;
2010-11-13 15:31:13 +00:00
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConInvis ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-01-26 21:09:54 +00:00
char aBuf [ 128 ] ;
2010-11-13 15:31:13 +00:00
int Victim = pResult - > GetVictim ( ) ;
2011-02-08 12:52:23 +00:00
if ( ! pSelf - > m_apPlayers [ ClientID ] )
2010-11-13 15:31:13 +00:00
return ;
if ( pSelf - > m_apPlayers [ Victim ] )
{
pSelf - > m_apPlayers [ Victim ] - > m_Invisible = true ;
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
2011-02-08 12:52:23 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " '%s' ClientID=%d is now invisible. " , pServ - > ClientName ( ClientID ) , Victim ) ;
2011-01-26 21:09:54 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , aBuf ) ;
2010-11-13 15:31:13 +00:00
}
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConVis ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
int Victim = pResult - > GetVictim ( ) ;
2011-02-08 12:52:23 +00:00
if ( ! pSelf - > m_apPlayers [ ClientID ] )
2010-11-13 15:31:13 +00:00
return ;
2011-01-26 21:09:54 +00:00
char aBuf [ 128 ] ;
2010-11-13 15:31:13 +00:00
if ( pSelf - > m_apPlayers [ Victim ] )
{
pSelf - > m_apPlayers [ Victim ] - > m_Invisible = false ;
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
2011-02-08 12:52:23 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " '%s' ClientID=%d is visible. " , pServ - > ClientName ( ClientID ) , Victim ) ;
2011-01-26 21:09:54 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , aBuf ) ;
2010-11-13 15:31:13 +00:00
}
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConCredits ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-12-16 12:50:22 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Teeworlds Team takes most of the credits also " ) ;
2011-02-08 12:52:23 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " This mod was originally created by \' 3DA \' " ) ;
2010-12-16 12:50:22 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Now it is maintained & re-coded by: " ) ;
2011-02-08 12:52:23 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " \' [Egypt]GreYFoX@GTi \' and \' [BlackTee]den \' " ) ;
2011-02-20 22:41:15 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Others Helping on the code: \' heinrich5991 \' , \' noother \' , \' LemonFace \' , \' <3 fisted <3 \' & \' Trust o_0 Aeeeh ?! \' " ) ;
2010-11-13 15:31:13 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Documentation: Zeta-Hoernchen, Entities: Fisico " ) ;
2011-02-08 12:52:23 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Code (in the past): \' 3DA \' and \' Fluxid \' " ) ;
2010-11-13 15:31:13 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Please check the changelog on DDRace.info. " ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Also the commit log on github.com/GreYFoXGTi/DDRace. " ) ;
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConInfo ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-01-30 19:11:45 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " DDRace Mod. Version: " GAME_VERSION ) ;
2010-11-13 15:31:13 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Official site: DDRace.info " ) ;
2010-11-24 21:09:31 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " For more Info /cmdlist " ) ;
2010-11-13 15:31:13 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Or visit DDRace.info " ) ;
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConHelp ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
if ( pResult - > NumArguments ( ) = = 0 )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " /cmdlist will show a list of all chat commands " ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " /help + any command will show you the help for this command " ) ;
2010-12-03 01:05:56 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Example /help settings will display the help about " ) ;
2010-11-13 15:31:13 +00:00
}
else
{
const char * pArg = pResult - > GetString ( 0 ) ;
IConsole : : CCommandInfo * pCmdInfo = pSelf - > Console ( ) - > GetCommandInfo ( pArg , CFGFLAG_SERVER ) ;
if ( pCmdInfo & & pCmdInfo - > m_pHelp )
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , pCmdInfo - > m_pHelp ) ;
else
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Command is either unknown or you have given a blank command without any parameters. " ) ;
}
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConSettings ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2010-12-03 01:05:56 +00:00
if ( pResult - > NumArguments ( ) = = 0 )
2010-11-13 15:31:13 +00:00
{
2010-12-03 01:05:56 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " to check a server setting say /settings and setting's name, setting names are: " ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " teams, cheats, collision, hooking, endlesshooking, me, " ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " hitting, oldlaser, timeout, votes, pause and scores " ) ;
}
else
{
const char * pArg = pResult - > GetString ( 0 ) ;
char aBuf [ 256 ] ;
float ColTemp ;
float HookTemp ;
pSelf - > m_Tuning . Get ( " player_collision " , & ColTemp ) ;
pSelf - > m_Tuning . Get ( " player_hooking " , & HookTemp ) ;
if ( str_comp ( pArg , " cheats " ) = = 0 )
{
str_format ( aBuf , sizeof ( aBuf ) , " %s%s " ,
g_Config . m_SvCheats ? " People can cheat " : " People can't cheat " ,
( g_Config . m_SvCheats ) ? ( g_Config . m_SvCheatTime ) ? " with time " : " without time " : " " ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , aBuf ) ;
if ( g_Config . m_SvCheats )
{
str_format ( aBuf , sizeof ( aBuf ) , " %s " , g_Config . m_SvEndlessSuperHook ? " super can hook you forever " : " super can only hook you for limited time " ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , aBuf ) ;
str_format ( aBuf , sizeof ( aBuf ) , " %s " , g_Config . m_SvTimer ? " admins have the power to control your time " : " admins have no power over your time " ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , aBuf ) ;
}
}
else if ( str_comp ( pArg , " teams " ) = = 0 )
{
2011-02-14 21:34:46 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " %s %s " , g_Config . m_SvTeam = = 1 ? " Teams are available on this server " : ! g_Config . m_SvTeam ? " Teams are not available on this server " : " You have to be in a team to play on this server " , ! g_Config . m_SvTeamStrict ? " and if you die in a team only you die " : " and if you die in a team all of you die " ) ;
2010-12-03 01:05:56 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , aBuf ) ;
}
else if ( str_comp ( pArg , " collision " ) = = 0 )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , ColTemp ? " Players can collide on this server " : " Players Can't collide on this server " ) ;
}
else if ( str_comp ( pArg , " hooking " ) = = 0 )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , HookTemp ? " Players can hook each other on this server " : " Players Can't hook each other on this server " ) ;
}
else if ( str_comp ( pArg , " endlesshooking " ) = = 0 )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , g_Config . m_SvEndlessDrag ? " Players can hook time is unlimited " : " Players can hook time is limited " ) ;
}
else if ( str_comp ( pArg , " hitting " ) = = 0 )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , g_Config . m_SvHit ? " Player's weapons affect each other " : " Player's weapons has no affect on each other " ) ;
}
else if ( str_comp ( pArg , " oldlaser " ) = = 0 )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , g_Config . m_SvOldLaser ? " Lasers can hit you if you shot them and that they pull you towards the bounce origin (Like DDRace Beta) " : " Lasers can't hit you if you shot them, and they pull others towards the shooter " ) ;
}
else if ( str_comp ( pArg , " me " ) = = 0 )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , g_Config . m_SvSlashMe ? " Players can use /me commands the famous IRC Command " : " Players Can't use the /me command " ) ;
}
else if ( str_comp ( pArg , " timeout " ) = = 0 )
{
str_format ( aBuf , sizeof ( aBuf ) , " The Server Timeout is currently set to %d " , g_Config . m_ConnTimeout ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , aBuf ) ;
}
else if ( str_comp ( pArg , " votes " ) = = 0 )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , g_Config . m_SvVoteKick ? " Players can use Callvote menu tab to kick offenders " : " Players Can't use the Callvote menu tab to kick offenders " ) ;
if ( g_Config . m_SvVoteKick )
str_format ( aBuf , sizeof ( aBuf ) , " Players are banned for %d second(s) if they get voted off " , g_Config . m_SvVoteKickBantime ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , g_Config . m_SvVoteKickBantime ? aBuf : " Players are just kicked and not banned if they get voted off " ) ;
}
else if ( str_comp ( pArg , " pause " ) = = 0 )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , g_Config . m_SvPauseable ? g_Config . m_SvPauseTime ? " /pause is available on this server and it pauses your time too " : " /pause is available on this server but it doesn't pause your time " : " /pause is NOT available on this server " ) ;
}
else if ( str_comp ( pArg , " scores " ) = = 0 )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , g_Config . m_SvHideScore ? " Scores are private on this server " : " Scores are public on this server " ) ;
}
2010-11-13 15:31:13 +00:00
}
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConRules ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-02-16 08:17:47 +00:00
bool Printed = false ;
2010-11-13 15:31:13 +00:00
if ( g_Config . m_SvDDRaceRules )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " No blocking. " ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " No insulting / spamming. " ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " No fun voting / vote spamming. " ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Breaking any of these rules will result in a penalty, decided by server admins. " ) ;
2011-02-16 08:17:47 +00:00
Printed = true ;
2010-11-13 15:31:13 +00:00
}
if ( g_Config . m_SvRulesLine1 [ 0 ] )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , g_Config . m_SvRulesLine1 ) ;
2011-02-16 08:17:47 +00:00
Printed = true ;
2010-11-13 15:31:13 +00:00
}
if ( g_Config . m_SvRulesLine2 [ 0 ] )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , g_Config . m_SvRulesLine2 ) ;
2011-02-16 08:17:47 +00:00
Printed = true ;
2010-11-13 15:31:13 +00:00
}
if ( g_Config . m_SvRulesLine3 [ 0 ] )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , g_Config . m_SvRulesLine3 ) ;
2011-02-16 08:17:47 +00:00
Printed = true ;
2010-11-13 15:31:13 +00:00
}
if ( g_Config . m_SvRulesLine4 [ 0 ] )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , g_Config . m_SvRulesLine4 ) ;
2011-02-16 08:17:47 +00:00
Printed = true ;
2010-11-13 15:31:13 +00:00
}
if ( g_Config . m_SvRulesLine5 [ 0 ] )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , g_Config . m_SvRulesLine5 ) ;
2011-02-16 08:17:47 +00:00
Printed = true ;
2010-11-13 15:31:13 +00:00
}
if ( g_Config . m_SvRulesLine6 [ 0 ] )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , g_Config . m_SvRulesLine6 ) ;
2011-02-16 08:17:47 +00:00
Printed = true ;
2010-11-13 15:31:13 +00:00
}
if ( g_Config . m_SvRulesLine7 [ 0 ] )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , g_Config . m_SvRulesLine7 ) ;
2011-02-16 08:17:47 +00:00
Printed = true ;
2010-11-13 15:31:13 +00:00
}
if ( g_Config . m_SvRulesLine8 [ 0 ] )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , g_Config . m_SvRulesLine8 ) ;
2011-02-16 08:17:47 +00:00
Printed = true ;
2010-11-13 15:31:13 +00:00
}
if ( g_Config . m_SvRulesLine9 [ 0 ] )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , g_Config . m_SvRulesLine9 ) ;
2011-02-16 08:17:47 +00:00
Printed = true ;
2010-11-13 15:31:13 +00:00
}
if ( g_Config . m_SvRulesLine10 [ 0 ] )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , g_Config . m_SvRulesLine10 ) ;
2011-02-16 08:17:47 +00:00
Printed = true ;
2010-11-13 15:31:13 +00:00
}
2011-02-16 08:17:47 +00:00
if ( ! Printed )
2010-11-13 15:31:13 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " No Rules Defined, Kill em all!! " ) ;
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConKill ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-02-08 12:52:23 +00:00
CPlayer * pPlayer = pSelf - > m_apPlayers [ ClientID ] ;
2010-11-13 15:31:13 +00:00
2011-02-14 18:36:30 +00:00
if ( ! pPlayer | | ( pPlayer - > m_Last_Kill & & pPlayer - > m_Last_Kill + pSelf - > Server ( ) - > TickSpeed ( ) * g_Config . m_SvKillDelay > pSelf - > Server ( ) - > Tick ( ) ) )
2010-11-13 15:31:13 +00:00
return ;
pPlayer - > m_Last_Kill = pSelf - > Server ( ) - > Tick ( ) ;
pPlayer - > KillCharacter ( WEAPON_SELF ) ;
pPlayer - > m_RespawnTick = pSelf - > Server ( ) - > Tick ( ) + pSelf - > Server ( ) - > TickSpeed ( ) * g_Config . m_SvSuicidePenalty ;
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConTogglePause ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-02-08 12:52:23 +00:00
CPlayer * pPlayer = pSelf - > m_apPlayers [ ClientID ] ;
2011-02-16 08:17:47 +00:00
if ( ! pPlayer )
return ;
2010-11-13 15:31:13 +00:00
if ( g_Config . m_SvPauseable )
{
2011-01-26 21:09:54 +00:00
CCharacter * pChr = pPlayer - > GetCharacter ( ) ;
2011-01-29 00:59:50 +00:00
if ( ! pPlayer - > GetTeam ( ) & & pChr & & ( ! pChr - > GetWeaponGot ( WEAPON_NINJA ) | | pChr - > m_FreezeTime ) & & pChr - > IsGrounded ( ) & & pChr - > m_Pos = = pChr - > m_PrevPos & & ! pChr - > Team ( ) & & ! pPlayer - > m_InfoSaved )
2010-11-13 15:31:13 +00:00
{
2011-02-13 18:45:17 +00:00
if ( pPlayer - > m_Last_Pause + pSelf - > Server ( ) - > TickSpeed ( ) * g_Config . m_SvPauseFrequency < = pSelf - > Server ( ) - > Tick ( ) )
{
2010-12-13 22:16:53 +00:00
pPlayer - > SaveCharacter ( ) ;
2011-01-06 13:31:54 +00:00
pPlayer - > SetTeam ( TEAM_SPECTATORS ) ;
2010-12-13 22:16:53 +00:00
pPlayer - > m_InfoSaved = true ;
pPlayer - > m_Last_Pause = pSelf - > Server ( ) - > Tick ( ) ;
}
else
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " You can \' t pause that often. " ) ;
2010-11-13 15:31:13 +00:00
}
2011-01-06 13:31:54 +00:00
else if ( pPlayer - > GetTeam ( ) = = TEAM_SPECTATORS & & pPlayer - > m_InfoSaved )
2010-11-13 15:31:13 +00:00
{
pPlayer - > m_InfoSaved = false ;
pPlayer - > m_PauseInfo . m_Respawn = true ;
2011-01-06 13:31:54 +00:00
pPlayer - > SetTeam ( TEAM_RED ) ;
2010-11-13 15:31:13 +00:00
//pPlayer->LoadCharacter();//TODO:Check if this system Works
}
2011-01-26 21:09:54 +00:00
else if ( pChr )
2011-01-29 00:59:50 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , ( pChr - > Team ( ) ) ? " You can't pause while you are in a team " : pChr - > GetWeaponGot ( WEAPON_NINJA ) ? " You can't use /pause while you are a ninja " : ( ! pChr - > IsGrounded ( ) ) ? " You can't use /pause while you are a in air " : " You can't use /pause while you are moving " ) ;
2010-11-13 15:31:13 +00:00
else
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " No pause data saved. " ) ;
}
else
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Pause isn't allowed on this server. " ) ;
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConTop5 ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-02-08 12:52:23 +00:00
CPlayer * pPlayer = pSelf - > m_apPlayers [ ClientID ] ;
2011-02-16 08:17:47 +00:00
if ( ! pPlayer )
return ;
2010-11-13 15:31:13 +00:00
if ( g_Config . m_SvHideScore )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Showing the top 5 is not allowed on this server. " ) ;
return ;
}
2011-02-16 08:17:47 +00:00
if ( pResult - > NumArguments ( ) > 0 )
pSelf - > Score ( ) - > ShowTop5 ( pPlayer - > GetCID ( ) , pResult - > GetInteger ( 0 ) ) ;
else
pSelf - > Score ( ) - > ShowTop5 ( pPlayer - > GetCID ( ) ) ;
2010-11-13 15:31:13 +00:00
}
2011-02-13 18:45:17 +00:00
# if defined(CONF_SQL)
void CGameContext : : ConTimes ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
{
if ( g_Config . m_SvUseSQL )
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
CSqlScore * pScore = ( CSqlScore * ) pSelf - > Score ( ) ;
CPlayer * pPlayer = pSelf - > m_apPlayers [ ClientID ] ;
2011-02-16 08:17:47 +00:00
if ( ! pPlayer )
return ;
2011-02-13 18:45:17 +00:00
2011-02-15 13:58:42 +00:00
if ( pResult - > NumArguments ( ) = = 0 )
{
pScore - > ShowTimes ( pPlayer - > GetCID ( ) , 1 ) ;
return ;
}
else if ( pResult - > NumArguments ( ) < 3 )
2011-02-13 18:45:17 +00:00
{
if ( pResult - > NumArguments ( ) = = 1 )
{
2011-02-15 13:58:42 +00:00
if ( pResult - > GetInteger ( 0 ) ! = 0 )
pScore - > ShowTimes ( pPlayer - > GetCID ( ) , pResult - > GetInteger ( 0 ) ) ;
else
pScore - > ShowTimes ( pPlayer - > GetCID ( ) , ( str_comp ( pResult - > GetString ( 0 ) , " me " ) = = 0 ) ? pSelf - > Server ( ) - > ClientName ( ClientID ) : pResult - > GetString ( 0 ) , 1 ) ;
2011-02-13 18:45:17 +00:00
return ;
}
else if ( pResult - > GetInteger ( 1 ) ! = 0 )
{
pScore - > ShowTimes ( pPlayer - > GetCID ( ) , ( str_comp ( pResult - > GetString ( 0 ) , " me " ) = = 0 ) ? pSelf - > Server ( ) - > ClientName ( ClientID ) : pResult - > GetString ( 0 ) , pResult - > GetInteger ( 1 ) ) ;
return ;
}
}
2011-02-15 13:58:42 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " /times needs 0, 1 or 2 parameter. 1. = name, 2. = start number " ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Example: /times, /times me, /times Hans, /times \" Papa Smurf \" 5 " ) ;
2011-02-13 18:45:17 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Bad: /times Papa Smurf 5 # Good: /times \" Papa Smurf \" 5 " ) ;
}
}
# endif
2010-11-13 15:31:13 +00:00
2011-02-08 12:52:23 +00:00
void CGameContext : : ConRank ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-02-08 12:52:23 +00:00
CPlayer * pPlayer = pSelf - > m_apPlayers [ ClientID ] ;
2011-02-16 08:17:47 +00:00
if ( ! pPlayer )
return ;
2010-11-13 15:31:13 +00:00
if ( /*g_Config.m_SvSpamprotection && */ pPlayer - > m_Last_Chat & & pPlayer - > m_Last_Chat + pSelf - > Server ( ) - > TickSpeed ( ) + g_Config . m_SvChatDelay > pSelf - > Server ( ) - > Tick ( ) )
return ;
2011-02-13 04:45:17 +00:00
2010-11-13 15:31:13 +00:00
pPlayer - > m_Last_Chat = pSelf - > Server ( ) - > Tick ( ) ;
if ( pResult - > NumArguments ( ) > 0 )
if ( ! g_Config . m_SvHideScore )
pSelf - > Score ( ) - > ShowRank ( pPlayer - > GetCID ( ) , pResult - > GetString ( 0 ) , true ) ;
else
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Showing the rank of other players is not allowed on this server. " ) ;
else
2011-02-08 12:52:23 +00:00
pSelf - > Score ( ) - > ShowRank ( pPlayer - > GetCID ( ) , pSelf - > Server ( ) - > ClientName ( ClientID ) ) ;
2010-11-13 15:31:13 +00:00
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConJoinTeam ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
2011-02-13 04:45:17 +00:00
2010-11-13 15:31:13 +00:00
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-02-02 10:49:19 +00:00
CGameControllerDDRace * Controller = ( CGameControllerDDRace * ) pSelf - > m_pController ;
2011-02-14 21:34:46 +00:00
if ( g_Config . m_SvTeam = = 0 )
2011-02-02 10:49:19 +00:00
{
2010-11-13 15:31:13 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Admin disable teams " ) ;
return ;
2011-02-02 10:49:19 +00:00
}
2011-02-14 21:34:46 +00:00
else if ( g_Config . m_SvTeam = = 2 )
2011-02-02 10:49:19 +00:00
{
2010-11-13 15:31:13 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " You must join to any team and play with anybody or you will not play " ) ;
}
2011-02-08 12:52:23 +00:00
CPlayer * pPlayer = pSelf - > m_apPlayers [ ClientID ] ;
2011-02-16 08:17:47 +00:00
if ( ! pPlayer )
return ;
2010-11-13 15:31:13 +00:00
if ( pResult - > NumArguments ( ) > 0 )
{
2011-02-02 10:49:19 +00:00
int Team = pResult - > GetInteger ( 0 ) ;
2010-11-13 15:31:13 +00:00
if ( pPlayer - > GetCharacter ( ) = = 0 )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " You can't change teams while you are dead/a spectator. " ) ;
}
else
{
2011-02-02 10:49:19 +00:00
if ( pPlayer - > m_Last_Team + pSelf - > Server ( ) - > TickSpeed ( ) * g_Config . m_SvTeamChangeDelay < = pSelf - > Server ( ) - > Tick ( ) )
2011-01-24 20:22:04 +00:00
{
2011-02-02 10:49:19 +00:00
if ( Controller - > m_Teams . GetTeamLeader ( Team ) = = - 1 )
switch ( Controller - > m_Teams . SetCharacterTeam ( pPlayer - > GetCID ( ) , Team ) )
{
case 0 :
char aBuf [ 512 ] ;
pPlayer - > m_Last_Team = pSelf - > Server ( ) - > Tick ( ) ;
break ;
case CGameTeams : : ERROR_ALREADY_THERE :
str_format ( aBuf , sizeof ( aBuf ) , " You are already in team %d...! " , Team ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , aBuf ) ;
break ;
case CGameTeams : : ERROR_CLOSED :
str_format ( aBuf , sizeof ( aBuf ) , " Team %d is closed, they have to kill or finish for u to join. " , Team ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , aBuf ) ;
break ;
case CGameTeams : : ERROR_NOT_SUPER :
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " You are trying to join team Super but you are not super. " ) ;
break ;
case CGameTeams : : ERROR_STARTED :
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " You already started, kill first. " ) ;
break ;
case CGameTeams : : ERROR_WRONG_PARAMS :
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " The wrong parameters were given. " ) ;
break ;
default :
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " You cannot join this team at this time " ) ;
}
2011-01-26 21:09:54 +00:00
else
{
2011-02-02 10:49:19 +00:00
char aBuf [ 512 ] ;
str_format ( aBuf , sizeof ( aBuf ) , " Team %d is led by \' %s \' , please ask him to join his team. " , Team , pSelf - > Server ( ) - > ClientName ( Controller - > m_Teams . GetTeamLeader ( Team ) ) ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , aBuf ) ;
2011-01-26 21:09:54 +00:00
}
2010-11-13 15:31:13 +00:00
}
else
{
2011-02-02 10:49:19 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " You can \' t change teams that fast! " ) ;
2010-11-13 15:31:13 +00:00
}
}
}
else
{
char aBuf [ 512 ] ;
if ( pPlayer - > GetCharacter ( ) = = 0 )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " You can't check your team while you are dead/a spectator. " ) ;
}
else
{
str_format ( aBuf , sizeof ( aBuf ) , " You are in team %d " , pPlayer - > GetCharacter ( ) - > Team ( ) ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , aBuf ) ;
}
}
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConToggleFly ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-02-16 08:17:47 +00:00
CPlayer * pPlayer = pSelf - > m_apPlayers [ ClientID ] ;
if ( ! pPlayer )
return ;
CCharacter * pChr = pPlayer - > GetCharacter ( ) ;
if ( ! pChr )
return ;
if ( pChr - > m_Super )
2010-11-13 15:31:13 +00:00
{
pChr - > m_Fly = ! pChr - > m_Fly ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , ( pChr - > m_Fly ) ? " Fly enabled " : " Fly disabled " ) ;
}
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConMe ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
char aBuf [ 256 + 24 ] ;
2011-02-13 04:45:17 +00:00
2011-02-08 12:52:23 +00:00
str_format ( aBuf , 256 + 24 , " '%s' %s " , pSelf - > Server ( ) - > ClientName ( ClientID ) , pResult - > GetString ( 0 ) ) ;
2010-12-03 01:05:56 +00:00
if ( g_Config . m_SvSlashMe )
2011-02-08 12:52:23 +00:00
pSelf - > SendChat ( - 2 , CGameContext : : CHAT_ALL , aBuf , ClientID ) ;
2010-12-03 01:05:56 +00:00
else
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " /me is disabled on this server, admin can enable it by using sv_slash_me " ) ;
2010-11-13 15:31:13 +00:00
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConToggleEyeEmote ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-02-16 08:17:47 +00:00
CPlayer * pPlayer = pSelf - > m_apPlayers [ ClientID ] ;
if ( ! pPlayer )
return ;
CCharacter * pChr = pPlayer - > GetCharacter ( ) ;
if ( ! pChr )
return ;
2011-02-13 04:45:17 +00:00
2011-02-16 08:17:47 +00:00
pChr - > m_EyeEmote = ! pChr - > m_EyeEmote ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , ( pChr - > m_EyeEmote ) ? " You can now use the preset eye emotes. " : " You don't have any eye emotes, remember to bind some. (until you die) " ) ;
2010-11-13 15:31:13 +00:00
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConToggleBroadcast ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-02-16 08:17:47 +00:00
CPlayer * pPlayer = pSelf - > m_apPlayers [ ClientID ] ;
if ( ! pPlayer )
return ;
CCharacter * pChr = pPlayer - > GetCharacter ( ) ;
if ( ! pChr )
return ;
2011-02-13 04:45:17 +00:00
2011-02-16 08:17:47 +00:00
pChr - > m_BroadCast = ! pChr - > m_BroadCast ;
2010-11-13 15:31:13 +00:00
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConEyeEmote ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2010-11-13 15:31:13 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-02-16 08:17:47 +00:00
CPlayer * pPlayer = pSelf - > m_apPlayers [ ClientID ] ;
if ( ! pPlayer )
return ;
CCharacter * pChr = pPlayer - > GetCharacter ( ) ;
if ( ! pChr )
return ;
2011-02-13 04:45:17 +00:00
2010-11-13 15:31:13 +00:00
if ( pResult - > NumArguments ( ) = = 0 )
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Emote commands are: /emote surprise /emote blink /emote close /emote angry /emote happy /emote pain " ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Example: /emote surprise 10 for 10 seconds or /emote surprise (default 1 second) " ) ;
}
2011-02-13 04:45:17 +00:00
else
2010-11-13 15:31:13 +00:00
{
2011-02-13 04:45:17 +00:00
if ( pChr )
2010-11-13 15:31:13 +00:00
{
if ( ! str_comp ( pResult - > GetString ( 0 ) , " angry " ) )
2011-02-13 04:45:17 +00:00
pChr - > m_DefEmote = EMOTE_ANGRY ;
2010-11-13 15:31:13 +00:00
else if ( ! str_comp ( pResult - > GetString ( 0 ) , " blink " ) )
2011-02-13 04:45:17 +00:00
pChr - > m_DefEmote = EMOTE_BLINK ;
2010-11-13 15:31:13 +00:00
else if ( ! str_comp ( pResult - > GetString ( 0 ) , " close " ) )
2011-02-13 04:45:17 +00:00
pChr - > m_DefEmote = EMOTE_BLINK ;
2010-11-13 15:31:13 +00:00
else if ( ! str_comp ( pResult - > GetString ( 0 ) , " happy " ) )
2011-02-13 04:45:17 +00:00
pChr - > m_DefEmote = EMOTE_HAPPY ;
2010-11-13 15:31:13 +00:00
else if ( ! str_comp ( pResult - > GetString ( 0 ) , " pain " ) )
2011-02-13 04:45:17 +00:00
pChr - > m_DefEmote = EMOTE_PAIN ;
2010-11-13 15:31:13 +00:00
else if ( ! str_comp ( pResult - > GetString ( 0 ) , " surprise " ) )
2011-02-13 04:45:17 +00:00
pChr - > m_DefEmote = EMOTE_SURPRISE ;
2010-11-13 15:31:13 +00:00
else
{
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Unkown emote... Say /emote " ) ;
}
2011-02-13 04:45:17 +00:00
2010-11-13 15:31:13 +00:00
int Duration = 1 ;
if ( pResult - > NumArguments ( ) > 1 )
Duration = pResult - > GetInteger ( 1 ) ;
2011-02-13 04:45:17 +00:00
2011-01-07 22:26:28 +00:00
pChr - > m_DefEmoteReset = pSelf - > Server ( ) - > Tick ( ) + Duration * pSelf - > Server ( ) - > TickSpeed ( ) ;
2010-11-13 15:31:13 +00:00
}
}
}
2011-01-06 05:08:12 +00:00
2011-02-08 12:52:23 +00:00
void CGameContext : : ConShowOthers ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2011-01-06 05:08:12 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-02-16 08:17:47 +00:00
CPlayer * pPlayer = pSelf - > m_apPlayers [ ClientID ] ;
if ( ! pPlayer )
return ;
2011-01-06 05:08:12 +00:00
2011-02-16 08:17:47 +00:00
if ( pPlayer - > m_IsUsingDDRaceClient )
pPlayer - > m_ShowOthers = ! pPlayer - > m_ShowOthers ;
2011-01-06 05:08:12 +00:00
else
2011-02-05 04:47:49 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Showing players from other teams is only available with DDRace Client, http://DDRace.info " ) ;
2011-01-06 05:08:12 +00:00
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConAsk ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2011-02-02 10:49:19 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
char aBuf [ 512 ] ;
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
const char * Name = pResult - > GetString ( 0 ) ;
int Matches = 0 ;
int Victim = - 1 ;
2011-02-16 08:17:47 +00:00
CPlayer * pPlayer = pSelf - > m_apPlayers [ ClientID ] ;
if ( ! pPlayer )
return ;
CCharacter * pAsker = pPlayer - > GetCharacter ( ) ;
2011-02-05 01:33:53 +00:00
CCharacter * pVictim = 0 ;
2011-02-02 10:49:19 +00:00
for ( int i = 0 ; i < MAX_CLIENTS ; i + + )
{
2011-02-08 12:52:23 +00:00
if ( pSelf - > m_apPlayers [ i ] & & i ! = ClientID & & ! str_comp_nocase ( pServ - > ClientName ( i ) , Name ) )
2011-02-02 10:49:19 +00:00
{
Victim = i ;
pVictim = pSelf - > m_apPlayers [ i ] - > GetCharacter ( ) ;
Matches = 1 ;
2011-02-05 04:47:49 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Exact Match found " ) ;
2011-02-02 10:49:19 +00:00
break ;
}
2011-02-08 12:52:23 +00:00
else if ( pSelf - > m_apPlayers [ i ] & & i ! = ClientID & & str_find_nocase ( pServ - > ClientName ( i ) , Name ) )
2011-02-02 10:49:19 +00:00
{
Victim = i ;
pVictim = pSelf - > m_apPlayers [ i ] - > GetCharacter ( ) ;
Matches + + ;
}
}
if ( ! pAsker | | ! pAsker - > IsAlive ( ) )
str_format ( aBuf , sizeof ( aBuf ) , " You can \' t invite while dead. " ) ;
else if ( pAsker - > Team ( ) )
str_format ( aBuf , sizeof ( aBuf ) , " You already are in team %d, you can use /invite if you are the leader. " , pAsker - > Team ( ) ) ;
else if ( Matches > 1 )
str_format ( aBuf , sizeof ( aBuf ) , " More Than one player matches the given string, maybe use auto complete (tab in any 0.5 trunk client) " ) ;
else if ( Matches = = 0 )
str_format ( aBuf , sizeof ( aBuf ) , " No matches found. " ) ;
else if ( pAsker - > m_DDRaceState ! = DDRACE_NONE )
str_format ( aBuf , sizeof ( aBuf ) , " You can't start a team at this time, please kill. " ) ;
else if ( ! pVictim | | ! pVictim - > IsAlive ( ) )
str_format ( aBuf , sizeof ( aBuf ) , " You can \' t invite him while he is dead. " ) ;
else if ( pVictim - > m_DDRaceState ! = DDRACE_NONE )
str_format ( aBuf , sizeof ( aBuf ) , " He can't change teams at this time, please tell him to kill. " ) ;
else if ( pSelf - > m_apPlayers [ Victim ] - > m_Asker ! = - 1 & & pSelf - > m_apPlayers [ Victim ] - > m_AskedTick > pSelf - > Server ( ) - > Tick ( ) - g_Config . m_SvTeamAskTime )
str_format ( aBuf , sizeof ( aBuf ) , " \' %s \' is already being asked wait for %.1f seconds. " , pServ - > ClientName ( Victim ) , ( pSelf - > m_apPlayers [ Victim ] - > m_AskedTick + g_Config . m_SvTeamAskTime * pSelf - > Server ( ) - > TickSpeed ( ) - pSelf - > Server ( ) - > Tick ( ) ) / ( float ) pSelf - > Server ( ) - > TickSpeed ( ) ) ;
else if ( pSelf - > m_apPlayers [ Victim ] - > m_Asked ! = - 1 & & pSelf - > m_apPlayers [ Victim ] - > m_AskerTick > pSelf - > Server ( ) - > Tick ( ) - g_Config . m_SvTeamAskTime )
str_format ( aBuf , sizeof ( aBuf ) , " \' %s \' is already is asking someone wait for %.1f seconds. " , pServ - > ClientName ( Victim ) , ( pSelf - > m_apPlayers [ Victim ] - > m_AskedTick + g_Config . m_SvTeamAskTime * pSelf - > Server ( ) - > TickSpeed ( ) - pSelf - > Server ( ) - > Tick ( ) ) / ( float ) pSelf - > Server ( ) - > TickSpeed ( ) ) ;
else if ( ! pVictim - > Team ( ) )
{
2011-02-08 12:52:23 +00:00
pSelf - > m_apPlayers [ Victim ] - > m_Asker = ClientID ;
2011-02-02 10:49:19 +00:00
pSelf - > m_apPlayers [ Victim ] - > m_AskedTick = pSelf - > Server ( ) - > Tick ( ) ;
2011-02-08 12:52:23 +00:00
pSelf - > m_apPlayers [ ClientID ] - > m_Asked = Victim ;
pSelf - > m_apPlayers [ ClientID ] - > m_AskerTick = pSelf - > Server ( ) - > Tick ( ) ;
2011-02-02 10:49:19 +00:00
char aTempBuf [ 512 ] ;
2011-02-08 12:52:23 +00:00
str_format ( aTempBuf , sizeof ( aTempBuf ) , " Do you want to start a team with \' %s \' as leader ? " , pServ - > ClientName ( ClientID ) ) ;
2011-02-02 10:49:19 +00:00
pSelf - > SendChatTarget ( Victim , aTempBuf ) ;
str_format ( aTempBuf , sizeof ( aTempBuf ) , " Please say /yes or /no within %d seconds. " , g_Config . m_SvTeamAskTime ) ;
pSelf - > SendChatTarget ( Victim , aTempBuf ) ;
str_format ( aBuf , sizeof ( aBuf ) , " \' %s \' has been asked to start a team with you as leader. " , pServ - > ClientName ( Victim ) ) ;
}
else if ( pVictim - > Team ( ) & & pAsker - > Teams ( ) - > GetTeamLeader ( pVictim - > Team ( ) ) ! = Victim )
{
str_format ( aBuf , sizeof ( aBuf ) , " You can't ask a team member you can only ask a team leader, Team %d is led by \' %s \' . " , pVictim - > Team ( ) , pServ - > ClientName ( Victim ) ) ;
}
else if ( pVictim - > Team ( ) & & pAsker - > Teams ( ) - > GetTeamState ( pVictim - > Team ( ) ) = = CGameTeams : : TEAMSTATE_OPEN )
{
2011-02-08 12:52:23 +00:00
pSelf - > m_apPlayers [ Victim ] - > m_Asker = ClientID ;
2011-02-02 10:49:19 +00:00
pSelf - > m_apPlayers [ Victim ] - > m_AskedTick = pSelf - > Server ( ) - > Tick ( ) ;
2011-02-08 12:52:23 +00:00
pSelf - > m_apPlayers [ ClientID ] - > m_Asked = Victim ;
pSelf - > m_apPlayers [ ClientID ] - > m_AskerTick = pSelf - > Server ( ) - > Tick ( ) ;
2011-02-02 10:49:19 +00:00
char aTempBuf [ 512 ] ;
2011-02-08 12:52:23 +00:00
str_format ( aTempBuf , sizeof ( aTempBuf ) , " %s wants to join your team ? " , pServ - > ClientName ( ClientID ) ) ;
2011-02-02 10:49:19 +00:00
pSelf - > SendChatTarget ( Victim , aTempBuf ) ;
str_format ( aTempBuf , sizeof ( aTempBuf ) , " Please say /yes or /no within %d seconds. " , g_Config . m_SvTeamAskTime ) ;
pSelf - > SendChatTarget ( Victim , aTempBuf ) ;
str_format ( aBuf , sizeof ( aBuf ) , " You asked to join %s \' s team %d. " , pServ - > ClientName ( Victim ) , pVictim - > Team ( ) ) ;
}
else
str_format ( aBuf , sizeof ( aBuf ) , " hmm, i don't know why but you are not allowed to ask this player " ) ;
2011-02-05 04:47:49 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , aBuf ) ;
2011-02-02 10:49:19 +00:00
return ;
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConYes ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2011-02-02 10:49:19 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
CGameControllerDDRace * Controller = ( CGameControllerDDRace * ) pSelf - > m_pController ;
char aBuf [ 512 ] ;
2011-02-16 08:17:47 +00:00
if ( pSelf - > m_apPlayers [ ClientID ] - > m_Asker = = - 1 | | ( pSelf - > m_apPlayers [ ClientID ] - > m_Asker ! = - 1 & & pSelf - > m_apPlayers [ ClientID ] - > m_AskedTick + g_Config . m_SvTeamAskTime * pSelf - > Server ( ) - > TickSpeed ( ) < pSelf - > Server ( ) - > Tick ( ) ) )
2011-02-13 20:21:17 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Couldn't find a valid question, maybe it timed out. " ) ;
2011-02-02 10:49:19 +00:00
else
{
2011-02-08 12:52:23 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " \' %s \' has accepted your request. " , pServ - > ClientName ( ClientID ) ) ;
pSelf - > SendChatTarget ( pSelf - > m_apPlayers [ ClientID ] - > m_Asker , aBuf ) ;
if ( pSelf - > m_apPlayers [ pSelf - > m_apPlayers [ ClientID ] - > m_Asker ] - > GetCharacter ( ) - > Team ( ) ! = 0 )
2011-02-02 10:49:19 +00:00
{
2011-02-08 12:52:23 +00:00
Controller - > m_Teams . SetCharacterTeam ( ClientID , pSelf - > m_apPlayers [ pSelf - > m_apPlayers [ ClientID ] - > m_Asker ] - > GetCharacter ( ) - > Team ( ) ) ;
2011-02-02 10:49:19 +00:00
}
2011-02-08 12:52:23 +00:00
else if ( pSelf - > m_apPlayers [ ClientID ] - > GetCharacter ( ) - > Team ( ) ! = 0 )
2011-02-02 10:49:19 +00:00
{
2011-02-08 12:52:23 +00:00
Controller - > m_Teams . SetCharacterTeam ( pSelf - > m_apPlayers [ ClientID ] - > m_Asker , pSelf - > m_apPlayers [ ClientID ] - > GetCharacter ( ) - > Team ( ) ) ;
str_format ( aBuf , sizeof ( aBuf ) , " \' %s \' joined team %d. " , pServ - > ClientName ( pSelf - > m_apPlayers [ ClientID ] - > m_Asker ) , pSelf - > m_apPlayers [ ClientID ] - > GetCharacter ( ) - > Team ( ) ) ;
2011-02-02 10:49:19 +00:00
pSelf - > SendChat ( - 1 , CGameContext : : CHAT_ALL , aBuf ) ;
}
else
for ( int i = 1 ; i < MAX_CLIENTS ; + + i )
{
if ( Controller - > m_Teams . GetTeamState ( i ) = = CGameTeams : : TEAMSTATE_EMPTY )
{
2011-02-08 12:52:23 +00:00
Controller - > m_Teams . SetCharacterTeam ( pSelf - > m_apPlayers [ ClientID ] - > m_Asker , i ) ;
Controller - > m_Teams . SetCharacterTeam ( ClientID , i ) ;
Controller - > m_Teams . SetTeamLeader ( i , pSelf - > m_apPlayers [ ClientID ] - > m_Asker ) ;
2011-02-02 10:49:19 +00:00
return ;
}
}
}
/*
2011-02-08 12:52:23 +00:00
if ( pSelf - > m_apPlayers [ ClientID ] - > m_Asker ! = - 1 & & pSelf - > m_apPlayers [ pSelf - > m_apPlayers [ ClientID ] - > m_Asker ] - > m_Asked = = ClientID )
2011-02-02 10:49:19 +00:00
{
2011-02-08 12:52:23 +00:00
pSelf - > m_apPlayers [ pSelf - > m_apPlayers [ ClientID ] - > m_Asker ] - > m_Asked = - 1 ;
pSelf - > m_apPlayers [ pSelf - > m_apPlayers [ ClientID ] - > m_Asker ] - > m_AskerTick = - g_Config . m_SvTeamAskTime ;
2011-02-02 10:49:19 +00:00
}
2011-02-08 12:52:23 +00:00
pSelf - > m_apPlayers [ ClientID ] - > m_Asker = - 1 ;
pSelf - > m_apPlayers [ ClientID ] - > m_AskedTick = - g_Config . m_SvTeamAskTime ;
2011-02-02 10:49:19 +00:00
*/
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConNo ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2011-02-02 10:49:19 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
char aBuf [ 512 ] ;
2011-02-16 08:17:47 +00:00
if ( pSelf - > m_apPlayers [ ClientID ] - > m_Asker = = - 1 | | ( pSelf - > m_apPlayers [ ClientID ] - > m_Asker ! = - 1 & & pSelf - > m_apPlayers [ ClientID ] - > m_AskedTick + g_Config . m_SvTeamAskTime * pSelf - > Server ( ) - > TickSpeed ( ) < pSelf - > Server ( ) - > Tick ( ) ) )
2011-02-13 20:21:17 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Couldn't find a valid question, maybe it timed out. " ) ;
2011-02-02 10:49:19 +00:00
else
{
2011-02-08 12:52:23 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " \' %s \' has rejected your request. " , pServ - > ClientName ( ClientID ) ) ;
pSelf - > SendChatTarget ( pSelf - > m_apPlayers [ ClientID ] - > m_Asker , aBuf ) ;
2011-02-02 10:49:19 +00:00
}
/*
2011-02-08 12:52:23 +00:00
if ( pSelf - > m_apPlayers [ ClientID ] - > m_Asker ! = - 1 & & pSelf - > m_apPlayers [ pSelf - > m_apPlayers [ ClientID ] - > m_Asker ] - > m_Asked = = ClientID )
2011-02-02 10:49:19 +00:00
{
2011-02-08 12:52:23 +00:00
pSelf - > m_apPlayers [ pSelf - > m_apPlayers [ ClientID ] - > m_Asker ] - > m_Asked = - 1 ;
pSelf - > m_apPlayers [ pSelf - > m_apPlayers [ ClientID ] - > m_Asker ] - > m_AskerTick = - g_Config . m_SvTeamAskTime ;
2011-02-02 10:49:19 +00:00
}
2011-02-08 12:52:23 +00:00
pSelf - > m_apPlayers [ ClientID ] - > m_Asker = - 1 ;
pSelf - > m_apPlayers [ ClientID ] - > m_AskedTick = - g_Config . m_SvTeamAskTime ;
2011-02-02 10:49:19 +00:00
*/
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConInvite ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2011-02-02 10:49:19 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
CServer * pServ = ( CServer * ) pSelf - > Server ( ) ;
CGameControllerDDRace * Controller = ( CGameControllerDDRace * ) pSelf - > m_pController ;
char aBuf [ 512 ] ;
const char * Name = pResult - > GetString ( 0 ) ;
int Matches = 0 ;
int Victim = - 1 ;
2011-02-16 08:17:47 +00:00
CPlayer * pPlayer = pSelf - > m_apPlayers [ ClientID ] ;
if ( ! pPlayer )
return ;
CCharacter * pAsker = pPlayer - > GetCharacter ( ) ;
2011-02-05 01:33:53 +00:00
CCharacter * pVictim = 0 ;
2011-02-02 10:49:19 +00:00
for ( int i = 0 ; i < MAX_CLIENTS ; i + + )
{
2011-02-08 12:52:23 +00:00
if ( pSelf - > m_apPlayers [ i ] & & i ! = ClientID & & ! str_comp_nocase ( pServ - > ClientName ( i ) , Name ) )
2011-02-02 10:49:19 +00:00
{
Victim = i ;
pVictim = pSelf - > m_apPlayers [ i ] - > GetCharacter ( ) ;
Matches = 1 ;
2011-02-05 04:47:49 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , " Exact Match found " ) ;
2011-02-02 10:49:19 +00:00
break ;
}
2011-02-08 12:52:23 +00:00
else if ( pSelf - > m_apPlayers [ i ] & & i ! = ClientID & & str_find_nocase ( pServ - > ClientName ( i ) , Name ) )
2011-02-02 10:49:19 +00:00
{
Victim = i ;
pVictim = pSelf - > m_apPlayers [ i ] - > GetCharacter ( ) ;
Matches + + ;
}
}
if ( ! pAsker | | ! pAsker - > IsAlive ( ) )
str_format ( aBuf , sizeof ( aBuf ) , " You can \' t invite while dead. " ) ;
else if ( pAsker - > Team ( ) = = 0 )
2011-02-08 12:44:59 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " You are in team %d, use /ask. " , pAsker - > Team ( ) ) ;
2011-02-08 12:52:23 +00:00
else if ( pAsker - > Team ( ) & & ClientID ! = Controller - > m_Teams . GetTeamLeader ( pAsker - > Team ( ) ) )
2011-02-02 10:49:19 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " You already are in team %d, but not leader. " , pAsker - > Team ( ) ) ;
else if ( Matches > 1 )
str_format ( aBuf , sizeof ( aBuf ) , " More Than one player matches the given string, maybe use auto complete (tab in any 0.5 trunk client) " ) ;
else if ( Matches = = 0 )
str_format ( aBuf , sizeof ( aBuf ) , " No matches found. " ) ;
else if ( Controller - > m_Teams . GetTeamState ( pAsker - > Team ( ) ) ! = CGameTeams : : TEAMSTATE_OPEN )
str_format ( aBuf , sizeof ( aBuf ) , " You can't invite anyone at this time, your team is closed. " ) ;
else if ( ! pVictim | | ! pVictim - > IsAlive ( ) )
str_format ( aBuf , sizeof ( aBuf ) , " You can \' t invite him while he is dead. " ) ;
else if ( pVictim - > m_DDRaceState ! = DDRACE_NONE )
str_format ( aBuf , sizeof ( aBuf ) , " He can't change teams at this time, please tell him to kill. " ) ;
else if ( pSelf - > m_apPlayers [ Victim ] - > m_Asker ! = - 1 & & pSelf - > m_apPlayers [ Victim ] - > m_AskedTick > pSelf - > Server ( ) - > Tick ( ) - g_Config . m_SvTeamAskTime )
str_format ( aBuf , sizeof ( aBuf ) , " \' %s \' is already being asked wait for %.1f seconds. " , pServ - > ClientName ( Victim ) , ( pSelf - > m_apPlayers [ Victim ] - > m_AskedTick + g_Config . m_SvTeamAskTime * pSelf - > Server ( ) - > TickSpeed ( ) - pSelf - > Server ( ) - > Tick ( ) ) / ( float ) pSelf - > Server ( ) - > TickSpeed ( ) ) ;
else if ( pSelf - > m_apPlayers [ Victim ] - > m_Asked ! = - 1 & & pSelf - > m_apPlayers [ Victim ] - > m_AskerTick > pSelf - > Server ( ) - > Tick ( ) - g_Config . m_SvTeamAskTime )
str_format ( aBuf , sizeof ( aBuf ) , " \' %s \' is already is asking someone wait for %.1f seconds. " , pServ - > ClientName ( Victim ) , ( pSelf - > m_apPlayers [ Victim ] - > m_AskedTick + g_Config . m_SvTeamAskTime * pSelf - > Server ( ) - > TickSpeed ( ) - pSelf - > Server ( ) - > Tick ( ) ) / ( float ) pSelf - > Server ( ) - > TickSpeed ( ) ) ;
else if ( ! pVictim - > Team ( ) )
{
2011-02-08 12:52:23 +00:00
pSelf - > m_apPlayers [ Victim ] - > m_Asker = ClientID ;
2011-02-02 10:49:19 +00:00
pSelf - > m_apPlayers [ Victim ] - > m_AskedTick = pSelf - > Server ( ) - > Tick ( ) ;
2011-02-16 08:17:47 +00:00
pPlayer - > m_Asked = Victim ;
pPlayer - > m_AskerTick = pSelf - > Server ( ) - > Tick ( ) ;
2011-02-02 10:49:19 +00:00
char aTempBuf [ 512 ] ;
2011-02-08 12:52:23 +00:00
str_format ( aTempBuf , sizeof ( aTempBuf ) , " Do you want to join \' %s \' \' s team? " , pServ - > ClientName ( ClientID ) ) ;
2011-02-02 10:49:19 +00:00
pSelf - > SendChatTarget ( Victim , aTempBuf ) ;
str_format ( aTempBuf , sizeof ( aTempBuf ) , " Please say /yes or /no within %d seconds. " , g_Config . m_SvTeamAskTime ) ;
pSelf - > SendChatTarget ( Victim , aTempBuf ) ;
str_format ( aBuf , sizeof ( aBuf ) , " \' %s \' has been asked to join your team. " , pServ - > ClientName ( Victim ) ) ;
}
else
str_format ( aBuf , sizeof ( aBuf ) , " hmm, i don't know why but you are not allowed to ask this player " ) ;
2011-02-05 04:47:49 +00:00
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , aBuf ) ;
2011-02-02 10:49:19 +00:00
return ;
}
2011-02-08 12:44:59 +00:00
2011-02-14 21:34:46 +00:00
void CGameContext : : ConToggleStrict ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
CGameControllerDDRace * Controller = ( CGameControllerDDRace * ) pSelf - > m_pController ;
2011-02-16 08:17:47 +00:00
CPlayer * pPlayer = pSelf - > m_apPlayers [ ClientID ] ;
if ( ! pPlayer )
return ;
CCharacter * pChr = pPlayer - > GetCharacter ( ) ;
if ( ! pChr )
return ;
2011-02-14 21:34:46 +00:00
char aBuf [ 512 ] ;
2011-02-16 08:17:47 +00:00
if ( ! pChr | | ! pChr - > IsAlive ( ) )
2011-02-14 21:34:46 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " You can \' t while you are dead. " ) ;
2011-02-16 08:17:47 +00:00
else if ( pChr - > Team ( ) = = 0 )
str_format ( aBuf , sizeof ( aBuf ) , " You are in team %d, that can't be strict! " , pChr - > Team ( ) ) ;
else if ( pChr - > Team ( ) & & ClientID ! = Controller - > m_Teams . GetTeamLeader ( pChr - > Team ( ) ) )
str_format ( aBuf , sizeof ( aBuf ) , " You are not the leader of team %, you can't change it's strictness. " , pChr - > Team ( ) ) ;
2011-02-14 21:34:46 +00:00
else
{
2011-02-16 08:17:47 +00:00
Controller - > m_Teams . ToggleStrictness ( pChr - > Team ( ) ) ;
str_format ( aBuf , sizeof ( aBuf ) , " Done. " , pChr - > Team ( ) ) ;
2011-02-14 21:34:46 +00:00
}
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " info " , aBuf ) ;
return ;
}
2011-02-08 12:44:59 +00:00
void CGameContext : : Mute ( const char * pIP , int Secs , const char * pDisplayName )
{
char aBuf [ 128 ] ;
// purge expired mutes first
for ( int z = 0 ; z < MAX_MUTES ; + + z )
if ( m_aMutes [ z ] . m_IP [ 0 ] & & m_aMutes [ z ] . m_Expire < = Server ( ) - > Tick ( ) )
m_aMutes [ z ] . m_IP [ 0 ] = 0 ;
int FoundInd = - 1 ;
// find a matching mute for this ip, update expiration time if found
for ( int z = 0 ; z < MAX_MUTES ; + + z )
if ( m_aMutes [ z ] . m_IP [ 0 ] & & str_comp ( m_aMutes [ z ] . m_IP , pIP ) = = 0 )
m_aMutes [ FoundInd = z ] . m_Expire = Server ( ) - > Tick ( ) + Secs * Server ( ) - > TickSpeed ( ) ;
if ( FoundInd = = - 1 ) // nothing found so far, find a free slot..
for ( int z = 0 ; z < MAX_MUTES ; + + z ) //..in order to add a new mute
if ( ! m_aMutes [ z ] . m_IP [ 0 ] )
{
str_copy ( m_aMutes [ z ] . m_IP , pIP , str_length ( pIP ) + 1 ) ;
m_aMutes [ FoundInd = z ] . m_Expire = Server ( ) - > Tick ( ) + Secs * Server ( ) - > TickSpeed ( ) ;
break ;
}
if ( FoundInd ! = - 1 )
{
str_format ( aBuf , sizeof aBuf , " '%s' has been muted for %d seconds. " , pDisplayName , Secs ) ;
SendChat ( - 1 , CHAT_ALL , aBuf ) ;
}
else // no free slot found
Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " server " , " mute array is full " ) ;
}
2011-02-08 12:52:23 +00:00
void CGameContext : : ConMute ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2011-02-08 12:44:59 +00:00
{
( ( CGameContext * ) pUserData ) - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " server " , " Use either 'muteid <client_id> <seconds>' or 'muteip <ip> <seconds>' " ) ;
}
// mute through client id
void CGameContext : : ConMuteID ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
2011-02-08 12:52:23 +00:00
int Victim = pResult - > GetVictim ( ) ;
if ( Victim < 0 | | Victim > = MAX_CLIENTS | | ! pSelf - > m_apPlayers [ Victim ] )
2011-02-08 12:44:59 +00:00
return ;
char aIP [ 16 ] ;
2011-02-08 12:52:23 +00:00
pSelf - > Server ( ) - > GetClientIP ( Victim , aIP , sizeof aIP ) ;
2011-02-08 12:44:59 +00:00
2011-02-08 12:52:23 +00:00
pSelf - > Mute ( aIP , clamp ( pResult - > GetInteger ( 0 ) , 1 , 60 * 60 * 24 * 365 ) , pSelf - > Server ( ) - > ClientName ( Victim ) ) ;
2011-02-08 12:44:59 +00:00
}
// mute through ip, arguments reversed to workaround parsing
2011-02-08 12:52:23 +00:00
void CGameContext : : ConMuteIP ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
2011-02-08 12:44:59 +00:00
{
CGameContext * pSelf = ( CGameContext * ) pUserData ;
pSelf - > Mute ( pResult - > GetString ( 0 ) , clamp ( pResult - > GetInteger ( 1 ) , 1 , 60 * 60 * 24 * 365 ) , pResult - > GetString ( 0 ) ) ;
}
// unmute by mute list index
void CGameContext : : ConUnmute ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
{
char aBuf [ 32 ] ;
CGameContext * pSelf = ( CGameContext * ) pUserData ;
int Ind = pResult - > GetInteger ( 0 ) ;
if ( Ind < 0 | | Ind > = MAX_MUTES | | ! m_aMutes [ Ind ] . m_IP [ 0 ] )
return ;
str_format ( aBuf , sizeof aBuf , " Unmuted %s " , m_aMutes [ Ind ] . m_IP ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " server " , aBuf ) ;
m_aMutes [ Ind ] . m_IP [ 0 ] = 0 ;
}
// list mutes
void CGameContext : : ConMutes ( IConsole : : IResult * pResult , void * pUserData , int ClientID )
{
char aBuf [ 128 ] ;
CGameContext * pSelf = ( CGameContext * ) pUserData ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " server " , " Active mutes: " ) ;
for ( int z = 0 ; z < MAX_MUTES ; + + z )
if ( m_aMutes [ z ] . m_IP [ 0 ] )
{
int Exp = ( m_aMutes [ z ] . m_Expire - pSelf - > Server ( ) - > Tick ( ) ) / pSelf - > Server ( ) - > TickSpeed ( ) ;
if ( Exp > 0 )
str_format ( aBuf , sizeof aBuf , " %d: \" %s \" , %d seconds left " , z , m_aMutes [ z ] . m_IP , Exp ) ;
else
str_format ( aBuf , sizeof aBuf , " %d: \" %s \" , expired (pending) " , z , m_aMutes [ z ] . m_IP ) ;
pSelf - > Console ( ) - > PrintResponse ( IConsole : : OUTPUT_LEVEL_STANDARD , " server " , aBuf ) ;
}
}