2015-09-30 03:49:22 +03:00
# include "precompiled.h"
2017-10-12 17:50:56 +03:00
int gmsgWeapPickup = 0 ;
int gmsgHudText = 0 ;
2017-10-19 20:12:02 +03:00
int gmsgHudTextPro = 0 ;
2017-10-12 17:50:56 +03:00
int gmsgHudTextArgs = 0 ;
int gmsgShake = 0 ;
int gmsgFade = 0 ;
int gmsgFlashlight = 0 ;
int gmsgFlashBattery = 0 ;
int gmsgResetHUD = 0 ;
int gmsgInitHUD = 0 ;
int gmsgViewMode = 0 ;
int gmsgShowGameTitle = 0 ;
int gmsgCurWeapon = 0 ;
int gmsgHealth = 0 ;
int gmsgDamage = 0 ;
int gmsgBattery = 0 ;
int gmsgTrain = 0 ;
int gmsgLogo = 0 ;
int gmsgWeaponList = 0 ;
int gmsgAmmoX = 0 ;
int gmsgDeathMsg = 0 ;
int gmsgScoreAttrib = 0 ;
int gmsgScoreInfo = 0 ;
int gmsgTeamInfo = 0 ;
int gmsgTeamScore = 0 ;
int gmsgGameMode = 0 ;
int gmsgMOTD = 0 ;
int gmsgServerName = 0 ;
int gmsgAmmoPickup = 0 ;
int gmsgItemPickup = 0 ;
int gmsgHideWeapon = 0 ;
int gmsgSayText = 0 ;
int gmsgTextMsg = 0 ;
int gmsgSetFOV = 0 ;
int gmsgShowMenu = 0 ;
int gmsgSendAudio = 0 ;
int gmsgRoundTime = 0 ;
int gmsgMoney = 0 ;
int gmsgBlinkAcct = 0 ;
int gmsgArmorType = 0 ;
int gmsgStatusValue = 0 ;
int gmsgStatusText = 0 ;
int gmsgStatusIcon = 0 ;
int gmsgBarTime = 0 ;
int gmsgReloadSound = 0 ;
int gmsgCrosshair = 0 ;
int gmsgNVGToggle = 0 ;
int gmsgRadar = 0 ;
int gmsgSpectator = 0 ;
int gmsgVGUIMenu = 0 ;
int gmsgCZCareer = 0 ;
int gmsgCZCareerHUD = 0 ;
int gmsgTaskTime = 0 ;
int gmsgTutorText = 0 ;
int gmsgTutorLine = 0 ;
int gmsgShadowIdx = 0 ;
int gmsgTutorState = 0 ;
int gmsgTutorClose = 0 ;
int gmsgAllowSpec = 0 ;
int gmsgBombDrop = 0 ;
int gmsgBombPickup = 0 ;
int gmsgHostagePos = 0 ;
int gmsgHostageK = 0 ;
int gmsgGeigerRange = 0 ;
int gmsgSendCorpse = 0 ;
int gmsgHLTV = 0 ;
int gmsgSpecHealth = 0 ;
int gmsgForceCam = 0 ;
int gmsgADStop = 0 ;
int gmsgReceiveW = 0 ;
int gmsgScenarioIcon = 0 ;
int gmsgBotVoice = 0 ;
int gmsgBuyClose = 0 ;
int gmsgItemStatus = 0 ;
int gmsgLocation = 0 ;
int gmsgSpecHealth2 = 0 ;
int gmsgBarTime2 = 0 ;
int gmsgBotProgress = 0 ;
int gmsgBrass = 0 ;
int gmsgFog = 0 ;
int gmsgShowTimer = 0 ;
2019-06-04 17:41:30 +03:00
int gmsgAccount = 0 ;
int gmsgHealthInfo = 0 ;
2015-09-30 03:49:22 +03:00
bool g_bClientPrintEnable = true ;
char * sPlayerModelFiles [ ] =
{
" models/player.mdl " ,
" models/player/leet/leet.mdl " ,
" models/player/gign/gign.mdl " ,
" models/player/vip/vip.mdl " ,
" models/player/gsg9/gsg9.mdl " ,
" models/player/guerilla/guerilla.mdl " ,
" models/player/arctic/arctic.mdl " ,
" models/player/sas/sas.mdl " ,
" models/player/terror/terror.mdl " ,
" models/player/urban/urban.mdl " ,
2017-10-12 17:50:56 +03:00
" models/player/spetsnaz/spetsnaz.mdl " , // CZ
" models/player/militia/militia.mdl " // CZ
2015-09-30 03:49:22 +03:00
} ;
2015-12-05 22:40:30 +03:00
bool g_skipCareerInitialSpawn = false ;
2015-09-30 03:49:22 +03:00
static entity_field_alias_t entity_field_alias [ ] =
{
2017-10-12 17:50:56 +03:00
{ " origin[0] " , 0 } ,
{ " origin[1] " , 0 } ,
{ " origin[2] " , 0 } ,
{ " angles[0] " , 0 } ,
{ " angles[1] " , 0 } ,
{ " angles[2] " , 0 } ,
2015-09-30 03:49:22 +03:00
} ;
static entity_field_alias_t player_field_alias [ ] =
{
2017-10-12 17:50:56 +03:00
{ " origin[0] " , 0 } ,
{ " origin[1] " , 0 } ,
{ " origin[2] " , 0 } ,
2015-12-05 22:40:30 +03:00
} ;
2015-09-30 03:49:22 +03:00
static entity_field_alias_t custom_entity_field_alias [ ] =
{
2017-10-12 17:50:56 +03:00
{ " origin[0] " , 0 } ,
{ " origin[1] " , 0 } ,
{ " origin[2] " , 0 } ,
{ " angles[0] " , 0 } ,
{ " angles[1] " , 0 } ,
{ " angles[2] " , 0 } ,
{ " skin " , 0 } ,
{ " sequence " , 0 } ,
{ " animtime " , 0 } ,
2015-12-05 22:40:30 +03:00
} ;
2015-09-30 03:49:22 +03:00
2016-10-05 18:27:50 +03:00
bool g_bServerActive = false ;
2020-06-25 15:30:12 +03:00
bool g_bItemCreatedByBuying = false ;
2015-12-09 01:39:54 +03:00
PLAYERPVSSTATUS g_PVSStatus [ MAX_CLIENTS ] ;
2015-09-30 03:49:22 +03:00
unsigned short m_usResetDecals ;
unsigned short g_iShadowSprite ;
2017-10-12 17:50:56 +03:00
void LinkUserMessages ( )
{
if ( gmsgCurWeapon )
return ;
2017-10-19 20:12:02 +03:00
gmsgCurWeapon = REG_USER_MSG ( " CurWeapon " , 3 ) ;
gmsgGeigerRange = REG_USER_MSG ( " Geiger " , 1 ) ;
gmsgFlashlight = REG_USER_MSG ( " Flashlight " , 2 ) ;
gmsgFlashBattery = REG_USER_MSG ( " FlashBat " , 1 ) ;
gmsgHealth = REG_USER_MSG ( " Health " , 1 ) ;
gmsgDamage = REG_USER_MSG ( " Damage " , 12 ) ;
gmsgBattery = REG_USER_MSG ( " Battery " , 2 ) ;
gmsgTrain = REG_USER_MSG ( " Train " , 1 ) ;
gmsgHudTextPro = REG_USER_MSG ( " HudTextPro " , - 1 ) ;
gmsgHudText = REG_USER_MSG ( " HudText " , - 1 ) ;
gmsgSayText = REG_USER_MSG ( " SayText " , - 1 ) ;
gmsgTextMsg = REG_USER_MSG ( " TextMsg " , - 1 ) ;
gmsgWeaponList = REG_USER_MSG ( " WeaponList " , - 1 ) ;
gmsgResetHUD = REG_USER_MSG ( " ResetHUD " , 0 ) ;
gmsgInitHUD = REG_USER_MSG ( " InitHUD " , 0 ) ;
gmsgViewMode = REG_USER_MSG ( " ViewMode " , 0 ) ;
2017-10-12 17:50:56 +03:00
gmsgShowGameTitle = REG_USER_MSG ( " GameTitle " , 1 ) ;
2017-10-19 20:12:02 +03:00
gmsgDeathMsg = REG_USER_MSG ( " DeathMsg " , - 1 ) ;
gmsgScoreAttrib = REG_USER_MSG ( " ScoreAttrib " , 2 ) ;
gmsgScoreInfo = REG_USER_MSG ( " ScoreInfo " , 9 ) ;
gmsgTeamInfo = REG_USER_MSG ( " TeamInfo " , - 1 ) ;
gmsgTeamScore = REG_USER_MSG ( " TeamScore " , - 1 ) ;
gmsgGameMode = REG_USER_MSG ( " GameMode " , 1 ) ;
gmsgMOTD = REG_USER_MSG ( " MOTD " , - 1 ) ;
gmsgServerName = REG_USER_MSG ( " ServerName " , - 1 ) ;
gmsgAmmoPickup = REG_USER_MSG ( " AmmoPickup " , 2 ) ;
gmsgWeapPickup = REG_USER_MSG ( " WeapPickup " , 1 ) ;
gmsgItemPickup = REG_USER_MSG ( " ItemPickup " , - 1 ) ;
gmsgHideWeapon = REG_USER_MSG ( " HideWeapon " , 1 ) ;
gmsgSetFOV = REG_USER_MSG ( " SetFOV " , 1 ) ;
gmsgShowMenu = REG_USER_MSG ( " ShowMenu " , - 1 ) ;
gmsgShake = REG_USER_MSG ( " ScreenShake " , 6 ) ;
gmsgFade = REG_USER_MSG ( " ScreenFade " , 10 ) ;
gmsgAmmoX = REG_USER_MSG ( " AmmoX " , 2 ) ;
gmsgSendAudio = REG_USER_MSG ( " SendAudio " , - 1 ) ;
gmsgRoundTime = REG_USER_MSG ( " RoundTime " , 2 ) ;
gmsgMoney = REG_USER_MSG ( " Money " , 5 ) ;
gmsgArmorType = REG_USER_MSG ( " ArmorType " , 1 ) ;
gmsgBlinkAcct = REG_USER_MSG ( " BlinkAcct " , 1 ) ;
gmsgStatusValue = REG_USER_MSG ( " StatusValue " , - 1 ) ;
gmsgStatusText = REG_USER_MSG ( " StatusText " , - 1 ) ;
gmsgStatusIcon = REG_USER_MSG ( " StatusIcon " , - 1 ) ;
gmsgBarTime = REG_USER_MSG ( " BarTime " , 2 ) ;
gmsgReloadSound = REG_USER_MSG ( " ReloadSound " , 2 ) ;
gmsgCrosshair = REG_USER_MSG ( " Crosshair " , 1 ) ;
gmsgNVGToggle = REG_USER_MSG ( " NVGToggle " , 1 ) ;
gmsgRadar = REG_USER_MSG ( " Radar " , 7 ) ;
gmsgSpectator = REG_USER_MSG ( " Spectator " , 2 ) ;
gmsgVGUIMenu = REG_USER_MSG ( " VGUIMenu " , - 1 ) ;
gmsgTutorText = REG_USER_MSG ( " TutorText " , - 1 ) ;
gmsgTutorLine = REG_USER_MSG ( " TutorLine " , - 1 ) ;
gmsgTutorState = REG_USER_MSG ( " TutorState " , - 1 ) ;
gmsgTutorClose = REG_USER_MSG ( " TutorClose " , - 1 ) ;
gmsgAllowSpec = REG_USER_MSG ( " AllowSpec " , 1 ) ;
gmsgBombDrop = REG_USER_MSG ( " BombDrop " , 7 ) ;
gmsgBombPickup = REG_USER_MSG ( " BombPickup " , 0 ) ;
gmsgSendCorpse = REG_USER_MSG ( " ClCorpse " , - 1 ) ;
gmsgHostagePos = REG_USER_MSG ( " HostagePos " , 8 ) ;
gmsgHostageK = REG_USER_MSG ( " HostageK " , 1 ) ;
gmsgHLTV = REG_USER_MSG ( " HLTV " , 2 ) ;
gmsgSpecHealth = REG_USER_MSG ( " SpecHealth " , 1 ) ;
gmsgForceCam = REG_USER_MSG ( " ForceCam " , 3 ) ;
gmsgADStop = REG_USER_MSG ( " ADStop " , 0 ) ;
gmsgReceiveW = REG_USER_MSG ( " ReceiveW " , 1 ) ;
gmsgCZCareer = REG_USER_MSG ( " CZCareer " , - 1 ) ;
gmsgCZCareerHUD = REG_USER_MSG ( " CZCareerHUD " , - 1 ) ;
gmsgShadowIdx = REG_USER_MSG ( " ShadowIdx " , 4 ) ;
gmsgTaskTime = REG_USER_MSG ( " TaskTime " , 4 ) ;
gmsgScenarioIcon = REG_USER_MSG ( " Scenario " , - 1 ) ;
gmsgBotVoice = REG_USER_MSG ( " BotVoice " , 2 ) ;
gmsgBuyClose = REG_USER_MSG ( " BuyClose " , 0 ) ;
gmsgSpecHealth2 = REG_USER_MSG ( " SpecHealth2 " , 2 ) ;
gmsgBarTime2 = REG_USER_MSG ( " BarTime2 " , 4 ) ;
gmsgItemStatus = REG_USER_MSG ( " ItemStatus " , 1 ) ;
gmsgLocation = REG_USER_MSG ( " Location " , - 1 ) ;
gmsgBotProgress = REG_USER_MSG ( " BotProgress " , - 1 ) ;
gmsgBrass = REG_USER_MSG ( " Brass " , - 1 ) ;
gmsgFog = REG_USER_MSG ( " Fog " , 7 ) ;
gmsgShowTimer = REG_USER_MSG ( " ShowTimer " , 0 ) ;
gmsgHudTextArgs = REG_USER_MSG ( " HudTextArgs " , - 1 ) ;
2019-06-04 17:41:30 +03:00
# ifdef BUILD_LATEST
2019-12-17 17:25:24 +03:00
gmsgAccount = REG_USER_MSG ( " Account " , 5 ) ;
gmsgHealthInfo = REG_USER_MSG ( " HealthInfo " , 5 ) ;
2019-06-04 17:41:30 +03:00
# endif
2017-10-12 17:50:56 +03:00
}
void WriteSigonMessages ( )
{
2017-10-19 20:12:02 +03:00
for ( int i = 0 ; i < MAX_WEAPONS ; i + + )
2017-10-12 17:50:56 +03:00
{
2017-10-19 20:12:02 +03:00
ItemInfo & info = CBasePlayerItem : : m_ItemInfoArray [ i ] ;
if ( ! info . iId )
2017-10-12 17:50:56 +03:00
continue ;
const char * pszName ;
2017-10-19 20:12:02 +03:00
if ( ! info . pszName )
2017-10-12 17:50:56 +03:00
pszName = " Empty " ;
else
2017-10-19 20:12:02 +03:00
pszName = info . pszName ;
2017-10-12 17:50:56 +03:00
2021-05-22 14:12:24 +03:00
int iFlags = info . iFlags ;
# ifdef PLAY_GAMEDLL
// TODO: fix test demo
iFlags & = ~ ITEM_FLAG_NOFIREUNDERWATER ;
# endif
2017-10-12 17:50:56 +03:00
MESSAGE_BEGIN ( MSG_INIT , gmsgWeaponList ) ;
WRITE_STRING ( pszName ) ;
2017-10-19 20:12:02 +03:00
WRITE_BYTE ( CBasePlayer : : GetAmmoIndex ( info . pszAmmo1 ) ) ;
WRITE_BYTE ( info . iMaxAmmo1 ) ;
WRITE_BYTE ( CBasePlayer : : GetAmmoIndex ( info . pszAmmo2 ) ) ;
WRITE_BYTE ( info . iMaxAmmo2 ) ;
WRITE_BYTE ( info . iSlot ) ;
WRITE_BYTE ( info . iPosition ) ;
WRITE_BYTE ( info . iId ) ;
2021-05-22 14:12:24 +03:00
WRITE_BYTE ( iFlags ) ;
2017-10-12 17:50:56 +03:00
MESSAGE_END ( ) ;
}
}
2016-02-04 03:18:26 +03:00
int CMD_ARGC_ ( )
2015-09-30 03:49:22 +03:00
{
if ( ! UseBotArgs )
return CMD_ARGC ( ) ;
int i = 0 ;
while ( BotArgs [ i ] )
2017-10-12 17:50:56 +03:00
i + + ;
2015-09-30 03:49:22 +03:00
return i ;
}
const char * CMD_ARGV_ ( int i )
{
if ( ! UseBotArgs )
return CMD_ARGV ( i ) ;
if ( i < 4 )
return BotArgs [ i ] ;
2017-10-12 17:50:56 +03:00
return nullptr ;
2015-09-30 03:49:22 +03:00
}
NOXREF void set_suicide_frame ( entvars_t * pev )
{
if ( ! FStrEq ( STRING ( pev - > model ) , " models/player.mdl " ) )
return ;
pev - > solid = SOLID_NOT ;
pev - > movetype = MOVETYPE_TOSS ;
pev - > deadflag = DEAD_DEAD ;
pev - > nextthink = - 1 ;
}
2017-10-17 15:38:40 +03:00
void BlinkAccount ( CBasePlayer * pPlayer , int numBlinks )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
MESSAGE_BEGIN ( MSG_ONE , gmsgBlinkAcct , nullptr , pPlayer - > pev ) ;
2015-09-30 03:49:22 +03:00
WRITE_BYTE ( numBlinks ) ;
MESSAGE_END ( ) ;
}
2015-12-09 01:39:54 +03:00
BOOL EXT_FUNC ClientConnect ( edict_t * pEntity , const char * pszName , const char * pszAddress , char * szRejectReason )
2015-09-30 03:49:22 +03:00
{
return g_pGameRules - > ClientConnected ( pEntity , pszName , pszAddress , szRejectReason ) ;
}
2015-12-09 01:39:54 +03:00
void EXT_FUNC ClientDisconnect ( edict_t * pEntity )
2015-09-30 03:49:22 +03:00
{
2016-06-14 01:13:13 +03:00
CBasePlayer * pPlayer = CBasePlayer : : Instance ( pEntity ) ;
2015-09-30 03:49:22 +03:00
2016-12-06 22:21:52 +03:00
if ( ! g_pGameRules - > IsGameOver ( ) )
2015-09-30 03:49:22 +03:00
{
UTIL_ClientPrintAll ( HUD_PRINTNOTIFY , " #Game_disconnected " , STRING ( pEntity - > v . netname ) ) ;
2016-04-05 03:12:05 +03:00
# ifndef REGAMEDLL_FIXES
2015-09-30 03:49:22 +03:00
CSound * pSound = CSoundEnt : : SoundPointerForIndex ( CSoundEnt : : ClientSoundIndex ( pEntity ) ) ;
2016-06-14 01:13:13 +03:00
if ( pSound )
2015-09-30 03:49:22 +03:00
pSound - > Reset ( ) ;
2016-04-05 03:12:05 +03:00
# endif
2015-09-30 03:49:22 +03:00
pEntity - > v . takedamage = DAMAGE_NO ;
pEntity - > v . solid = SOLID_NOT ;
pEntity - > v . flags = FL_DORMANT ;
2016-06-14 01:13:13 +03:00
if ( pPlayer )
2017-10-12 17:50:56 +03:00
{
2016-10-11 14:51:28 +03:00
pPlayer - > Disconnect ( ) ;
2017-10-12 17:50:56 +03:00
}
2015-09-30 03:49:22 +03:00
UTIL_SetOrigin ( & pEntity - > v , pEntity - > v . origin ) ;
g_pGameRules - > ClientDisconnected ( pEntity ) ;
}
2016-06-14 01:13:13 +03:00
# ifndef REGAMEDLL_FIXES
if ( TheBots & & pPlayer & & pPlayer - > IsBot ( ) )
# else
// These checks are already inside into this CCSBotManager::ClientDisconnect
if ( TheBots )
# endif
2015-09-30 03:49:22 +03:00
{
TheBots - > ClientDisconnect ( pPlayer ) ;
}
}
void respawn ( entvars_t * pev , BOOL fCopyCorpse )
{
if ( gpGlobals - > coop | | gpGlobals - > deathmatch )
{
2016-02-23 02:13:52 +03:00
if ( CSGameRules ( ) - > m_iTotalRoundsPlayed > 0 )
CSGameRules ( ) - > MarkSpawnSkipped ( ) ;
2015-09-30 03:49:22 +03:00
2016-03-17 20:44:52 +03:00
CBasePlayer * pPlayer = GetClassPtr < CCSPlayer > ( ( CBasePlayer * ) pev ) ;
2016-02-23 02:13:52 +03:00
if ( CSGameRules ( ) - > IsCareer ( ) & & CSGameRules ( ) - > ShouldSkipSpawn ( ) & & pPlayer - > IsAlive ( ) )
2015-09-30 03:49:22 +03:00
g_skipCareerInitialSpawn = true ;
pPlayer - > Spawn ( ) ;
g_skipCareerInitialSpawn = false ;
}
else if ( pev - > deadflag > DEAD_NO )
{
SERVER_COMMAND ( " reload \n " ) ;
}
}
// Suicide...
2015-12-09 01:39:54 +03:00
void EXT_FUNC ClientKill ( edict_t * pEntity )
2015-09-30 03:49:22 +03:00
{
entvars_t * pev = & pEntity - > v ;
2016-06-14 01:13:13 +03:00
CBasePlayer * pPlayer = CBasePlayer : : Instance ( pev ) ;
2015-09-30 03:49:22 +03:00
// prevent suiciding too often
2016-06-14 01:13:13 +03:00
if ( pPlayer - > m_fNextSuicideTime > gpGlobals - > time )
2015-09-30 03:49:22 +03:00
return ;
2020-05-18 15:59:43 +03:00
// don't let them suicide for 1 second after suiciding
2016-06-14 01:13:13 +03:00
pPlayer - > m_fNextSuicideTime = gpGlobals - > time + 1.0f ;
2022-12-17 19:45:04 +03:00
pPlayer - > Kill ( ) ;
2015-09-30 03:49:22 +03:00
}
2017-01-29 02:56:29 +03:00
LINK_HOOK_VOID_CHAIN ( ShowMenu , ( CBasePlayer * pPlayer , int bitsValidSlots , int nDisplayTime , BOOL fNeedMore , char * pszText ) , pPlayer , bitsValidSlots , nDisplayTime , fNeedMore , pszText )
2016-05-23 01:51:21 +03:00
2016-12-06 22:21:52 +03:00
void EXT_FUNC __API_HOOK ( ShowMenu ) ( CBasePlayer * pPlayer , int bitsValidSlots , int nDisplayTime , BOOL fNeedMore , char * pszText )
2015-09-30 03:49:22 +03:00
{
2017-10-12 17:50:56 +03:00
MESSAGE_BEGIN ( MSG_ONE , gmsgShowMenu , nullptr , pPlayer - > pev ) ;
2015-09-30 03:49:22 +03:00
WRITE_SHORT ( bitsValidSlots ) ;
WRITE_CHAR ( nDisplayTime ) ;
WRITE_BYTE ( fNeedMore ) ;
WRITE_STRING ( pszText ) ;
MESSAGE_END ( ) ;
}
2016-06-15 12:26:46 +03:00
LINK_HOOK_VOID_CHAIN ( ShowVGUIMenu , ( CBasePlayer * pPlayer , int MenuType , int BitMask , char * szOldMenu ) , pPlayer , MenuType , BitMask , szOldMenu ) ;
2016-05-23 01:51:21 +03:00
2016-12-06 22:21:52 +03:00
void EXT_FUNC __API_HOOK ( ShowVGUIMenu ) ( CBasePlayer * pPlayer , int MenuType , int BitMask , char * szOldMenu )
2015-09-30 03:49:22 +03:00
{
2016-06-15 12:26:46 +03:00
# ifdef REGAMEDLL_ADD
if ( CSGameRules ( ) - > ShouldSkipShowMenu ( ) ) {
CSGameRules ( ) - > MarkShowMenuSkipped ( ) ;
2017-01-20 17:52:37 +03:00
pPlayer - > ResetMenu ( ) ;
2016-06-15 12:26:46 +03:00
return ;
}
if ( pPlayer - > CSPlayer ( ) - > m_bForceShowMenu ) {
ShowMenu ( pPlayer , BitMask , - 1 , 0 , szOldMenu ) ;
return ;
}
# endif
if ( pPlayer - > m_bVGUIMenus | | MenuType > VGUI_Menu_Buy_Item )
2015-09-30 03:49:22 +03:00
{
2017-10-12 17:50:56 +03:00
MESSAGE_BEGIN ( MSG_ONE , gmsgVGUIMenu , nullptr , pPlayer - > pev ) ;
2016-06-14 01:13:13 +03:00
WRITE_BYTE ( MenuType ) ;
WRITE_SHORT ( BitMask ) ;
WRITE_CHAR ( - 1 ) ;
WRITE_BYTE ( 0 ) ;
WRITE_STRING ( " " ) ;
2015-09-30 03:49:22 +03:00
MESSAGE_END ( ) ;
}
else
ShowMenu ( pPlayer , BitMask , - 1 , 0 , szOldMenu ) ;
}
2016-02-04 03:18:26 +03:00
NOXREF int CountTeams ( )
2015-09-30 03:49:22 +03:00
{
int iNumCT = 0 , iNumTerrorist = 0 ;
2017-10-17 15:38:40 +03:00
CBaseEntity * pEntity = nullptr ;
2017-10-12 17:50:56 +03:00
while ( ( pEntity = UTIL_FindEntityByClassname ( pEntity , " player " ) ) )
2015-09-30 03:49:22 +03:00
{
2017-10-12 17:50:56 +03:00
if ( FNullEnt ( pEntity - > edict ( ) ) )
2015-09-30 03:49:22 +03:00
break ;
2017-10-12 17:50:56 +03:00
CBasePlayer * pPlayer = GetClassPtr < CCSPlayer > ( ( CBasePlayer * ) pEntity - > pev ) ;
2015-09-30 03:49:22 +03:00
2017-10-12 17:50:56 +03:00
if ( pPlayer - > m_iTeam = = UNASSIGNED )
2015-09-30 03:49:22 +03:00
continue ;
2017-11-22 20:27:55 +03:00
if ( pPlayer - > IsDormant ( ) )
2015-09-30 03:49:22 +03:00
continue ;
2017-10-12 17:50:56 +03:00
if ( pPlayer - > m_iTeam = = SPECTATOR )
2015-09-30 03:49:22 +03:00
continue ;
2017-10-12 17:50:56 +03:00
if ( pPlayer - > m_iTeam = = CT )
2015-09-30 03:49:22 +03:00
iNumCT + + ;
2017-10-12 17:50:56 +03:00
else if ( pPlayer - > m_iTeam = = TERRORIST )
2015-09-30 03:49:22 +03:00
iNumTerrorist + + ;
}
return iNumCT - iNumTerrorist ;
}
void ListPlayers ( CBasePlayer * current )
{
2016-05-04 00:53:03 +03:00
char message [ 120 ] = " " , cNumber [ 12 ] ;
2015-09-30 03:49:22 +03:00
2017-10-12 17:50:56 +03:00
CBaseEntity * pEntity = nullptr ;
while ( ( pEntity = UTIL_FindEntityByClassname ( pEntity , " player " ) ) )
2015-09-30 03:49:22 +03:00
{
2017-10-12 17:50:56 +03:00
if ( FNullEnt ( pEntity - > edict ( ) ) )
2015-09-30 03:49:22 +03:00
break ;
2017-11-22 20:27:55 +03:00
if ( pEntity - > IsDormant ( ) )
2015-09-30 03:49:22 +03:00
continue ;
2017-10-12 17:50:56 +03:00
CBasePlayer * pPlayer = GetClassPtr < CCSPlayer > ( ( CBasePlayer * ) pEntity - > pev ) ;
int iUserID = GETPLAYERUSERID ( ENT ( pPlayer - > pev ) ) ;
2015-09-30 03:49:22 +03:00
Q_sprintf ( cNumber , " %d " , iUserID ) ;
Q_strcpy ( message , " \n " ) ;
Q_strcat ( message , cNumber ) ;
Q_strcat ( message , " : " ) ;
2017-10-12 17:50:56 +03:00
Q_strcat ( message , STRING ( pPlayer - > pev - > netname ) ) ;
2015-09-30 03:49:22 +03:00
ClientPrint ( current - > pev , HUD_PRINTCONSOLE , message ) ;
}
ClientPrint ( current - > pev , HUD_PRINTCONSOLE , " \n " ) ;
}
int CountTeamPlayers ( int iTeam )
{
2017-10-12 17:50:56 +03:00
int nCount = 0 ;
CBaseEntity * pEntity = nullptr ;
while ( ( pEntity = UTIL_FindEntityByClassname ( pEntity , " player " ) ) )
2015-09-30 03:49:22 +03:00
{
2017-10-12 17:50:56 +03:00
if ( FNullEnt ( pEntity - > edict ( ) ) )
2015-09-30 03:49:22 +03:00
break ;
2017-11-22 20:27:55 +03:00
if ( pEntity - > IsDormant ( ) )
2015-09-30 03:49:22 +03:00
continue ;
2017-10-12 17:50:56 +03:00
if ( GetClassPtr < CCSPlayer > ( ( CBasePlayer * ) pEntity - > pev ) - > m_iTeam = = iTeam )
{
nCount + + ;
}
2015-09-30 03:49:22 +03:00
}
2017-10-12 17:50:56 +03:00
return nCount ;
2015-09-30 03:49:22 +03:00
}
void ProcessKickVote ( CBasePlayer * pVotingPlayer , CBasePlayer * pKickPlayer )
{
CBaseEntity * pTempEntity ;
CBasePlayer * pTempPlayer ;
int iValidVotes ;
int iVoteID ;
int iVotesNeeded ;
float fKickPercent ;
if ( ! pVotingPlayer | | ! pKickPlayer )
return ;
int iTeamCount = CountTeamPlayers ( pVotingPlayer - > m_iTeam ) ;
if ( iTeamCount < 3 )
return ;
iValidVotes = 0 ;
2017-10-12 17:50:56 +03:00
pTempEntity = nullptr ;
2015-09-30 03:49:22 +03:00
iVoteID = pVotingPlayer - > m_iCurrentKickVote ;
2016-12-06 22:21:52 +03:00
while ( ( pTempEntity = UTIL_FindEntityByClassname ( pTempEntity , " player " ) ) )
2015-09-30 03:49:22 +03:00
{
if ( FNullEnt ( pTempEntity - > edict ( ) ) )
break ;
2016-03-17 20:44:52 +03:00
pTempPlayer = GetClassPtr < CCSPlayer > ( ( CBasePlayer * ) pTempEntity - > pev ) ;
2015-09-30 03:49:22 +03:00
if ( ! pTempPlayer | | pTempPlayer - > m_iTeam = = UNASSIGNED )
continue ;
if ( pTempPlayer - > m_iTeam = = pVotingPlayer - > m_iTeam & & pTempPlayer - > m_iCurrentKickVote = = iVoteID )
iValidVotes + + ;
}
if ( kick_percent . value < 0 )
CVAR_SET_STRING ( " mp_kickpercent " , " 0.0 " ) ;
else if ( kick_percent . value > 1 )
CVAR_SET_STRING ( " mp_kickpercent " , " 1.0 " ) ;
iVotesNeeded = iValidVotes ;
fKickPercent = ( iTeamCount * kick_percent . value + 0.5 ) ;
2016-02-23 02:13:52 +03:00
if ( iVotesNeeded > = int ( fKickPercent ) )
2015-09-30 03:49:22 +03:00
{
2019-06-20 22:37:44 +03:00
# ifdef REGAMEDLL_FIXES
SERVER_COMMAND ( UTIL_VarArgs ( " kick #%d \" You have been voted off. \" \n " , iVoteID ) ) ;
SERVER_EXECUTE ( ) ;
# endif
2015-09-30 03:49:22 +03:00
UTIL_ClientPrintAll ( HUD_PRINTCENTER , " #Game_kicked " , STRING ( pKickPlayer - > pev - > netname ) ) ;
2019-06-20 22:37:44 +03:00
# ifndef REGAMEDLL_FIXES
2019-12-25 15:35:18 +03:00
SERVER_COMMAND ( UTIL_VarArgs ( " kick #%d \n " , iVoteID ) ) ;
2019-06-20 22:37:44 +03:00
# endif
2017-10-12 17:50:56 +03:00
pTempEntity = nullptr ;
2015-09-30 03:49:22 +03:00
2016-12-06 22:21:52 +03:00
while ( ( pTempEntity = UTIL_FindEntityByClassname ( pTempEntity , " player " ) ) )
2015-09-30 03:49:22 +03:00
{
if ( FNullEnt ( pTempEntity - > edict ( ) ) )
break ;
2016-03-17 20:44:52 +03:00
pTempPlayer = GetClassPtr < CCSPlayer > ( ( CBasePlayer * ) pTempEntity - > pev ) ;
2015-09-30 03:49:22 +03:00
if ( ! pTempPlayer | | pTempPlayer - > m_iTeam = = UNASSIGNED )
continue ;
if ( pTempPlayer - > m_iTeam = = pVotingPlayer - > m_iTeam & & pTempPlayer - > m_iCurrentKickVote = = iVoteID )
pTempPlayer - > m_iCurrentKickVote = 0 ;
}
}
}
2016-02-04 03:18:26 +03:00
void CheckStartMoney ( )
2015-09-30 03:49:22 +03:00
{
2016-02-23 02:13:52 +03:00
int money = int ( startmoney . value ) ;
2015-09-30 03:49:22 +03:00
2015-12-29 01:54:08 +03:00
# ifndef REGAMEDLL_ADD
2015-09-30 03:49:22 +03:00
if ( money > 16000 )
CVAR_SET_FLOAT ( " mp_startmoney " , 16000 ) ;
else if ( money < 800 )
CVAR_SET_FLOAT ( " mp_startmoney " , 800 ) ;
2015-12-29 01:54:08 +03:00
# else
2016-02-23 02:13:52 +03:00
int max_money = int ( maxmoney . value ) ;
2019-04-23 15:54:51 +03:00
if ( max_money > MAX_MONEY_THRESHOLD )
{
max_money = MAX_MONEY_THRESHOLD ;
CVAR_SET_FLOAT ( " mp_maxmoney " , MAX_MONEY_THRESHOLD ) ;
}
2015-12-29 01:54:08 +03:00
if ( money > max_money )
CVAR_SET_FLOAT ( " mp_startmoney " , max_money ) ;
2016-01-21 14:23:56 +03:00
else if ( money < 0 )
CVAR_SET_FLOAT ( " mp_startmoney " , 0 ) ;
2016-06-26 21:31:23 +03:00
# endif
2015-12-29 01:54:08 +03:00
2015-09-30 03:49:22 +03:00
}
2015-12-09 01:39:54 +03:00
void EXT_FUNC ClientPutInServer ( edict_t * pEntity )
2015-09-30 03:49:22 +03:00
{
entvars_t * pev = & pEntity - > v ;
2016-03-17 20:44:52 +03:00
CBasePlayer * pPlayer = GetClassPtr < CCSPlayer > ( ( CBasePlayer * ) pev ) ;
2015-09-30 03:49:22 +03:00
pPlayer - > SetCustomDecalFrames ( - 1 ) ;
pPlayer - > SetPrefsFromUserinfo ( GET_INFO_BUFFER ( pEntity ) ) ;
2016-02-23 02:13:52 +03:00
if ( ! g_pGameRules - > IsMultiplayer ( ) )
2015-09-30 03:49:22 +03:00
{
pPlayer - > Spawn ( ) ;
return ;
}
2023-09-05 06:52:44 +03:00
# ifdef REGAMEDLL_FIXES
pPlayer - > m_bHasDefuser = false ;
# endif
2015-09-30 03:49:22 +03:00
pPlayer - > m_bNotKilled = true ;
pPlayer - > m_iIgnoreGlobalChat = IGNOREMSG_NONE ;
pPlayer - > m_iTeamKills = 0 ;
pPlayer - > m_bJustConnected = true ;
pPlayer - > Spawn ( ) ;
pPlayer - > m_bTeamChanged = false ;
pPlayer - > m_iNumSpawns = 0 ;
CheckStartMoney ( ) ;
2016-10-07 15:19:51 +03:00
# ifdef REGAMEDLL_ADD
pPlayer - > AddAccount ( startmoney . value , RT_PLAYER_JOIN ) ;
# else
2016-02-23 02:13:52 +03:00
pPlayer - > m_iAccount = int ( startmoney . value ) ;
2016-10-07 15:19:51 +03:00
# endif
2015-09-30 03:49:22 +03:00
pPlayer - > m_fGameHUDInitialized = FALSE ;
pPlayer - > m_flDisplayHistory & = ~ DHF_ROUND_STARTED ;
pPlayer - > pev - > flags | = FL_SPECTATOR ;
pPlayer - > pev - > solid = SOLID_NOT ;
pPlayer - > pev - > movetype = MOVETYPE_NOCLIP ;
2017-05-24 19:07:37 +03:00
pPlayer - > pev - > effects = ( EF_NODRAW | EF_NOINTERP ) ;
2015-09-30 03:49:22 +03:00
pPlayer - > pev - > takedamage = DAMAGE_NO ;
pPlayer - > pev - > deadflag = DEAD_DEAD ;
pPlayer - > pev - > velocity = g_vecZero ;
pPlayer - > pev - > punchangle = g_vecZero ;
pPlayer - > m_iJoiningState = READINGLTEXT ;
pPlayer - > m_iTeam = UNASSIGNED ;
pPlayer - > pev - > fixangle = 1 ;
pPlayer - > m_iModelName = MODEL_URBAN ;
pPlayer - > m_bContextHelp = true ;
pPlayer - > m_bHasNightVision = false ;
pPlayer - > m_iHostagesKilled = 0 ;
pPlayer - > m_iMapVote = 0 ;
pPlayer - > m_iCurrentKickVote = 0 ;
pPlayer - > m_fDeadTime = 0 ;
pPlayer - > has_disconnected = false ;
pPlayer - > m_iMenu = Menu_OFF ;
pPlayer - > ClearAutoBuyData ( ) ;
2017-10-12 17:50:56 +03:00
pPlayer - > m_rebuyString = nullptr ;
2015-09-30 03:49:22 +03:00
SET_CLIENT_MAXSPEED ( ENT ( pPlayer - > pev ) , 1 ) ;
SET_MODEL ( ENT ( pPlayer - > pev ) , " models/player.mdl " ) ;
2017-11-22 20:27:55 +03:00
pPlayer - > SetThink ( nullptr ) ;
2015-09-30 03:49:22 +03:00
2017-10-12 17:50:56 +03:00
CBaseEntity * pTarget = nullptr ;
pPlayer - > m_pIntroCamera = UTIL_FindEntityByClassname ( nullptr , " trigger_camera " ) ;
2015-09-30 03:49:22 +03:00
2016-12-06 22:21:52 +03:00
if ( g_pGameRules & & g_pGameRules - > IsMultiplayer ( ) )
2015-09-30 03:49:22 +03:00
{
2017-10-12 17:50:56 +03:00
CSGameRules ( ) - > m_bMapHasCameras = ( pPlayer - > m_pIntroCamera ! = nullptr ) ;
2015-09-30 03:49:22 +03:00
}
2016-07-14 17:12:17 +03:00
if ( pPlayer - > m_pIntroCamera )
2016-12-06 22:21:52 +03:00
{
// find the target (by default info_target) for the camera view direction.
2017-10-12 17:50:56 +03:00
pTarget = UTIL_FindEntityByTargetname ( nullptr , STRING ( pPlayer - > m_pIntroCamera - > pev - > target ) ) ;
2016-12-06 22:21:52 +03:00
}
2015-09-30 03:49:22 +03:00
2016-07-14 17:12:17 +03:00
if ( pPlayer - > m_pIntroCamera & & pTarget )
2015-09-30 03:49:22 +03:00
{
2016-07-14 17:12:17 +03:00
Vector CamAngles = UTIL_VecToAngles ( ( pTarget - > pev - > origin - pPlayer - > m_pIntroCamera - > pev - > origin ) . Normalize ( ) ) ;
2015-09-30 03:49:22 +03:00
CamAngles . x = - CamAngles . x ;
UTIL_SetOrigin ( pPlayer - > pev , pPlayer - > m_pIntroCamera - > pev - > origin ) ;
pPlayer - > pev - > angles = CamAngles ;
pPlayer - > pev - > v_angle = pPlayer - > pev - > angles ;
pPlayer - > m_fIntroCamTime = gpGlobals - > time + 6 ;
pPlayer - > pev - > view_ofs = g_vecZero ;
}
2016-07-14 17:12:17 +03:00
# ifndef REGAMEDLL_FIXES
2015-09-30 03:49:22 +03:00
else
{
pPlayer - > m_iTeam = CT ;
2016-12-06 22:21:52 +03:00
if ( g_pGameRules )
2015-09-30 03:49:22 +03:00
{
2016-02-23 02:13:52 +03:00
g_pGameRules - > GetPlayerSpawnSpot ( pPlayer ) ;
2015-09-30 03:49:22 +03:00
}
pPlayer - > m_iTeam = UNASSIGNED ;
pPlayer - > pev - > v_angle = g_vecZero ;
pPlayer - > pev - > angles = gpGlobals - > v_forward ;
}
2016-07-14 17:12:17 +03:00
# endif
2015-09-30 03:49:22 +03:00
2016-12-06 22:21:52 +03:00
if ( TheBots )
2015-12-05 22:40:30 +03:00
{
TheBots - > OnEvent ( EVENT_PLAYER_CHANGED_TEAM , ( CBaseEntity * ) pPlayer ) ;
}
2015-09-30 03:49:22 +03:00
pPlayer - > m_iJoiningState = SHOWLTEXT ;
static char sName [ 128 ] ;
Q_strcpy ( sName , STRING ( pPlayer - > pev - > netname ) ) ;
for ( char * pApersand = sName ; pApersand & & * pApersand ! = ' \0 ' ; pApersand + + )
{
if ( * pApersand = = ' % ' )
* pApersand = ' ' ;
}
2019-08-13 14:57:19 +03:00
# ifdef REGAMEDLL_API
2023-09-28 12:18:15 +03:00
pPlayer - > CSPlayer ( ) - > OnConnect ( ) ;
2019-08-13 14:57:19 +03:00
# endif
2015-09-30 03:49:22 +03:00
UTIL_ClientPrintAll ( HUD_PRINTNOTIFY , " #Game_connected " , ( sName [ 0 ] ! = ' \0 ' ) ? sName : " <unconnected> " ) ;
}
2016-07-14 17:12:17 +03:00
void Host_Say ( edict_t * pEntity , BOOL teamonly )
2015-09-30 03:49:22 +03:00
{
int j ;
char * p ;
char text [ 128 ] ;
char szTemp [ 256 ] ;
const char * cpSay = " say " ;
const char * cpSayTeam = " say_team " ;
const char * pcmd = CMD_ARGV_ ( 0 ) ;
bool bSenderDead = false ;
entvars_t * pev = & pEntity - > v ;
2017-10-17 15:38:40 +03:00
CBasePlayer * pPlayer = GetClassPtr < CCSPlayer > ( ( CBasePlayer * ) pev ) ;
2015-09-30 03:49:22 +03:00
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_flLastTalk ! = 0.0f & & gpGlobals - > time - pPlayer - > m_flLastTalk < 0.66f )
2015-09-30 03:49:22 +03:00
return ;
2017-10-17 15:38:40 +03:00
pPlayer - > m_flLastTalk = gpGlobals - > time ;
2015-09-30 03:49:22 +03:00
2017-10-17 15:38:40 +03:00
if ( pPlayer - > pev - > deadflag ! = DEAD_NO )
2015-09-30 03:49:22 +03:00
bSenderDead = true ;
// We can get a raw string now, without the "say " prepended
if ( CMD_ARGC_ ( ) = = 0 )
return ;
if ( ! Q_stricmp ( pcmd , cpSay ) | | ! Q_stricmp ( pcmd , cpSayTeam ) )
{
if ( CMD_ARGC_ ( ) > = 2 )
{
2020-12-25 15:38:11 +03:00
Q_strlcpy ( szTemp , CMD_ARGS ( ) ) ;
p = szTemp ;
2015-09-30 03:49:22 +03:00
}
else
{
// say with a blank message, nothing to do
return ;
}
}
else // Raw text, need to prepend argv[0]
{
if ( CMD_ARGC_ ( ) > = 2 )
{
2020-12-25 15:40:01 +03:00
Q_sprintf ( szTemp , " %s %s " , pcmd , CMD_ARGS ( ) ) ;
2015-09-30 03:49:22 +03:00
}
else
{
// Just a one word command, use the first word...sigh
2020-12-25 15:40:01 +03:00
Q_sprintf ( szTemp , " %s " , pcmd ) ;
2015-09-30 03:49:22 +03:00
}
p = szTemp ;
}
2017-10-31 00:29:22 +03:00
# ifdef REGAMEDLL_FIXES
Q_StripPrecedingAndTrailingWhitespace ( p ) ;
# endif
// remove quotes (leading & trailing) if present
2015-09-30 03:49:22 +03:00
if ( * p = = ' " ' )
{
p + + ;
p [ Q_strlen ( p ) - 1 ] = ' \0 ' ;
}
2020-12-25 15:36:02 +03:00
// Check if buffer contains an invalid unicode sequence
// This can happen after truncation up to 127 chars into SV_ParseStringCommand
if ( ! Q_UnicodeValidate ( p ) )
{
// Try fix invalid sequence in UTF-8
Q_UnicodeRepair ( p ) ;
}
2015-09-30 03:49:22 +03:00
// make sure the text has content
2020-12-25 15:36:02 +03:00
if ( ! p [ 0 ] )
2015-09-30 03:49:22 +03:00
{
// no character found, so say nothing
return ;
}
Q_StripUnprintableAndSpace ( p ) ;
if ( Q_strlen ( p ) < = 0 )
return ;
2017-10-12 17:50:56 +03:00
const char * placeName = nullptr ;
char * pszFormat = nullptr ;
char * pszConsoleFormat = nullptr ;
2015-09-30 03:49:22 +03:00
bool consoleUsesPlaceName = false ;
2016-01-19 14:54:31 +03:00
// team only
2015-09-30 03:49:22 +03:00
if ( teamonly )
{
2017-10-17 15:38:40 +03:00
if ( AreRunningCZero ( ) & & ( pPlayer - > m_iTeam = = CT | | pPlayer - > m_iTeam = = TERRORIST ) )
2015-09-30 03:49:22 +03:00
{
// search the place name where is located the player
2017-10-17 15:38:40 +03:00
Place playerPlace = TheNavAreaGrid . GetPlace ( & pPlayer - > pev - > origin ) ;
2015-09-30 03:49:22 +03:00
const BotPhraseList * placeList = TheBotPhrases - > GetPlaceList ( ) ;
2017-10-31 00:29:22 +03:00
for ( auto phrase : * placeList )
2015-09-30 03:49:22 +03:00
{
2017-10-31 00:29:22 +03:00
if ( phrase - > GetID ( ) = = playerPlace )
2015-09-30 03:49:22 +03:00
{
2017-10-31 00:29:22 +03:00
placeName = phrase - > GetName ( ) ;
2015-09-30 03:49:22 +03:00
break ;
}
}
}
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iTeam = = CT )
2015-09-30 03:49:22 +03:00
{
if ( bSenderDead )
{
pszFormat = " #Cstrike_Chat_CT_Dead " ;
pszConsoleFormat = " *DEAD*(Counter-Terrorist) %s : %s " ;
}
2016-12-06 22:21:52 +03:00
else if ( placeName )
2015-09-30 03:49:22 +03:00
{
pszFormat = " #Cstrike_Chat_CT_Loc " ;
pszConsoleFormat = " *(Counter-Terrorist) %s @ %s : %s " ;
consoleUsesPlaceName = true ;
}
else
{
pszFormat = " #Cstrike_Chat_CT " ;
pszConsoleFormat = " (Counter-Terrorist) %s : %s " ;
}
}
2017-10-17 15:38:40 +03:00
else if ( pPlayer - > m_iTeam = = TERRORIST )
2015-09-30 03:49:22 +03:00
{
if ( bSenderDead )
{
pszFormat = " #Cstrike_Chat_T_Dead " ;
pszConsoleFormat = " *DEAD*(Terrorist) %s : %s " ;
}
2016-12-06 22:21:52 +03:00
else if ( placeName )
2015-09-30 03:49:22 +03:00
{
pszFormat = " #Cstrike_Chat_T_Loc " ;
pszConsoleFormat = " (Terrorist) %s @ %s : %s " ;
consoleUsesPlaceName = true ;
}
else
{
pszFormat = " #Cstrike_Chat_T " ;
pszConsoleFormat = " (Terrorist) %s : %s " ;
}
}
else
{
pszFormat = " #Cstrike_Chat_Spec " ;
pszConsoleFormat = " (Spectator) %s : %s " ;
}
}
2016-01-19 14:54:31 +03:00
// everyone
2015-09-30 03:49:22 +03:00
else
{
if ( bSenderDead )
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iTeam = = SPECTATOR )
2015-09-30 03:49:22 +03:00
{
pszFormat = " #Cstrike_Chat_AllSpec " ;
pszConsoleFormat = " *SPEC* %s : %s " ;
}
else
{
pszFormat = " #Cstrike_Chat_AllDead " ;
pszConsoleFormat = " *DEAD* %s : %s " ;
}
}
else
{
pszFormat = " #Cstrike_Chat_All " ;
pszConsoleFormat = " %s : %s " ;
}
}
text [ 0 ] = ' \0 ' ;
// -3 for /n and null terminator
j = sizeof ( text ) - 3 - Q_strlen ( text ) - Q_strlen ( pszFormat ) ;
2016-12-06 22:21:52 +03:00
if ( placeName )
2015-09-30 03:49:22 +03:00
{
j - = Q_strlen ( placeName ) + 1 ;
}
if ( ( signed int ) Q_strlen ( p ) > j )
p [ j ] = 0 ;
2016-12-06 22:21:52 +03:00
for ( char * pAmpersand = p ; pAmpersand & & * pAmpersand ! = ' \0 ' ; pAmpersand + + )
2015-09-30 03:49:22 +03:00
{
if ( pAmpersand [ 0 ] = = ' % ' )
{
if ( pAmpersand [ 1 ] ! = ' l ' & & pAmpersand [ 1 ] ! = ' ' & & pAmpersand [ 1 ] ! = ' \0 ' )
{
pAmpersand [ 0 ] = ' ' ;
}
}
}
Q_strcat ( text , p ) ;
Q_strcat ( text , " \n " ) ;
// loop through all players
// Start with the first player.
// This may return the world in single player if the client types something between levels or during spawn
// so check it, or it will infinite loop
2017-11-22 20:27:55 +03:00
CBasePlayer * pReceiver = nullptr ;
while ( ( pReceiver = UTIL_FindEntityByClassname ( pReceiver , " player " ) ) )
2015-09-30 03:49:22 +03:00
{
2017-11-22 20:27:55 +03:00
if ( FNullEnt ( pReceiver - > edict ( ) ) )
2015-09-30 03:49:22 +03:00
break ;
2017-11-22 20:27:55 +03:00
if ( ! pReceiver - > pev )
2015-09-30 03:49:22 +03:00
continue ;
2017-11-22 20:27:55 +03:00
if ( pReceiver - > edict ( ) = = pEntity )
2015-09-30 03:49:22 +03:00
continue ;
// Not a client ? (should never be true)
2017-11-22 20:27:55 +03:00
if ( ! pReceiver - > IsNetClient ( ) )
2015-09-30 03:49:22 +03:00
continue ;
// can the receiver hear the sender? or has he muted him?
2017-11-22 20:27:55 +03:00
if ( gpGlobals - > deathmatch ! = 0.0f & & CSGameRules ( ) - > m_VoiceGameMgr . PlayerHasBlockedPlayer ( pReceiver , pPlayer ) )
2015-09-30 03:49:22 +03:00
continue ;
2017-11-22 20:27:55 +03:00
if ( teamonly & & pReceiver - > m_iTeam ! = pPlayer - > m_iTeam )
2015-09-30 03:49:22 +03:00
continue ;
2021-08-28 13:41:49 +03:00
if (
# ifdef REGAMEDLL_ADD
! ( bool ) allchat . value & &
# endif
( ( pReceiver - > pev - > deadflag ! = DEAD_NO & & ! bSenderDead ) | | ( pReceiver - > pev - > deadflag = = DEAD_NO & & bSenderDead ) ) )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
if ( ! ( pPlayer - > pev - > flags & FL_PROXY ) )
2015-09-30 03:49:22 +03:00
continue ;
}
2017-11-22 20:27:55 +03:00
if ( ( pReceiver - > m_iIgnoreGlobalChat = = IGNOREMSG_ENEMY & & pReceiver - > m_iTeam = = pPlayer - > m_iTeam )
| | pReceiver - > m_iIgnoreGlobalChat = = IGNOREMSG_NONE )
2015-09-30 03:49:22 +03:00
{
2017-11-22 20:27:55 +03:00
MESSAGE_BEGIN ( MSG_ONE , gmsgSayText , nullptr , pReceiver - > pev ) ;
2015-09-30 03:49:22 +03:00
WRITE_BYTE ( ENTINDEX ( pEntity ) ) ;
WRITE_STRING ( pszFormat ) ;
WRITE_STRING ( " " ) ;
WRITE_STRING ( text ) ;
2016-12-06 22:21:52 +03:00
if ( placeName )
2015-09-30 03:49:22 +03:00
{
WRITE_STRING ( placeName ) ;
}
MESSAGE_END ( ) ;
}
}
// print to the sending client
2017-10-12 17:50:56 +03:00
MESSAGE_BEGIN ( MSG_ONE , gmsgSayText , nullptr , & pEntity - > v ) ;
2015-09-30 03:49:22 +03:00
WRITE_BYTE ( ENTINDEX ( pEntity ) ) ;
WRITE_STRING ( pszFormat ) ;
WRITE_STRING ( " " ) ;
WRITE_STRING ( text ) ;
2016-12-06 22:21:52 +03:00
if ( placeName )
2015-09-30 03:49:22 +03:00
{
WRITE_STRING ( placeName ) ;
}
MESSAGE_END ( ) ;
2019-06-05 17:06:02 +03:00
# ifdef REGAMEDLL_FIXES
// don't to type for listenserver
if ( IS_DEDICATED_SERVER ( ) )
# endif
2015-09-30 03:49:22 +03:00
{
2019-06-05 17:06:02 +03:00
// echo to server console
if ( pszConsoleFormat )
{
if ( placeName & & consoleUsesPlaceName )
SERVER_PRINT ( UTIL_VarArgs ( pszConsoleFormat , STRING ( pPlayer - > pev - > netname ) , placeName , text ) ) ;
else
SERVER_PRINT ( UTIL_VarArgs ( pszConsoleFormat , STRING ( pPlayer - > pev - > netname ) , text ) ) ;
}
2015-09-30 03:49:22 +03:00
else
2019-06-05 17:06:02 +03:00
{
SERVER_PRINT ( text ) ;
}
2017-11-22 20:27:55 +03:00
}
2015-09-30 03:49:22 +03:00
2016-12-06 22:21:52 +03:00
if ( logmessages . value )
2015-09-30 03:49:22 +03:00
{
const char * temp = teamonly ? " say_team " : " say " ;
2017-10-17 15:38:40 +03:00
const char * deadText = ( pPlayer - > m_iTeam ! = SPECTATOR & & bSenderDead ) ? " (dead) " : " " ;
2015-09-30 03:49:22 +03:00
2017-10-17 15:38:40 +03:00
char * szTeam = GetTeam ( pPlayer - > m_iTeam ) ;
2015-09-30 03:49:22 +03:00
2017-10-17 15:38:40 +03:00
UTIL_LogPrintf ( " \" %s<%i><%s><%s> \" %s \" %s \" %s \n " , STRING ( pPlayer - > pev - > netname ) , GETPLAYERUSERID ( pPlayer - > edict ( ) ) , GETPLAYERAUTHID ( pPlayer - > edict ( ) ) ,
2017-11-22 20:27:55 +03:00
szTeam , temp , p , deadText ) ;
2015-09-30 03:49:22 +03:00
}
}
2016-06-20 22:32:02 +03:00
bool CanBuyThis ( CBasePlayer * pPlayer , int iWeapon )
2015-09-30 03:49:22 +03:00
{
if ( pPlayer - > HasShield ( ) & & iWeapon = = WEAPON_ELITE )
return false ;
if ( pPlayer - > HasShield ( ) & & iWeapon = = WEAPON_SHIELDGUN )
return false ;
2017-10-19 20:12:02 +03:00
if ( pPlayer - > m_rgpPlayerItems [ PISTOL_SLOT ] & & pPlayer - > m_rgpPlayerItems [ PISTOL_SLOT ] - > m_iId = = WEAPON_ELITE & & iWeapon = = WEAPON_SHIELDGUN )
2015-09-30 03:49:22 +03:00
return false ;
2017-10-19 20:12:02 +03:00
if ( pPlayer - > m_rgpPlayerItems [ PRIMARY_WEAPON_SLOT ] & & pPlayer - > m_rgpPlayerItems [ PRIMARY_WEAPON_SLOT ] - > m_iId = = iWeapon )
2015-09-30 03:49:22 +03:00
{
if ( g_bClientPrintEnable )
{
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Cstrike_Already_Own_Weapon " ) ;
}
return false ;
}
2017-10-19 20:12:02 +03:00
if ( pPlayer - > m_rgpPlayerItems [ PISTOL_SLOT ] & & pPlayer - > m_rgpPlayerItems [ PISTOL_SLOT ] - > m_iId = = iWeapon )
2015-09-30 03:49:22 +03:00
{
if ( g_bClientPrintEnable )
{
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Cstrike_Already_Own_Weapon " ) ;
}
return false ;
}
2016-12-06 22:21:52 +03:00
if ( ! CanBuyWeaponByMaptype ( pPlayer - > m_iTeam , ( WeaponIdType ) iWeapon , CSGameRules ( ) - > m_bMapHasVIPSafetyZone = = TRUE ) )
2015-09-30 03:49:22 +03:00
{
if ( g_bClientPrintEnable )
{
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Cannot_Buy_This " ) ;
}
return false ;
}
return true ;
}
void BuyPistol ( CBasePlayer * pPlayer , int iSlot )
{
if ( iSlot < 1 | | iSlot > 5 )
return ;
2016-05-04 00:53:03 +03:00
WeaponIdType buyWeapon = WEAPON_NONE ;
2015-09-30 03:49:22 +03:00
switch ( iSlot )
{
2016-05-04 00:53:03 +03:00
case 1 :
buyWeapon = WEAPON_GLOCK18 ;
break ;
case 2 :
buyWeapon = WEAPON_USP ;
break ;
case 3 :
buyWeapon = WEAPON_P228 ;
break ;
case 4 :
buyWeapon = WEAPON_DEAGLE ;
break ;
case 5 :
buyWeapon = ( pPlayer - > m_iTeam = = CT ) ? WEAPON_FIVESEVEN : WEAPON_ELITE ;
break ;
2015-09-30 03:49:22 +03:00
}
2016-05-04 00:53:03 +03:00
BuyWeaponByWeaponID ( pPlayer , buyWeapon ) ;
2015-09-30 03:49:22 +03:00
}
void BuyShotgun ( CBasePlayer * pPlayer , int iSlot )
{
if ( iSlot < 1 | | iSlot > 2 )
return ;
2016-05-04 00:53:03 +03:00
WeaponIdType buyWeapon = WEAPON_NONE ;
2015-09-30 03:49:22 +03:00
switch ( iSlot )
{
2016-05-04 00:53:03 +03:00
case 1 :
buyWeapon = WEAPON_M3 ;
break ;
case 2 :
buyWeapon = WEAPON_XM1014 ;
break ;
2015-09-30 03:49:22 +03:00
}
2016-05-04 00:53:03 +03:00
BuyWeaponByWeaponID ( pPlayer , buyWeapon ) ;
2015-09-30 03:49:22 +03:00
}
void BuySubMachineGun ( CBasePlayer * pPlayer , int iSlot )
{
if ( iSlot < 1 | | iSlot > 4 )
return ;
2016-05-04 00:53:03 +03:00
WeaponIdType buyWeapon = WEAPON_NONE ;
2015-09-30 03:49:22 +03:00
switch ( iSlot )
{
2016-05-04 00:53:03 +03:00
case 1 :
buyWeapon = ( pPlayer - > m_iTeam = = CT ) ? WEAPON_TMP : WEAPON_MAC10 ;
break ;
case 2 :
buyWeapon = WEAPON_MP5N ;
break ;
case 3 :
buyWeapon = WEAPON_UMP45 ;
break ;
case 4 :
buyWeapon = WEAPON_P90 ;
break ;
2015-09-30 03:49:22 +03:00
}
2016-05-04 00:53:03 +03:00
BuyWeaponByWeaponID ( pPlayer , buyWeapon ) ;
2015-09-30 03:49:22 +03:00
}
void BuyRifle ( CBasePlayer * pPlayer , int iSlot )
{
if ( iSlot < 1 | | iSlot > 6 )
return ;
2016-05-04 00:53:03 +03:00
WeaponIdType buyWeapon = WEAPON_NONE ;
bool bIsCT = ( pPlayer - > m_iTeam = = CT ) ? true : false ;
2015-09-30 03:49:22 +03:00
switch ( iSlot )
{
2016-05-04 00:53:03 +03:00
case 2 :
buyWeapon = bIsCT ? WEAPON_SCOUT : WEAPON_AK47 ;
break ;
case 3 :
buyWeapon = bIsCT ? WEAPON_M4A1 : WEAPON_SCOUT ;
break ;
case 4 :
buyWeapon = bIsCT ? WEAPON_AUG : WEAPON_SG552 ;
break ;
case 5 :
buyWeapon = bIsCT ? WEAPON_SG550 : WEAPON_AWP ;
break ;
case 6 :
buyWeapon = bIsCT ? WEAPON_AWP : WEAPON_G3SG1 ;
break ;
default :
buyWeapon = bIsCT ? WEAPON_FAMAS : WEAPON_GALIL ;
break ;
2015-09-30 03:49:22 +03:00
}
2016-05-04 00:53:03 +03:00
BuyWeaponByWeaponID ( pPlayer , buyWeapon ) ;
2015-09-30 03:49:22 +03:00
}
void BuyMachineGun ( CBasePlayer * pPlayer , int iSlot )
{
if ( iSlot ! = 1 )
return ;
2016-05-04 00:53:03 +03:00
BuyWeaponByWeaponID ( pPlayer , WEAPON_M249 ) ;
2015-09-30 03:49:22 +03:00
}
2023-09-05 06:43:40 +03:00
LINK_HOOK_VOID_CHAIN ( BuyItem , ( CBasePlayer * pPlayer , int iSlot ) , pPlayer , iSlot )
void EXT_FUNC __API_HOOK ( BuyItem ) ( CBasePlayer * pPlayer , int iSlot )
2015-09-30 03:49:22 +03:00
{
int iItemPrice = 0 ;
2017-10-12 17:50:56 +03:00
const char * pszItem = nullptr ;
2015-09-30 03:49:22 +03:00
if ( ! pPlayer - > CanPlayerBuy ( true ) )
return ;
if ( pPlayer - > m_iTeam = = CT )
{
if ( iSlot < 1 | | iSlot > 8 )
return ;
}
else
{
if ( iSlot < 1 | | iSlot > 6 )
return ;
}
2016-10-05 18:27:50 +03:00
bool bFullArmor = ( pPlayer - > pev - > armorvalue > = 100 ) ;
2016-05-17 21:01:46 +03:00
bool bHasHelmet = ( pPlayer - > m_iKevlar = = ARMOR_VESTHELM ) ;
2016-05-04 00:53:03 +03:00
bool bEnoughMoney = false ;
2015-09-30 03:49:22 +03:00
switch ( iSlot )
{
case MENU_SLOT_ITEM_VEST :
{
2016-06-18 17:48:19 +03:00
# ifdef REGAMEDLL_ADD
2016-06-20 22:32:02 +03:00
if ( pPlayer - > HasRestrictItem ( ITEM_KEVLAR , ITEM_TYPE_BUYING ) )
2016-06-18 17:48:19 +03:00
return ;
# endif
2016-10-05 18:27:50 +03:00
if ( bFullArmor )
2015-09-30 03:49:22 +03:00
{
if ( g_bClientPrintEnable )
{
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Already_Have_Kevlar " ) ;
}
return ;
}
if ( pPlayer - > m_iAccount > = KEVLAR_PRICE )
{
2016-05-04 00:53:03 +03:00
if ( bHasHelmet & & g_bClientPrintEnable )
2015-09-30 03:49:22 +03:00
{
2016-05-04 00:53:03 +03:00
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Already_Have_Helmet_Bought_Kevlar " ) ;
2015-09-30 03:49:22 +03:00
}
2016-05-04 00:53:03 +03:00
bEnoughMoney = true ;
2015-09-30 03:49:22 +03:00
pszItem = " item_kevlar " ;
iItemPrice = KEVLAR_PRICE ;
}
break ;
}
case MENU_SLOT_ITEM_VESTHELM :
{
2016-06-18 17:48:19 +03:00
# ifdef REGAMEDLL_ADD
2016-06-20 22:32:02 +03:00
if ( pPlayer - > HasRestrictItem ( ITEM_ASSAULT , ITEM_TYPE_BUYING ) )
2016-06-18 17:48:19 +03:00
return ;
# endif
2016-10-05 18:27:50 +03:00
if ( bFullArmor )
2015-09-30 03:49:22 +03:00
{
2016-05-04 00:53:03 +03:00
if ( bHasHelmet )
2015-09-30 03:49:22 +03:00
{
if ( g_bClientPrintEnable )
{
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Already_Have_Kevlar_Helmet " ) ;
}
return ;
}
if ( pPlayer - > m_iAccount > = HELMET_PRICE )
{
if ( g_bClientPrintEnable )
{
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Already_Have_Kevlar_Bought_Helmet " ) ;
}
2016-05-04 00:53:03 +03:00
bEnoughMoney = true ;
2015-09-30 03:49:22 +03:00
pszItem = " item_assaultsuit " ;
iItemPrice = HELMET_PRICE ;
}
break ;
}
else
{
2016-05-04 00:53:03 +03:00
if ( bHasHelmet )
2015-09-30 03:49:22 +03:00
{
if ( pPlayer - > m_iAccount > = KEVLAR_PRICE )
{
if ( g_bClientPrintEnable )
{
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Already_Have_Helmet_Bought_Kevlar " ) ;
}
2016-05-04 00:53:03 +03:00
bEnoughMoney = true ;
2015-09-30 03:49:22 +03:00
pszItem = " item_assaultsuit " ;
iItemPrice = KEVLAR_PRICE ;
}
}
else
{
if ( pPlayer - > m_iAccount > = ASSAULTSUIT_PRICE )
{
2016-05-04 00:53:03 +03:00
bEnoughMoney = true ;
2015-09-30 03:49:22 +03:00
pszItem = " item_assaultsuit " ;
iItemPrice = ASSAULTSUIT_PRICE ;
}
}
}
break ;
}
case MENU_SLOT_ITEM_FLASHGREN :
{
2016-06-18 17:48:19 +03:00
# ifdef REGAMEDLL_ADD
2016-06-20 22:32:02 +03:00
if ( pPlayer - > HasRestrictItem ( ITEM_FLASHBANG , ITEM_TYPE_BUYING ) )
2016-06-18 17:48:19 +03:00
return ;
# endif
2016-12-06 22:21:52 +03:00
if ( pPlayer - > AmmoInventory ( AMMO_FLASHBANG ) > = MaxAmmoCarry ( WEAPON_FLASHBANG ) )
2015-09-30 03:49:22 +03:00
{
if ( g_bClientPrintEnable )
{
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Cannot_Carry_Anymore " ) ;
}
return ;
}
if ( pPlayer - > m_iAccount > = FLASHBANG_PRICE )
{
2016-05-04 00:53:03 +03:00
bEnoughMoney = true ;
2015-09-30 03:49:22 +03:00
pszItem = " weapon_flashbang " ;
iItemPrice = FLASHBANG_PRICE ;
}
break ;
}
case MENU_SLOT_ITEM_HEGREN :
{
2016-06-18 17:48:19 +03:00
# ifdef REGAMEDLL_ADD
2016-06-20 22:32:02 +03:00
if ( pPlayer - > HasRestrictItem ( ITEM_HEGRENADE , ITEM_TYPE_BUYING ) )
2016-06-18 17:48:19 +03:00
return ;
# endif
2016-12-06 22:21:52 +03:00
if ( pPlayer - > AmmoInventory ( AMMO_HEGRENADE ) > = MaxAmmoCarry ( WEAPON_HEGRENADE ) )
2015-09-30 03:49:22 +03:00
{
if ( g_bClientPrintEnable )
{
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Cannot_Carry_Anymore " ) ;
}
return ;
}
if ( pPlayer - > m_iAccount > = HEGRENADE_PRICE )
{
2016-05-04 00:53:03 +03:00
bEnoughMoney = true ;
2015-09-30 03:49:22 +03:00
pszItem = " weapon_hegrenade " ;
iItemPrice = HEGRENADE_PRICE ;
}
break ;
}
case MENU_SLOT_ITEM_SMOKEGREN :
{
2016-06-18 17:48:19 +03:00
# ifdef REGAMEDLL_ADD
2016-06-20 22:32:02 +03:00
if ( pPlayer - > HasRestrictItem ( ITEM_SMOKEGRENADE , ITEM_TYPE_BUYING ) )
2016-06-18 17:48:19 +03:00
return ;
# endif
2016-12-06 22:21:52 +03:00
if ( pPlayer - > AmmoInventory ( AMMO_SMOKEGRENADE ) > = MaxAmmoCarry ( WEAPON_SMOKEGRENADE ) )
2015-09-30 03:49:22 +03:00
{
if ( g_bClientPrintEnable )
{
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Cannot_Carry_Anymore " ) ;
}
return ;
}
if ( pPlayer - > m_iAccount > = SMOKEGRENADE_PRICE )
{
2016-05-04 00:53:03 +03:00
bEnoughMoney = true ;
2015-09-30 03:49:22 +03:00
pszItem = " weapon_smokegrenade " ;
iItemPrice = SMOKEGRENADE_PRICE ;
}
break ;
}
case MENU_SLOT_ITEM_NVG :
{
2016-06-18 17:48:19 +03:00
# ifdef REGAMEDLL_ADD
2016-06-20 22:32:02 +03:00
if ( pPlayer - > HasRestrictItem ( ITEM_NVG , ITEM_TYPE_BUYING ) )
2016-06-18 17:48:19 +03:00
return ;
# endif
2015-09-30 03:49:22 +03:00
if ( pPlayer - > m_bHasNightVision )
{
if ( g_bClientPrintEnable )
{
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Already_Have_One " ) ;
}
return ;
}
if ( pPlayer - > m_iAccount > = NVG_PRICE )
{
if ( ! ( pPlayer - > m_flDisplayHistory & DHF_NIGHTVISION ) )
{
pPlayer - > HintMessage ( " #Hint_use_nightvision " ) ;
pPlayer - > m_flDisplayHistory | = DHF_NIGHTVISION ;
}
EMIT_SOUND ( ENT ( pPlayer - > pev ) , CHAN_ITEM , " items/equip_nvg.wav " , VOL_NORM , ATTN_NORM ) ;
2016-05-04 00:53:03 +03:00
bEnoughMoney = true ;
2015-09-30 03:49:22 +03:00
pPlayer - > m_bHasNightVision = true ;
2016-05-25 16:56:48 +03:00
pPlayer - > AddAccount ( - NVG_PRICE , RT_PLAYER_BOUGHT_SOMETHING ) ;
2016-06-02 01:08:22 +03:00
pPlayer - > SendItemStatus ( ) ;
2015-09-30 03:49:22 +03:00
}
break ;
}
case MENU_SLOT_ITEM_DEFUSEKIT :
{
2016-06-18 17:48:19 +03:00
# ifdef REGAMEDLL_ADD
2016-06-20 22:32:02 +03:00
if ( pPlayer - > HasRestrictItem ( ITEM_DEFUSEKIT , ITEM_TYPE_BUYING ) )
2016-06-18 17:48:19 +03:00
return ;
# endif
2016-02-23 02:13:52 +03:00
if ( pPlayer - > m_iTeam ! = CT | | ! CSGameRules ( ) - > m_bMapHasBombTarget )
2015-09-30 03:49:22 +03:00
return ;
if ( pPlayer - > m_bHasDefuser )
{
if ( g_bClientPrintEnable )
{
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Already_Have_One " ) ;
}
return ;
}
if ( pPlayer - > m_iAccount > = DEFUSEKIT_PRICE )
{
2016-05-04 00:53:03 +03:00
bEnoughMoney = true ;
2023-10-11 01:02:27 +03:00
pPlayer - > GiveDefuser ( ) ;
2016-05-25 16:56:48 +03:00
pPlayer - > AddAccount ( - DEFUSEKIT_PRICE , RT_PLAYER_BOUGHT_SOMETHING ) ;
2015-09-30 03:49:22 +03:00
2017-11-01 18:48:28 +03:00
# ifdef REGAMEDLL_FIXES
EMIT_SOUND ( ENT ( pPlayer - > pev ) , CHAN_VOICE , " items/kevlar.wav " , VOL_NORM , ATTN_NORM ) ;
# else
2015-09-30 03:49:22 +03:00
EMIT_SOUND ( ENT ( pPlayer - > pev ) , CHAN_ITEM , " items/kevlar.wav " , VOL_NORM , ATTN_NORM ) ;
2019-06-04 17:41:30 +03:00
# endif
2015-09-30 03:49:22 +03:00
}
break ;
}
case MENU_SLOT_ITEM_SHIELD :
{
2016-06-20 22:32:02 +03:00
# ifdef REGAMEDLL_ADD
if ( pPlayer - > HasRestrictItem ( ITEM_SHIELDGUN , ITEM_TYPE_BUYING ) )
return ;
# endif
2015-09-30 03:49:22 +03:00
if ( ! CanBuyThis ( pPlayer , WEAPON_SHIELDGUN ) )
return ;
if ( pPlayer - > m_iAccount > = SHIELDGUN_PRICE )
{
2016-05-04 00:53:03 +03:00
bEnoughMoney = true ;
2016-07-14 17:12:17 +03:00
pPlayer - > DropPrimary ( ) ;
pPlayer - > GiveShield ( ) ;
2016-05-25 16:56:48 +03:00
pPlayer - > AddAccount ( - SHIELDGUN_PRICE , RT_PLAYER_BOUGHT_SOMETHING ) ;
2015-09-30 03:49:22 +03:00
EMIT_SOUND ( ENT ( pPlayer - > pev ) , CHAN_ITEM , " items/gunpickup2.wav " , VOL_NORM , ATTN_NORM ) ;
}
break ;
}
}
2016-05-04 00:53:03 +03:00
if ( ! bEnoughMoney )
2015-09-30 03:49:22 +03:00
{
if ( g_bClientPrintEnable )
{
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Not_Enough_Money " ) ;
2016-05-04 00:53:03 +03:00
BlinkAccount ( pPlayer ) ;
2015-09-30 03:49:22 +03:00
}
return ;
}
2016-12-06 22:21:52 +03:00
if ( pszItem )
2015-09-30 03:49:22 +03:00
{
2020-06-25 15:30:12 +03:00
g_bItemCreatedByBuying = true ;
2015-09-30 03:49:22 +03:00
pPlayer - > GiveNamedItem ( pszItem ) ;
2020-06-25 15:30:12 +03:00
g_bItemCreatedByBuying = false ;
2016-05-25 16:56:48 +03:00
pPlayer - > AddAccount ( - iItemPrice , RT_PLAYER_BOUGHT_SOMETHING ) ;
2015-09-30 03:49:22 +03:00
}
2016-12-06 22:21:52 +03:00
if ( TheTutor )
2015-09-30 03:49:22 +03:00
{
TheTutor - > OnEvent ( EVENT_PLAYER_BOUGHT_SOMETHING , pPlayer ) ;
}
}
2017-01-29 02:56:29 +03:00
LINK_HOOK_CHAIN ( CBaseEntity * , BuyWeaponByWeaponID , ( CBasePlayer * pPlayer , WeaponIdType weaponID ) , pPlayer , weaponID )
2016-12-06 22:21:52 +03:00
CBaseEntity * EXT_FUNC __API_HOOK ( BuyWeaponByWeaponID ) ( CBasePlayer * pPlayer , WeaponIdType weaponID )
2016-05-04 00:53:03 +03:00
{
if ( ! pPlayer - > CanPlayerBuy ( true ) )
2016-12-06 22:21:52 +03:00
return nullptr ;
2016-05-04 00:53:03 +03:00
2016-06-20 22:32:02 +03:00
# ifdef REGAMEDLL_ADD
if ( pPlayer - > HasRestrictItem ( ( ItemID ) weaponID , ITEM_TYPE_BUYING ) )
2016-12-06 22:21:52 +03:00
return nullptr ;
2016-06-20 22:32:02 +03:00
# endif
2016-05-04 00:53:03 +03:00
if ( ! CanBuyThis ( pPlayer , weaponID ) )
2016-12-06 22:21:52 +03:00
return nullptr ;
2016-05-04 00:53:03 +03:00
WeaponInfoStruct * info = GetWeaponInfo ( weaponID ) ;
if ( ! info | | ! info - > entityName )
2016-12-06 22:21:52 +03:00
return nullptr ;
2016-05-04 00:53:03 +03:00
if ( pPlayer - > m_iAccount < info - > cost )
{
if ( g_bClientPrintEnable )
{
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Not_Enough_Money " ) ;
BlinkAccount ( pPlayer ) ;
}
2016-12-06 22:21:52 +03:00
return nullptr ;
2016-05-04 00:53:03 +03:00
}
if ( IsPrimaryWeapon ( weaponID ) )
{
2016-07-14 17:12:17 +03:00
pPlayer - > DropPrimary ( ) ;
2016-05-04 00:53:03 +03:00
}
else
{
2016-07-14 17:12:17 +03:00
pPlayer - > DropSecondary ( ) ;
2016-05-04 00:53:03 +03:00
}
2016-12-06 22:21:52 +03:00
auto pEntity = pPlayer - > GiveNamedItem ( info - > entityName ) ;
2016-05-25 16:56:48 +03:00
pPlayer - > AddAccount ( - info - > cost , RT_PLAYER_BOUGHT_SOMETHING ) ;
2016-05-04 00:53:03 +03:00
2016-12-06 22:21:52 +03:00
# ifdef REGAMEDLL_ADD
2019-09-22 17:49:52 +03:00
if ( refill_bpammo_weapons . value > 1 )
{
CBasePlayerItem * pItem = static_cast < CBasePlayerItem * > ( pEntity ) ;
if ( pItem ) {
pPlayer - > GiveAmmo ( pItem - > iMaxAmmo1 ( ) , pItem - > pszAmmo1 ( ) , pItem - > iMaxAmmo1 ( ) ) ;
}
2016-12-06 22:21:52 +03:00
}
# endif
if ( TheTutor )
2016-05-04 00:53:03 +03:00
{
TheTutor - > OnEvent ( EVENT_PLAYER_BOUGHT_SOMETHING , pPlayer ) ;
}
2016-12-06 22:21:52 +03:00
return pEntity ;
2016-05-04 00:53:03 +03:00
}
2017-10-17 15:38:40 +03:00
LINK_HOOK_VOID_CHAIN ( HandleMenu_ChooseAppearance , ( CBasePlayer * pPlayer , int slot ) , pPlayer , slot )
2016-05-19 12:57:36 +03:00
2017-10-17 15:38:40 +03:00
void EXT_FUNC __API_HOOK ( HandleMenu_ChooseAppearance ) ( CBasePlayer * pPlayer , int slot )
2015-09-30 03:49:22 +03:00
{
2017-10-12 17:50:56 +03:00
int numSkins = AreRunningCZero ( ) ? CZ_NUM_SKIN : CS_NUM_SKIN ;
2015-09-30 03:49:22 +03:00
struct
{
ModelName model_id ;
char * model_name ;
int model_name_index ;
} appearance ;
Q_memset ( & appearance , 0 , sizeof ( appearance ) ) ;
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iTeam = = TERRORIST )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
if ( ( slot > numSkins | | slot < 1 ) & & ( ! TheBotProfiles - > GetCustomSkin ( slot ) | | ! pPlayer - > IsBot ( ) ) )
2015-09-30 03:49:22 +03:00
{
slot = RANDOM_LONG ( 1 , numSkins ) ;
}
switch ( slot )
{
case 1 :
appearance . model_id = MODEL_TERROR ;
appearance . model_name = " terror " ;
break ;
case 2 :
appearance . model_id = MODEL_LEET ;
appearance . model_name = " leet " ;
break ;
case 3 :
appearance . model_id = MODEL_ARCTIC ;
appearance . model_name = " arctic " ;
break ;
case 4 :
appearance . model_id = MODEL_GUERILLA ;
appearance . model_name = " guerilla " ;
break ;
case 5 :
2017-10-12 17:50:56 +03:00
if ( AreRunningCZero ( ) )
2015-09-30 03:49:22 +03:00
{
appearance . model_id = MODEL_MILITIA ;
appearance . model_name = " militia " ;
break ;
}
default :
2017-10-17 15:38:40 +03:00
if ( TheBotProfiles - > GetCustomSkinModelname ( slot ) & & pPlayer - > IsBot ( ) )
2015-09-30 03:49:22 +03:00
{
appearance . model_name = ( char * ) TheBotProfiles - > GetCustomSkinModelname ( slot ) ;
}
else
{
appearance . model_id = MODEL_TERROR ;
appearance . model_name = " terror " ;
}
break ;
}
// default T model models/player/terror/terror.mdl
appearance . model_name_index = 8 ;
}
2017-10-17 15:38:40 +03:00
else if ( pPlayer - > m_iTeam = = CT )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
if ( ( slot > numSkins | | slot < 1 ) & & ( ! TheBotProfiles - > GetCustomSkin ( slot ) | | ! pPlayer - > IsBot ( ) ) )
2015-09-30 03:49:22 +03:00
{
slot = RANDOM_LONG ( 1 , numSkins ) ;
}
switch ( slot )
{
case 1 :
appearance . model_id = MODEL_URBAN ;
appearance . model_name = " urban " ;
break ;
case 2 :
appearance . model_id = MODEL_GSG9 ;
appearance . model_name = " gsg9 " ;
break ;
case 3 :
appearance . model_id = MODEL_SAS ;
appearance . model_name = " sas " ;
break ;
case 4 :
appearance . model_id = MODEL_GIGN ;
appearance . model_name = " gign " ;
break ;
case 5 :
2017-10-12 17:50:56 +03:00
if ( AreRunningCZero ( ) )
2015-09-30 03:49:22 +03:00
{
appearance . model_id = MODEL_SPETSNAZ ;
appearance . model_name = " spetsnaz " ;
break ;
}
default :
2017-10-17 15:38:40 +03:00
if ( TheBotProfiles - > GetCustomSkinModelname ( slot ) & & pPlayer - > IsBot ( ) )
2015-09-30 03:49:22 +03:00
{
appearance . model_name = ( char * ) TheBotProfiles - > GetCustomSkinModelname ( slot ) ;
}
else
{
appearance . model_id = MODEL_URBAN ;
appearance . model_name = " urban " ;
}
break ;
}
// default CT model models/player/urban/urban.mdl
appearance . model_name_index = 9 ;
}
2017-01-20 17:52:37 +03:00
# ifdef REGAMEDLL_FIXES
2017-10-17 15:38:40 +03:00
pPlayer - > ResetMenu ( ) ;
2017-01-20 17:52:37 +03:00
# else
2017-10-17 15:38:40 +03:00
pPlayer - > m_iMenu = Menu_OFF ;
2017-01-20 17:52:37 +03:00
# endif
2015-09-30 03:49:22 +03:00
// Reset the player's state
2017-10-17 15:38:40 +03:00
switch ( pPlayer - > m_iJoiningState )
2015-09-30 03:49:22 +03:00
{
2017-01-20 17:52:37 +03:00
case JOINED :
2016-02-23 02:13:52 +03:00
CSGameRules ( ) - > CheckWinConditions ( ) ;
2017-01-20 17:52:37 +03:00
break ;
case PICKINGTEAM :
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
pPlayer - > m_iJoiningState = GETINTOGAME ;
2015-09-30 03:49:22 +03:00
2016-02-23 02:13:52 +03:00
if ( CSGameRules ( ) - > IsCareer ( ) )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
if ( ! pPlayer - > IsBot ( ) )
2015-09-30 03:49:22 +03:00
{
2016-02-23 02:13:52 +03:00
CSGameRules ( ) - > CheckWinConditions ( ) ;
2015-09-30 03:49:22 +03:00
}
}
2017-01-20 17:52:37 +03:00
break ;
}
2015-09-30 03:49:22 +03:00
}
2017-10-17 15:38:40 +03:00
pPlayer - > pev - > body = 0 ;
pPlayer - > m_iModelName = appearance . model_id ;
2015-09-30 03:49:22 +03:00
2017-10-17 15:38:40 +03:00
pPlayer - > SetClientUserInfoModel ( GET_INFO_BUFFER ( pPlayer - > edict ( ) ) , appearance . model_name ) ;
2017-10-19 20:12:02 +03:00
pPlayer - > SetNewPlayerModel ( sPlayerModelFiles [ appearance . model_name_index ] ) ;
2015-09-30 03:49:22 +03:00
2016-12-06 22:21:52 +03:00
if ( CSGameRules ( ) - > m_bMapHasVIPSafetyZone )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
if ( ! CSGameRules ( ) - > m_pVIP & & pPlayer - > m_iTeam = = CT )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
pPlayer - > MakeVIP ( ) ;
2015-09-30 03:49:22 +03:00
}
}
}
2017-10-17 15:38:40 +03:00
LINK_HOOK_CHAIN ( BOOL , HandleMenu_ChooseTeam , ( CBasePlayer * pPlayer , int slot ) , pPlayer , slot )
2016-05-19 12:57:36 +03:00
2015-09-30 03:49:22 +03:00
// returns true if the selection has been handled and the player's menu
// can be closed...false if the menu should be displayed again
2017-10-17 15:38:40 +03:00
BOOL EXT_FUNC __API_HOOK ( HandleMenu_ChooseTeam ) ( CBasePlayer * pPlayer , int slot )
2015-09-30 03:49:22 +03:00
{
// If this player is a VIP, don't allow him to switch teams/appearances unless the following conditions are met :
// a) There is another TEAM_CT player who is in the queue to be a VIP
// b) This player is dead
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_bIsVIP )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > pev - > deadflag = = DEAD_NO )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Cannot_Switch_From_VIP " ) ;
CLIENT_COMMAND ( ENT ( pPlayer - > pev ) , " slot10 \n " ) ;
2015-09-30 03:49:22 +03:00
return TRUE ;
}
2016-02-23 02:13:52 +03:00
else if ( CSGameRules ( ) - > IsVIPQueueEmpty ( ) )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Cannot_Switch_From_VIP " ) ;
CLIENT_COMMAND ( ENT ( pPlayer - > pev ) , " slot10 \n " ) ;
2015-09-30 03:49:22 +03:00
return TRUE ;
}
}
TeamName team = UNASSIGNED ;
switch ( slot )
{
case MENU_SLOT_TEAM_TERRORIST :
team = TERRORIST ;
break ;
case MENU_SLOT_TEAM_CT :
team = CT ;
break ;
case MENU_SLOT_TEAM_VIP :
{
2017-10-17 15:38:40 +03:00
if ( CSGameRules ( ) - > m_bMapHasVIPSafetyZone & & pPlayer - > m_iTeam = = CT )
2016-01-19 14:54:31 +03:00
{
2017-10-17 15:38:40 +03:00
CSGameRules ( ) - > AddToVIPQueue ( pPlayer ) ;
CLIENT_COMMAND ( ENT ( pPlayer - > pev ) , " slot10 \n " ) ;
2016-01-19 14:54:31 +03:00
return TRUE ;
}
else
2015-09-30 03:49:22 +03:00
{
return FALSE ;
}
2016-01-19 14:54:31 +03:00
break ;
2015-09-30 03:49:22 +03:00
}
case MENU_SLOT_TEAM_RANDOM :
{
// Attempt to auto-select a team
2016-06-15 16:10:40 +03:00
team = CSGameRules ( ) - > SelectDefaultTeam ( ) ;
2015-09-30 03:49:22 +03:00
if ( team = = UNASSIGNED )
{
2017-10-17 15:38:40 +03:00
if ( cv_bot_auto_vacate . value > 0.0f & & ! pPlayer - > IsBot ( ) )
2015-09-30 03:49:22 +03:00
{
team = ( RANDOM_LONG ( 0 , 1 ) = = 0 ) ? TERRORIST : CT ;
2019-06-20 22:37:44 +03:00
bool atLeastOneLeft = UTIL_KickBotFromTeam ( team ) ;
if ( ! atLeastOneLeft )
2015-09-30 03:49:22 +03:00
{
// no bots on that team, try the other
team = ( team = = CT ) ? TERRORIST : CT ;
2019-06-20 22:37:44 +03:00
atLeastOneLeft = UTIL_KickBotFromTeam ( team ) ;
if ( ! atLeastOneLeft )
2015-09-30 03:49:22 +03:00
{
// couldn't kick any bots, fail
team = UNASSIGNED ;
}
}
2019-06-20 22:37:44 +03:00
if ( atLeastOneLeft )
{
CONSOLE_ECHO ( " These bots has left the game to make room for human players. \n " ) ;
}
2015-09-30 03:49:22 +03:00
}
}
break ;
}
case MENU_SLOT_TEAM_SPECT :
{
// Prevent this is the cvar is set
// spectator proxy
2017-10-17 15:38:40 +03:00
if ( ! allow_spectators . value & & ! ( pPlayer - > pev - > flags & FL_PROXY ) )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Cannot_Be_Spectator " ) ;
CLIENT_COMMAND ( ENT ( pPlayer - > pev ) , " slot10 \n " ) ;
2015-09-30 03:49:22 +03:00
return FALSE ;
}
// are we already a spectator?
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iTeam = = SPECTATOR )
2015-09-30 03:49:22 +03:00
{
return TRUE ;
}
// Only spectate if we are in the freeze period or dead.
// This is done here just in case.
2017-10-17 15:38:40 +03:00
if ( g_pGameRules - > IsFreezePeriod ( ) | | pPlayer - > pev - > deadflag ! = DEAD_NO )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iTeam ! = UNASSIGNED & & pPlayer - > pev - > deadflag = = DEAD_NO )
2015-09-30 03:49:22 +03:00
{
2022-12-17 19:45:04 +03:00
if ( pPlayer - > Kill ( ) )
{
// add 1 to frags to balance out the 1 subtracted for killing yourself
pPlayer - > pev - > frags + + ;
}
2015-09-30 03:49:22 +03:00
}
2017-10-17 15:38:40 +03:00
pPlayer - > RemoveAllItems ( TRUE ) ;
2019-10-09 13:18:42 +03:00
# ifndef REGAMEDLL_FIXES
// NOTE: It is already does reset inside RemoveAllItems
2017-10-17 15:38:40 +03:00
pPlayer - > m_bHasC4 = false ;
2019-10-09 13:18:42 +03:00
# endif
2015-09-30 03:49:22 +03:00
2016-06-15 00:21:34 +03:00
# ifdef REGAMEDLL_FIXES
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iTeam ! = SPECTATOR )
2016-06-15 00:21:34 +03:00
# endif
2015-09-30 03:49:22 +03:00
{
// notify other clients of player joined to team spectator
2017-10-17 15:38:40 +03:00
UTIL_LogPrintf ( " \" %s<%i><%s><%s> \" joined team \" SPECTATOR \" \n " , STRING ( pPlayer - > pev - > netname ) ,
GETPLAYERUSERID ( pPlayer - > edict ( ) ) , GETPLAYERAUTHID ( pPlayer - > edict ( ) ) , GetTeam ( pPlayer - > m_iTeam ) ) ;
2015-09-30 03:49:22 +03:00
}
2017-10-17 15:38:40 +03:00
pPlayer - > m_iTeam = SPECTATOR ;
pPlayer - > m_iJoiningState = JOINED ;
2015-09-30 03:49:22 +03:00
// Reset money
2016-10-07 15:19:51 +03:00
# ifdef REGAMEDLL_ADD
2017-10-17 15:38:40 +03:00
pPlayer - > AddAccount ( 0 , RT_PLAYER_SPEC_JOIN , false ) ;
2016-10-07 15:19:51 +03:00
# else
2017-10-17 15:38:40 +03:00
pPlayer - > m_iAccount = 0 ;
2015-09-30 03:49:22 +03:00
2017-10-17 15:38:40 +03:00
MESSAGE_BEGIN ( MSG_ONE , gmsgMoney , nullptr , pPlayer - > pev ) ;
WRITE_LONG ( pPlayer - > m_iAccount ) ;
2015-09-30 03:49:22 +03:00
WRITE_BYTE ( 0 ) ;
MESSAGE_END ( ) ;
2016-10-07 15:19:51 +03:00
# endif
2015-09-30 03:49:22 +03:00
2016-07-14 17:12:17 +03:00
# ifndef REGAMEDLL_FIXES
2015-09-30 03:49:22 +03:00
MESSAGE_BEGIN ( MSG_BROADCAST , gmsgScoreInfo ) ;
2016-07-14 17:12:17 +03:00
# else
MESSAGE_BEGIN ( MSG_ALL , gmsgScoreInfo ) ;
# endif
2017-10-17 15:38:40 +03:00
WRITE_BYTE ( ENTINDEX ( pPlayer - > edict ( ) ) ) ;
WRITE_SHORT ( int ( pPlayer - > pev - > frags ) ) ;
WRITE_SHORT ( pPlayer - > m_iDeaths ) ;
2015-09-30 03:49:22 +03:00
WRITE_SHORT ( 0 ) ;
WRITE_SHORT ( 0 ) ;
MESSAGE_END ( ) ;
2017-10-17 15:38:40 +03:00
pPlayer - > m_pIntroCamera = nullptr ;
pPlayer - > m_bTeamChanged = true ;
2015-09-30 03:49:22 +03:00
2016-12-06 22:21:52 +03:00
if ( TheBots )
2015-12-05 22:40:30 +03:00
{
2017-10-17 15:38:40 +03:00
TheBots - > OnEvent ( EVENT_PLAYER_CHANGED_TEAM , pPlayer ) ;
2015-12-05 22:40:30 +03:00
}
2015-09-30 03:49:22 +03:00
2017-10-17 15:38:40 +03:00
pPlayer - > TeamChangeUpdate ( ) ;
2015-09-30 03:49:22 +03:00
2017-10-17 15:38:40 +03:00
edict_t * pentSpawnSpot = g_pGameRules - > GetPlayerSpawnSpot ( pPlayer ) ;
pPlayer - > StartObserver ( pentSpawnSpot - > v . origin , pentSpawnSpot - > v . angles ) ;
2015-09-30 03:49:22 +03:00
2016-06-15 00:21:34 +03:00
# ifndef REGAMEDLL_FIXES
// TODO: it was already sent in StartObserver
2015-09-30 03:49:22 +03:00
MESSAGE_BEGIN ( MSG_ALL , gmsgSpectator ) ;
2017-10-17 15:38:40 +03:00
WRITE_BYTE ( ENTINDEX ( pPlayer - > edict ( ) ) ) ;
2015-09-30 03:49:22 +03:00
WRITE_BYTE ( 1 ) ;
MESSAGE_END ( ) ;
2016-06-15 00:21:34 +03:00
# endif
2015-09-30 03:49:22 +03:00
// do we have fadetoblack on? (need to fade their screen back in)
2023-07-16 15:55:58 +03:00
if ( fadetoblack . value = = FADETOBLACK_STAY )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
UTIL_ScreenFade ( pPlayer , Vector ( 0 , 0 , 0 ) , 0.001 , 0 , 0 , FFADE_IN ) ;
2015-09-30 03:49:22 +03:00
}
return TRUE ;
}
else
{
2017-10-17 15:38:40 +03:00
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Cannot_Be_Spectator " ) ;
CLIENT_COMMAND ( ENT ( pPlayer - > pev ) , " slot10 \n " ) ;
2015-09-30 03:49:22 +03:00
return FALSE ;
}
break ;
}
default :
return FALSE ;
}
// If the code gets this far, the team is not TEAM_UNASSIGNED
// Player is switching to a new team (It is possible to switch to the
// same team just to choose a new appearance)
2016-02-23 02:13:52 +03:00
if ( CSGameRules ( ) - > TeamFull ( team ) )
2015-09-30 03:49:22 +03:00
{
// The specified team is full
// attempt to kick a bot to make room for this player
bool madeRoom = false ;
2017-10-17 15:38:40 +03:00
if ( cv_bot_auto_vacate . value > 0 & & ! pPlayer - > IsBot ( ) )
2015-09-30 03:49:22 +03:00
{
if ( UTIL_KickBotFromTeam ( team ) )
2019-06-20 22:37:44 +03:00
{
CONSOLE_ECHO ( " These bots has left the game to make room for human players. \n " ) ;
2015-09-30 03:49:22 +03:00
madeRoom = true ;
2019-06-20 22:37:44 +03:00
}
2015-09-30 03:49:22 +03:00
}
if ( ! madeRoom )
{
2017-10-17 15:38:40 +03:00
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , ( team = = TERRORIST ) ? " #Terrorists_Full " : " #CTs_Full " ) ;
2015-09-30 03:49:22 +03:00
return FALSE ;
}
}
// players are allowed to change to their own team so they can just change their model
2017-10-17 15:38:40 +03:00
if ( CSGameRules ( ) - > TeamStacked ( team , pPlayer - > m_iTeam ) )
2015-09-30 03:49:22 +03:00
{
// The specified team is full
2017-10-17 15:38:40 +03:00
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , ( team = = TERRORIST ) ? " #Too_Many_Terrorists " : " #Too_Many_CTs " ) ;
2015-09-30 03:49:22 +03:00
return FALSE ;
}
2017-10-17 15:38:40 +03:00
if ( team ! = SPECTATOR & & ! pPlayer - > IsBot ( )
2016-06-15 12:26:46 +03:00
# ifdef REGAMEDLL_ADD
2018-09-09 11:39:22 +03:00
& & ! ( pPlayer - > pev - > flags & FL_FAKECLIENT ) & & auto_join_team . value ! = 1.0f
2016-06-15 12:26:46 +03:00
# endif
)
2015-09-30 03:49:22 +03:00
{
int humanTeam = UNASSIGNED ;
if ( ! Q_stricmp ( humans_join_team . string , " CT " ) )
{
humanTeam = CT ;
}
else if ( ! Q_stricmp ( humans_join_team . string , " T " ) )
{
humanTeam = TERRORIST ;
}
if ( humanTeam ! = UNASSIGNED & & team ! = humanTeam )
{
2016-06-15 12:26:46 +03:00
// TODO: These localization strings are not defined on the client CS 1.6, only for CZero
# ifdef REGAMEDLL_FIXES
2017-10-17 15:38:40 +03:00
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , ( team = = TERRORIST ) ? " Humans can only be CT! " : " Humans can only be terrorists! " ) ;
2016-06-15 12:26:46 +03:00
# else
2017-10-17 15:38:40 +03:00
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , ( team = = TERRORIST ) ? " #Humans_Join_Team_CT " : " #Humans_Join_Team_T " ) ;
2016-06-15 12:26:46 +03:00
# endif
2015-09-30 03:49:22 +03:00
return FALSE ;
}
}
2016-01-19 14:54:31 +03:00
// If we already died and changed teams once, deny
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_bTeamChanged )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > pev - > deadflag ! = DEAD_NO )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Only_1_Team_Change " ) ;
2015-09-30 03:49:22 +03:00
return FALSE ;
}
}
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iTeam = = SPECTATOR & & team ! = SPECTATOR )
2015-09-30 03:49:22 +03:00
{
// If they're switching into spectator, setup spectator properties..
2017-10-17 15:38:40 +03:00
pPlayer - > m_bNotKilled = true ;
pPlayer - > m_iIgnoreGlobalChat = IGNOREMSG_NONE ;
pPlayer - > m_iTeamKills = 0 ;
2015-09-30 03:49:22 +03:00
CheckStartMoney ( ) ;
// all players start with "mp_startmoney" bucks
2016-10-07 15:19:51 +03:00
# ifdef REGAMEDLL_ADD
2017-10-17 15:38:40 +03:00
pPlayer - > AddAccount ( startmoney . value , RT_PLAYER_SPEC_JOIN , false ) ;
2016-10-07 15:19:51 +03:00
# else
2017-10-17 15:38:40 +03:00
pPlayer - > m_iAccount = int ( startmoney . value ) ;
2016-10-07 15:19:51 +03:00
# endif
2015-09-30 03:49:22 +03:00
2017-10-17 15:38:40 +03:00
pPlayer - > pev - > solid = SOLID_NOT ;
pPlayer - > pev - > movetype = MOVETYPE_NOCLIP ;
pPlayer - > pev - > effects = ( EF_NODRAW | EF_NOINTERP ) ;
pPlayer - > pev - > takedamage = DAMAGE_NO ;
pPlayer - > pev - > deadflag = DEAD_DEAD ;
pPlayer - > pev - > punchangle = g_vecZero ;
2015-09-30 03:49:22 +03:00
2017-10-17 15:38:40 +03:00
pPlayer - > m_bHasNightVision = false ;
pPlayer - > m_iHostagesKilled = 0 ;
pPlayer - > m_fDeadTime = 0 ;
pPlayer - > has_disconnected = false ;
2015-09-30 03:49:22 +03:00
2017-01-20 17:52:37 +03:00
# ifdef REGAMEDLL_ADD
2017-10-17 15:38:40 +03:00
pPlayer - > m_iJoiningState = PICKINGTEAM ;
2017-01-20 17:52:37 +03:00
# else
2017-10-17 15:38:40 +03:00
pPlayer - > pev - > velocity = g_vecZero ;
pPlayer - > m_iJoiningState = GETINTOGAME ;
2017-01-20 17:52:37 +03:00
# endif
2017-10-17 15:38:40 +03:00
pPlayer - > SendItemStatus ( ) ;
2015-09-30 03:49:22 +03:00
2017-01-20 17:52:37 +03:00
# ifndef REGAMEDLL_ADD
2017-10-17 15:38:40 +03:00
SET_CLIENT_MAXSPEED ( ENT ( pPlayer - > pev ) , 1 ) ;
2017-01-20 17:52:37 +03:00
# endif
2017-10-17 15:38:40 +03:00
SET_MODEL ( ENT ( pPlayer - > pev ) , " models/player.mdl " ) ;
2015-09-30 03:49:22 +03:00
}
2016-06-15 12:26:46 +03:00
# ifdef REGAMEDLL_ADD
if ( ! CSGameRules ( ) - > ShouldSkipShowMenu ( ) )
# endif
2015-09-30 03:49:22 +03:00
{
2016-06-15 12:26:46 +03:00
if ( ! CSGameRules ( ) - > IsCareer ( ) )
2015-09-30 03:49:22 +03:00
{
2016-06-15 12:26:46 +03:00
switch ( team )
{
case CT :
2017-10-12 17:50:56 +03:00
if ( AreRunningCZero ( ) )
2017-10-17 15:38:40 +03:00
ShowVGUIMenu ( pPlayer , VGUI_Menu_Class_CT , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 ) , " #CT_Select " ) ;
2016-06-15 12:26:46 +03:00
else
2017-10-17 15:38:40 +03:00
ShowVGUIMenu ( pPlayer , VGUI_Menu_Class_CT , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 ) , " #CT_Select " ) ;
2016-06-15 12:26:46 +03:00
break ;
2015-09-30 03:49:22 +03:00
2016-06-15 12:26:46 +03:00
case TERRORIST :
2017-10-12 17:50:56 +03:00
if ( AreRunningCZero ( ) )
2017-10-17 15:38:40 +03:00
ShowVGUIMenu ( pPlayer , VGUI_Menu_Class_T , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 ) , " #Terrorist_Select " ) ;
2016-06-15 12:26:46 +03:00
else
2017-10-17 15:38:40 +03:00
ShowVGUIMenu ( pPlayer , VGUI_Menu_Class_T , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 ) , " #Terrorist_Select " ) ;
2016-06-15 12:26:46 +03:00
break ;
}
2015-09-30 03:49:22 +03:00
}
2017-10-17 15:38:40 +03:00
pPlayer - > m_iMenu = Menu_ChooseAppearance ;
2015-09-30 03:49:22 +03:00
2016-06-15 12:26:46 +03:00
// Show the appropriate Choose Appearance menu
2022-12-17 19:45:04 +03:00
// This must come before pPlayer->Kill() for CheckWinConditions() to function properly
2017-10-17 15:38:40 +03:00
if ( pPlayer - > pev - > deadflag = = DEAD_NO )
2016-06-15 12:26:46 +03:00
{
2022-12-17 19:45:04 +03:00
pPlayer - > Kill ( ) ;
2016-06-15 12:26:46 +03:00
}
2015-09-30 03:49:22 +03:00
}
2016-12-10 21:27:53 +03:00
TeamName oldTeam ;
char * szOldTeam , * szNewTeam ;
2015-09-30 03:49:22 +03:00
// Switch their actual team...
2017-10-17 15:38:40 +03:00
pPlayer - > m_bTeamChanged = true ;
oldTeam = pPlayer - > m_iTeam ;
pPlayer - > m_iTeam = team ;
2015-09-30 03:49:22 +03:00
2016-12-06 22:21:52 +03:00
if ( TheBots )
2015-12-05 22:40:30 +03:00
{
2017-10-17 15:38:40 +03:00
TheBots - > OnEvent ( EVENT_PLAYER_CHANGED_TEAM , pPlayer ) ;
2015-12-05 22:40:30 +03:00
}
2015-09-30 03:49:22 +03:00
2017-10-17 15:38:40 +03:00
pPlayer - > TeamChangeUpdate ( ) ;
2015-09-30 03:49:22 +03:00
szOldTeam = GetTeam ( oldTeam ) ;
szNewTeam = GetTeam ( team ) ;
// Notify others that this player has joined a new team
2016-02-23 02:13:52 +03:00
UTIL_ClientPrintAll ( HUD_PRINTNOTIFY , ( team = = TERRORIST ) ? " #Game_join_terrorist " : " #Game_join_ct " ,
2017-10-17 15:38:40 +03:00
( STRING ( pPlayer - > pev - > netname ) & & STRING ( pPlayer - > pev - > netname ) [ 0 ] ! = 0 ) ? STRING ( pPlayer - > pev - > netname ) : " <unconnected> " ) ;
2015-09-30 03:49:22 +03:00
2017-10-17 15:38:40 +03:00
UTIL_LogPrintf ( " \" %s<%i><%s><%s> \" joined team \" %s \" \n " , STRING ( pPlayer - > pev - > netname ) , GETPLAYERUSERID ( pPlayer - > edict ( ) ) , GETPLAYERAUTHID ( pPlayer - > edict ( ) ) , szOldTeam , szNewTeam ) ;
2015-09-30 03:49:22 +03:00
return TRUE ;
}
2017-10-17 15:38:40 +03:00
void Radio1 ( CBasePlayer * pPlayer , int slot )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_flRadioTime > = gpGlobals - > time )
2015-09-30 03:49:22 +03:00
return ;
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iRadioMessages < = 0 )
2015-09-30 03:49:22 +03:00
return ;
2017-10-17 15:38:40 +03:00
pPlayer - > m_iRadioMessages - - ;
2019-07-30 15:30:34 +03:00
pPlayer - > m_flRadioTime = gpGlobals - > time + CGameRules : : GetRadioTimeout ( ) ;
2015-09-30 03:49:22 +03:00
switch ( slot )
{
case 1 :
2017-10-17 15:38:40 +03:00
pPlayer - > Radio ( " %!MRAD_COVERME " , " #Cover_me " ) ;
2015-09-30 03:49:22 +03:00
break ;
case 2 :
2017-10-17 15:38:40 +03:00
pPlayer - > Radio ( " %!MRAD_TAKEPOINT " , " #You_take_the_point " ) ;
2015-09-30 03:49:22 +03:00
break ;
case 3 :
2017-10-17 15:38:40 +03:00
pPlayer - > Radio ( " %!MRAD_POSITION " , " #Hold_this_position " ) ;
2015-09-30 03:49:22 +03:00
break ;
case 4 :
2017-10-17 15:38:40 +03:00
pPlayer - > Radio ( " %!MRAD_REGROUP " , " #Regroup_team " ) ;
2015-09-30 03:49:22 +03:00
break ;
case 5 :
2017-10-17 15:38:40 +03:00
pPlayer - > Radio ( " %!MRAD_FOLLOWME " , " #Follow_me " ) ;
2015-09-30 03:49:22 +03:00
break ;
case 6 :
2017-10-17 15:38:40 +03:00
pPlayer - > Radio ( " %!MRAD_HITASSIST " , " #Taking_fire " ) ;
2015-09-30 03:49:22 +03:00
break ;
}
2016-12-06 22:21:52 +03:00
if ( TheBots )
2015-12-05 22:40:30 +03:00
{
2017-10-17 15:38:40 +03:00
TheBots - > OnEvent ( ( GameEventType ) ( EVENT_START_RADIO_1 + slot ) , pPlayer ) ;
2015-12-05 22:40:30 +03:00
}
2015-09-30 03:49:22 +03:00
}
2017-10-17 15:38:40 +03:00
void Radio2 ( CBasePlayer * pPlayer , int slot )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_flRadioTime > = gpGlobals - > time )
2015-09-30 03:49:22 +03:00
return ;
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iRadioMessages < = 0 )
2015-09-30 03:49:22 +03:00
return ;
2017-10-17 15:38:40 +03:00
pPlayer - > m_iRadioMessages - - ;
2019-07-30 15:30:34 +03:00
pPlayer - > m_flRadioTime = gpGlobals - > time + CGameRules : : GetRadioTimeout ( ) ;
2015-09-30 03:49:22 +03:00
switch ( slot )
{
case 1 :
2017-10-17 15:38:40 +03:00
pPlayer - > Radio ( " %!MRAD_GO " , " #Go_go_go " ) ;
2015-09-30 03:49:22 +03:00
break ;
case 2 :
2017-10-17 15:38:40 +03:00
pPlayer - > Radio ( " %!MRAD_FALLBACK " , " #Team_fall_back " ) ;
2015-09-30 03:49:22 +03:00
break ;
case 3 :
2017-10-17 15:38:40 +03:00
pPlayer - > Radio ( " %!MRAD_STICKTOG " , " #Stick_together_team " ) ;
2015-09-30 03:49:22 +03:00
break ;
case 4 :
2017-10-17 15:38:40 +03:00
pPlayer - > Radio ( " %!MRAD_GETINPOS " , " #Get_in_position_and_wait " ) ;
2015-09-30 03:49:22 +03:00
break ;
case 5 :
2017-10-17 15:38:40 +03:00
pPlayer - > Radio ( " %!MRAD_STORMFRONT " , " #Storm_the_front " ) ;
2015-09-30 03:49:22 +03:00
break ;
case 6 :
2017-10-17 15:38:40 +03:00
pPlayer - > Radio ( " %!MRAD_REPORTIN " , " #Report_in_team " ) ;
2015-09-30 03:49:22 +03:00
break ;
}
2016-12-06 22:21:52 +03:00
if ( TheBots )
2015-12-05 22:40:30 +03:00
{
2017-10-17 15:38:40 +03:00
TheBots - > OnEvent ( ( GameEventType ) ( EVENT_START_RADIO_2 + slot ) , pPlayer ) ;
2015-12-05 22:40:30 +03:00
}
2015-09-30 03:49:22 +03:00
}
2017-10-17 15:38:40 +03:00
void Radio3 ( CBasePlayer * pPlayer , int slot )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_flRadioTime > = gpGlobals - > time )
2015-09-30 03:49:22 +03:00
return ;
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iRadioMessages < = 0 )
2015-09-30 03:49:22 +03:00
return ;
2017-10-17 15:38:40 +03:00
pPlayer - > m_iRadioMessages - - ;
2019-07-30 15:30:34 +03:00
pPlayer - > m_flRadioTime = gpGlobals - > time + CGameRules : : GetRadioTimeout ( ) ;
2015-09-30 03:49:22 +03:00
switch ( slot )
{
case 1 :
if ( RANDOM_LONG ( 0 , 1 ) )
2017-10-17 15:38:40 +03:00
pPlayer - > Radio ( " %!MRAD_AFFIRM " , " #Affirmative " ) ;
2015-09-30 03:49:22 +03:00
else
2017-10-17 15:38:40 +03:00
pPlayer - > Radio ( " %!MRAD_ROGER " , " #Roger_that " ) ;
2015-09-30 03:49:22 +03:00
break ;
case 2 :
2017-10-17 15:38:40 +03:00
pPlayer - > Radio ( " %!MRAD_ENEMYSPOT " , " #Enemy_spotted " ) ;
2015-09-30 03:49:22 +03:00
break ;
case 3 :
2017-10-17 15:38:40 +03:00
pPlayer - > Radio ( " %!MRAD_BACKUP " , " #Need_backup " ) ;
2015-09-30 03:49:22 +03:00
break ;
case 4 :
2017-10-17 15:38:40 +03:00
pPlayer - > Radio ( " %!MRAD_CLEAR " , " #Sector_clear " ) ;
2015-09-30 03:49:22 +03:00
break ;
case 5 :
2017-10-17 15:38:40 +03:00
pPlayer - > Radio ( " %!MRAD_INPOS " , " #In_position " ) ;
2015-09-30 03:49:22 +03:00
break ;
case 6 :
2017-10-17 15:38:40 +03:00
pPlayer - > Radio ( " %!MRAD_REPRTINGIN " , " #Reporting_in " ) ;
2015-09-30 03:49:22 +03:00
break ;
case 7 :
2017-10-17 15:38:40 +03:00
pPlayer - > Radio ( " %!MRAD_BLOW " , " #Get_out_of_there " ) ;
2015-09-30 03:49:22 +03:00
break ;
case 8 :
2017-10-17 15:38:40 +03:00
pPlayer - > Radio ( " %!MRAD_NEGATIVE " , " #Negative " ) ;
2015-09-30 03:49:22 +03:00
break ;
case 9 :
2017-10-17 15:38:40 +03:00
pPlayer - > Radio ( " %!MRAD_ENEMYDOWN " , " #Enemy_down " ) ;
2015-09-30 03:49:22 +03:00
break ;
}
2016-12-06 22:21:52 +03:00
if ( TheBots )
2015-12-05 22:40:30 +03:00
{
2017-10-17 15:38:40 +03:00
TheBots - > OnEvent ( ( GameEventType ) ( EVENT_START_RADIO_3 + slot ) , pPlayer ) ;
2015-12-05 22:40:30 +03:00
}
2015-09-30 03:49:22 +03:00
}
2017-10-17 15:38:40 +03:00
LINK_HOOK_CHAIN ( bool , BuyGunAmmo , ( CBasePlayer * pPlayer , CBasePlayerItem * weapon , bool bBlinkMoney ) , pPlayer , weapon , bBlinkMoney )
2016-12-06 22:21:52 +03:00
2017-10-17 15:38:40 +03:00
bool EXT_FUNC __API_HOOK ( BuyGunAmmo ) ( CBasePlayer * pPlayer , CBasePlayerItem * weapon , bool bBlinkMoney )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
if ( ! pPlayer - > CanPlayerBuy ( true ) )
2015-09-30 03:49:22 +03:00
return false ;
// Ensure that the weapon uses ammo
int nAmmo = weapon - > PrimaryAmmoIndex ( ) ;
if ( nAmmo = = - 1 )
return false ;
// Can only buy if the player does not already have full ammo
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_rgAmmo [ nAmmo ] > = weapon - > iMaxAmmo1 ( ) )
2015-09-30 03:49:22 +03:00
return false ;
2016-05-04 00:53:03 +03:00
WeaponInfoStruct * info = GetWeaponInfo ( weapon - > m_iId ) ;
2016-07-17 23:31:56 +03:00
if ( ! info )
{
2015-09-30 03:49:22 +03:00
ALERT ( at_console , " Tried to buy ammo for an unrecognized gun \n " ) ;
return false ;
}
// Purchase the ammo if the player has enough money
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iAccount > = info - > clipCost )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
# ifdef REGAMEDLL_FIXES
2023-10-25 07:37:32 +03:00
if ( pPlayer - > GiveAmmo ( info - > buyClipSize , weapon - > pszAmmo1 ( ) , weapon - > iMaxAmmo1 ( ) ) = = - 1 )
2017-10-17 15:38:40 +03:00
return false ;
2017-11-04 01:32:28 +03:00
EMIT_SOUND ( ENT ( weapon - > pev ) , CHAN_ITEM , " items/9mmclip1.wav " , VOL_NORM , ATTN_NORM ) ;
2017-10-17 15:38:40 +03:00
# else
2017-11-04 01:32:28 +03:00
if ( ! pPlayer - > GiveNamedItemEx ( info - > ammoName1 ) ) {
return false ;
}
2017-10-17 15:38:40 +03:00
# endif
pPlayer - > AddAccount ( - info - > clipCost , RT_PLAYER_BOUGHT_SOMETHING ) ;
2015-09-30 03:49:22 +03:00
return true ;
}
if ( bBlinkMoney )
{
if ( g_bClientPrintEnable )
{
// Not enough money.. let the player know
2017-10-17 15:38:40 +03:00
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Not_Enough_Money " ) ;
BlinkAccount ( pPlayer ) ;
2015-09-30 03:49:22 +03:00
}
}
return false ;
}
2017-10-17 15:38:40 +03:00
bool BuyAmmo ( CBasePlayer * pPlayer , int nSlot , bool bBlinkMoney )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
if ( ! pPlayer - > CanPlayerBuy ( true ) )
2015-09-30 03:49:22 +03:00
return false ;
if ( nSlot < PRIMARY_WEAPON_SLOT | | nSlot > PISTOL_SLOT )
return false ;
// Buy one ammo clip for all weapons in the given slot
//
2016-05-04 00:53:03 +03:00
// nSlot == 1 : Primary weapons
// nSlot == 2 : Secondary weapons
2015-09-30 03:49:22 +03:00
2017-10-19 20:12:02 +03:00
CBasePlayerItem * pItem = pPlayer - > m_rgpPlayerItems [ nSlot ] ;
2015-09-30 03:49:22 +03:00
2017-10-17 15:38:40 +03:00
if ( pPlayer - > HasShield ( ) )
2015-09-30 03:49:22 +03:00
{
2017-10-19 20:12:02 +03:00
if ( pPlayer - > m_rgpPlayerItems [ PISTOL_SLOT ] )
pItem = pPlayer - > m_rgpPlayerItems [ PISTOL_SLOT ] ;
2015-09-30 03:49:22 +03:00
}
2016-12-06 22:21:52 +03:00
if ( pItem )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
while ( BuyGunAmmo ( pPlayer , pItem , bBlinkMoney ) )
2015-09-30 03:49:22 +03:00
{
pItem = pItem - > m_pNext ;
if ( ! pItem )
{
return true ;
}
}
}
return false ;
}
CBaseEntity * EntityFromUserID ( int userID )
{
2017-10-12 17:50:56 +03:00
CBaseEntity * pTempEntity = nullptr ;
2016-12-06 22:21:52 +03:00
while ( ( pTempEntity = UTIL_FindEntityByClassname ( pTempEntity , " player " ) ) )
2015-09-30 03:49:22 +03:00
{
if ( FNullEnt ( pTempEntity - > edict ( ) ) )
break ;
2016-03-17 20:44:52 +03:00
CBasePlayer * pTempPlayer = GetClassPtr < CCSPlayer > ( ( CBasePlayer * ) pTempEntity - > pev ) ;
2015-09-30 03:49:22 +03:00
if ( pTempPlayer - > m_iTeam ! = UNASSIGNED & & userID = = GETPLAYERUSERID ( pTempEntity - > edict ( ) ) )
{
return pTempPlayer ;
}
}
2017-10-12 17:50:56 +03:00
return nullptr ;
2015-09-30 03:49:22 +03:00
}
2016-02-04 03:18:26 +03:00
NOXREF int CountPlayersInServer ( )
2015-09-30 03:49:22 +03:00
{
int count = 0 ;
2017-10-12 17:50:56 +03:00
CBaseEntity * pTempEntity = nullptr ;
2016-12-06 22:21:52 +03:00
while ( ( pTempEntity = UTIL_FindEntityByClassname ( pTempEntity , " player " ) ) )
2015-09-30 03:49:22 +03:00
{
if ( FNullEnt ( pTempEntity - > edict ( ) ) )
break ;
2016-03-17 20:44:52 +03:00
CBasePlayer * pTempPlayer = GetClassPtr < CCSPlayer > ( ( CBasePlayer * ) pTempEntity - > pev ) ;
2015-09-30 03:49:22 +03:00
if ( pTempPlayer - > m_iTeam ! = UNASSIGNED )
{
count + + ;
}
}
return count ;
}
// Handles the special "buy" alias commands we're creating to accommodate the buy
// scripts players use (now that we've rearranged the buy menus and broken the scripts)
// ** Returns TRUE if we've handled the command **
BOOL HandleBuyAliasCommands ( CBasePlayer * pPlayer , const char * pszCommand )
{
// Let them buy it if it's got a weapon data string.
BOOL bRetVal = FALSE ;
2017-10-12 17:50:56 +03:00
const char * pszFailItem = nullptr ;
2015-09-30 03:49:22 +03:00
WeaponIdType weaponID = WEAPON_NONE ;
const char * weaponFailName = BuyAliasToWeaponID ( pszCommand , weaponID ) ;
2016-10-05 18:27:50 +03:00
// Ok, we have weapon info ID.
2015-09-30 03:49:22 +03:00
if ( weaponID ! = WEAPON_NONE )
{
// assasination maps have a specific set of weapons that can be used in them.
2016-12-06 22:21:52 +03:00
if ( CanBuyWeaponByMaptype ( pPlayer - > m_iTeam , weaponID , CSGameRules ( ) - > m_bMapHasVIPSafetyZone = = TRUE ) )
2015-09-30 03:49:22 +03:00
{
bRetVal = TRUE ;
BuyWeaponByWeaponID ( pPlayer , weaponID ) ;
}
2016-12-06 22:21:52 +03:00
else if ( weaponFailName )
2015-09-30 03:49:22 +03:00
{
bRetVal = TRUE ;
if ( g_bClientPrintEnable )
{
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Alias_Not_Avail " , weaponFailName ) ;
}
}
else
{
bRetVal = TRUE ;
if ( g_bClientPrintEnable )
{
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Cannot_Buy_This " ) ;
}
}
}
else
{
// primary ammo
if ( FStrEq ( pszCommand , " primammo " ) )
{
bRetVal = TRUE ;
// Buy as much primary ammo as possible
// Blink money only if player doesn't have enough for the
// first clip
if ( BuyAmmo ( pPlayer , PRIMARY_WEAPON_SLOT , true ) )
{
while ( BuyAmmo ( pPlayer , PRIMARY_WEAPON_SLOT , false ) )
;
2016-12-06 22:21:52 +03:00
if ( TheTutor )
2015-09-30 03:49:22 +03:00
{
TheTutor - > OnEvent ( EVENT_PLAYER_BOUGHT_SOMETHING , pPlayer ) ;
}
}
}
// secondary ammo
else if ( FStrEq ( pszCommand , " secammo " ) )
{
bRetVal = TRUE ;
// Buy as much secondary ammo as possible
// Blink money only if player doesn't have enough for the
// first clip
if ( BuyAmmo ( pPlayer , PISTOL_SLOT , true ) )
{
while ( BuyAmmo ( pPlayer , PISTOL_SLOT , false ) )
;
2016-12-06 22:21:52 +03:00
if ( TheTutor )
2015-09-30 03:49:22 +03:00
{
TheTutor - > OnEvent ( EVENT_PLAYER_BOUGHT_SOMETHING , pPlayer ) ;
}
}
}
// equipment
else if ( FStrEq ( pszCommand , " vest " ) )
{
bRetVal = TRUE ;
BuyItem ( pPlayer , MENU_SLOT_ITEM_VEST ) ;
}
else if ( FStrEq ( pszCommand , " vesthelm " ) )
{
bRetVal = TRUE ;
BuyItem ( pPlayer , MENU_SLOT_ITEM_VESTHELM ) ;
}
else if ( FStrEq ( pszCommand , " flash " ) )
{
bRetVal = TRUE ;
BuyItem ( pPlayer , MENU_SLOT_ITEM_FLASHGREN ) ;
}
else if ( FStrEq ( pszCommand , " hegren " ) )
{
bRetVal = TRUE ;
BuyItem ( pPlayer , MENU_SLOT_ITEM_HEGREN ) ;
}
else if ( FStrEq ( pszCommand , " sgren " ) )
{
bRetVal = TRUE ;
BuyItem ( pPlayer , MENU_SLOT_ITEM_SMOKEGREN ) ;
}
else if ( FStrEq ( pszCommand , " nvgs " ) )
{
bRetVal = TRUE ;
BuyItem ( pPlayer , MENU_SLOT_ITEM_NVG ) ;
}
else if ( FStrEq ( pszCommand , " defuser " ) )
{
bRetVal = TRUE ;
if ( pPlayer - > m_iTeam = = CT )
{
BuyItem ( pPlayer , MENU_SLOT_ITEM_DEFUSEKIT ) ;
}
else
{
// fail gracefully
pszFailItem = " #Bomb_Defusal_Kit " ;
}
}
else if ( FStrEq ( pszCommand , " shield " ) )
{
bRetVal = TRUE ;
if ( pPlayer - > m_iTeam = = CT )
{
BuyItem ( pPlayer , MENU_SLOT_ITEM_SHIELD ) ;
}
else
{
// fail gracefully
pszFailItem = " #TactShield_Desc " ;
}
}
}
2016-12-06 22:21:52 +03:00
if ( g_bClientPrintEnable & & pszFailItem )
2015-09-30 03:49:22 +03:00
{
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Alias_Not_Avail " , pszFailItem ) ;
}
pPlayer - > BuildRebuyStruct ( ) ;
return bRetVal ;
}
2016-05-04 00:53:03 +03:00
struct RadioStruct
2015-09-30 03:49:22 +03:00
{
2016-05-04 00:53:03 +03:00
int slot ;
void ( * func ) ( CBasePlayer * , int ) ;
const char * alias ;
} radioInfo [ ] = {
{ 1 , Radio1 , " coverme " } ,
{ 2 , Radio1 , " takepoint " } ,
{ 3 , Radio1 , " holdpos " } ,
{ 4 , Radio1 , " regroup " } ,
{ 5 , Radio1 , " followme " } ,
{ 6 , Radio1 , " takingfire " } ,
{ 1 , Radio2 , " go " } ,
{ 2 , Radio2 , " fallback " } ,
{ 3 , Radio2 , " sticktog " } ,
{ 4 , Radio2 , " getinpos " } ,
{ 5 , Radio2 , " stormfront " } ,
{ 6 , Radio2 , " report " } ,
{ 1 , Radio3 , " roger " } ,
{ 2 , Radio3 , " enemyspot " } ,
{ 3 , Radio3 , " needbackup " } ,
{ 4 , Radio3 , " sectorclear " } ,
{ 5 , Radio3 , " inposition " } ,
{ 6 , Radio3 , " reportingin " } ,
{ 7 , Radio3 , " getout " } ,
{ 8 , Radio3 , " negative " } ,
{ 9 , Radio3 , " enemydown " } ,
} ;
2015-09-30 03:49:22 +03:00
2016-05-04 00:53:03 +03:00
BOOL HandleRadioAliasCommands ( CBasePlayer * pPlayer , const char * pszCommand )
{
for ( auto & radio : radioInfo )
2015-09-30 03:49:22 +03:00
{
2016-05-04 00:53:03 +03:00
if ( FStrEq ( pszCommand , radio . alias ) )
{
radio . func ( pPlayer , radio . slot ) ;
return TRUE ;
2017-01-29 02:56:29 +03:00
}
2015-09-30 03:49:22 +03:00
}
2016-05-04 00:53:03 +03:00
return FALSE ;
2015-09-30 03:49:22 +03:00
}
2017-01-20 17:52:37 +03:00
void EXT_FUNC InternalCommand ( edict_t * pEntity , const char * pcmd , const char * parg1 )
2015-09-30 03:49:22 +03:00
{
2017-10-12 17:50:56 +03:00
const char * pstr = nullptr ;
2015-09-30 03:49:22 +03:00
entvars_t * pev = & pEntity - > v ;
2017-10-17 15:38:40 +03:00
CBasePlayer * pPlayer = GetClassPtr < CCSPlayer > ( ( CBasePlayer * ) pev ) ;
2015-09-30 03:49:22 +03:00
if ( FStrEq ( pcmd , " say " ) )
{
2017-10-17 15:38:40 +03:00
if ( gpGlobals - > time > = pPlayer - > m_flLastCommandTime [ CMD_SAY ] )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
pPlayer - > m_flLastCommandTime [ CMD_SAY ] = gpGlobals - > time + 0.3f ;
2016-07-14 17:12:17 +03:00
Host_Say ( pEntity , FALSE ) ;
2015-09-30 03:49:22 +03:00
}
}
else if ( FStrEq ( pcmd , " say_team " ) )
{
2017-10-17 15:38:40 +03:00
if ( gpGlobals - > time > = pPlayer - > m_flLastCommandTime [ CMD_SAYTEAM ] )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
pPlayer - > m_flLastCommandTime [ CMD_SAYTEAM ] = gpGlobals - > time + 0.3f ;
2016-07-14 17:12:17 +03:00
Host_Say ( pEntity , TRUE ) ;
2015-09-30 03:49:22 +03:00
}
}
else if ( FStrEq ( pcmd , " fullupdate " ) )
{
2017-10-17 15:38:40 +03:00
if ( gpGlobals - > time > = pPlayer - > m_flLastCommandTime [ CMD_FULLUPDATE ] )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
pPlayer - > m_flLastCommandTime [ CMD_FULLUPDATE ] = gpGlobals - > time + 0.6f ;
pPlayer - > ForceClientDllUpdate ( ) ;
2015-09-30 03:49:22 +03:00
}
}
else if ( FStrEq ( pcmd , " vote " ) )
{
2017-10-17 15:38:40 +03:00
if ( gpGlobals - > time > = pPlayer - > m_flLastCommandTime [ CMD_VOTE ] )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
pPlayer - > m_flLastCommandTime [ CMD_VOTE ] = gpGlobals - > time + 0.3f ;
2015-09-30 03:49:22 +03:00
2017-10-17 15:38:40 +03:00
if ( gpGlobals - > time < pPlayer - > m_flNextVoteTime )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
ClientPrint ( pPlayer - > pev , HUD_PRINTCONSOLE , " #Wait_3_Seconds " ) ;
2015-09-30 03:49:22 +03:00
return ;
}
2017-10-17 15:38:40 +03:00
pPlayer - > m_flNextVoteTime = gpGlobals - > time + 3 ;
2015-09-30 03:49:22 +03:00
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iTeam ! = UNASSIGNED )
2015-09-30 03:49:22 +03:00
{
int iVoteID ;
2019-01-07 12:55:29 +03:00
bool bVoteFail = false ;
2015-09-30 03:49:22 +03:00
int iNumArgs = CMD_ARGC_ ( ) ;
2017-01-20 17:52:37 +03:00
int iVoteLength = Q_strlen ( parg1 ) ;
2015-09-30 03:49:22 +03:00
if ( iNumArgs ! = 2 | | iVoteLength < = 0 | | iVoteLength > 6 )
{
2019-01-07 12:55:29 +03:00
bVoteFail = true ;
2015-09-30 03:49:22 +03:00
}
2017-01-20 17:52:37 +03:00
iVoteID = Q_atoi ( parg1 ) ;
2015-09-30 03:49:22 +03:00
if ( iVoteID < = 0 )
{
2019-01-07 12:55:29 +03:00
bVoteFail = true ;
2015-09-30 03:49:22 +03:00
}
2019-01-07 12:55:29 +03:00
if ( bVoteFail )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
ListPlayers ( pPlayer ) ;
ClientPrint ( pPlayer - > pev , HUD_PRINTCONSOLE , " #Game_vote_usage " ) ;
2015-09-30 03:49:22 +03:00
return ;
}
2017-10-17 15:38:40 +03:00
if ( CountTeamPlayers ( pPlayer - > m_iTeam ) < 3 )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
ClientPrint ( pPlayer - > pev , HUD_PRINTCONSOLE , " #Cannot_Vote_With_Less_Than_Three " ) ;
2015-09-30 03:49:22 +03:00
return ;
}
CBaseEntity * pKickEntity = EntityFromUserID ( iVoteID ) ;
2016-12-06 22:21:52 +03:00
if ( pKickEntity )
2015-09-30 03:49:22 +03:00
{
2016-03-17 20:44:52 +03:00
CBasePlayer * pKickPlayer = GetClassPtr < CCSPlayer > ( ( CBasePlayer * ) pKickEntity - > pev ) ;
2015-09-30 03:49:22 +03:00
2017-10-17 15:38:40 +03:00
if ( pKickPlayer - > m_iTeam ! = pPlayer - > m_iTeam )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
ClientPrint ( pPlayer - > pev , HUD_PRINTCONSOLE , " #Game_vote_players_on_your_team " ) ;
2015-09-30 03:49:22 +03:00
return ;
}
2017-10-17 15:38:40 +03:00
if ( pKickPlayer = = pPlayer )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
ClientPrint ( pPlayer - > pev , HUD_PRINTCONSOLE , " #Game_vote_not_yourself " ) ;
2015-09-30 03:49:22 +03:00
return ;
}
2017-10-17 15:38:40 +03:00
ClientPrint ( pPlayer - > pev , HUD_PRINTCONSOLE , " #Game_vote_cast " , UTIL_dtos1 ( iVoteID ) ) ;
pPlayer - > m_iCurrentKickVote = iVoteID ;
ProcessKickVote ( pPlayer , pKickPlayer ) ;
2015-09-30 03:49:22 +03:00
}
else
{
2017-10-17 15:38:40 +03:00
ListPlayers ( pPlayer ) ;
ClientPrint ( pPlayer - > pev , HUD_PRINTCONSOLE , " #Game_vote_player_not_found " , UTIL_dtos1 ( iVoteID ) ) ;
2015-09-30 03:49:22 +03:00
}
}
}
}
else if ( FStrEq ( pcmd , " listmaps " ) )
{
2017-10-17 15:38:40 +03:00
if ( gpGlobals - > time > = pPlayer - > m_flLastCommandTime [ CMD_LISTMAPS ] )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
pPlayer - > m_flLastCommandTime [ CMD_LISTMAPS ] = gpGlobals - > time + 0.3f ;
CSGameRules ( ) - > DisplayMaps ( pPlayer , 0 ) ;
2015-09-30 03:49:22 +03:00
}
}
else if ( FStrEq ( pcmd , " votemap " ) )
{
2017-10-17 15:38:40 +03:00
if ( gpGlobals - > time > = pPlayer - > m_flLastCommandTime [ CMD_VOTEMAP ] )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
pPlayer - > m_flLastCommandTime [ CMD_VOTEMAP ] = gpGlobals - > time + 0.3f ;
2015-09-30 03:49:22 +03:00
2017-10-17 15:38:40 +03:00
if ( gpGlobals - > time < pPlayer - > m_flNextVoteTime )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
ClientPrint ( pPlayer - > pev , HUD_PRINTCONSOLE , " #Wait_3_Seconds " ) ;
2015-09-30 03:49:22 +03:00
return ;
}
2017-10-17 15:38:40 +03:00
pPlayer - > m_flNextVoteTime = gpGlobals - > time + 3 ;
2015-09-30 03:49:22 +03:00
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iTeam ! = UNASSIGNED )
2015-09-30 03:49:22 +03:00
{
if ( gpGlobals - > time < 180 )
{
2017-10-17 15:38:40 +03:00
ClientPrint ( pPlayer - > pev , HUD_PRINTCONSOLE , " #Cannot_Vote_Map " ) ;
2015-09-30 03:49:22 +03:00
return ;
}
2019-01-07 12:55:29 +03:00
bool bFailed = false ;
2015-09-30 03:49:22 +03:00
int iNumArgs = CMD_ARGC_ ( ) ;
2017-01-20 17:52:37 +03:00
int iVoteLength = Q_strlen ( parg1 ) ;
2015-09-30 03:49:22 +03:00
if ( iNumArgs ! = 2 | | iVoteLength > 5 )
{
2019-01-07 12:55:29 +03:00
bFailed = true ;
2015-09-30 03:49:22 +03:00
}
2017-01-20 17:52:37 +03:00
int iVoteID = Q_atoi ( parg1 ) ;
2015-09-30 03:49:22 +03:00
if ( iVoteID < 1 | | iVoteID > MAX_VOTE_MAPS )
{
2019-01-07 12:55:29 +03:00
bFailed = true ;
2015-09-30 03:49:22 +03:00
}
if ( iVoteID > GetMapCount ( ) )
{
2019-01-07 12:55:29 +03:00
bFailed = true ;
2015-09-30 03:49:22 +03:00
}
2019-01-07 12:55:29 +03:00
if ( bFailed )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
CSGameRules ( ) - > DisplayMaps ( pPlayer , 0 ) ;
ClientPrint ( pPlayer - > pev , HUD_PRINTCONSOLE , " #Game_votemap_usage " ) ;
2015-09-30 03:49:22 +03:00
return ;
}
2017-10-17 15:38:40 +03:00
if ( CountTeamPlayers ( pPlayer - > m_iTeam ) < 2 )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
ClientPrint ( pPlayer - > pev , HUD_PRINTCONSOLE , " #Cannot_Vote_Need_More_People " ) ;
2015-09-30 03:49:22 +03:00
return ;
}
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iMapVote )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
if ( - - CSGameRules ( ) - > m_iMapVotes [ pPlayer - > m_iMapVote ] < 0 )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
CSGameRules ( ) - > m_iMapVotes [ pPlayer - > m_iMapVote ] = 0 ;
2015-09-30 03:49:22 +03:00
}
}
2017-10-17 15:38:40 +03:00
ClientPrint ( pPlayer - > pev , HUD_PRINTCONSOLE , " #Game_voted_for_map " , UTIL_dtos1 ( iVoteID ) ) ;
pPlayer - > m_iMapVote = iVoteID ;
CSGameRules ( ) - > ProcessMapVote ( pPlayer , iVoteID ) ;
2015-09-30 03:49:22 +03:00
}
}
}
else if ( FStrEq ( pcmd , " timeleft " ) )
{
2017-10-17 15:38:40 +03:00
if ( gpGlobals - > time > pPlayer - > m_iTimeCheckAllowed )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
pPlayer - > m_iTimeCheckAllowed = int ( gpGlobals - > time + 1.0f ) ;
2015-09-30 03:49:22 +03:00
if ( ! timelimit . value )
{
2017-10-17 15:38:40 +03:00
ClientPrint ( pPlayer - > pev , HUD_PRINTTALK , " #Game_no_timelimit " ) ;
2015-09-30 03:49:22 +03:00
return ;
}
2016-12-06 22:21:52 +03:00
int timeRemaining = ( int ) CSGameRules ( ) - > GetTimeLeft ( ) ;
if ( timeRemaining < 0 )
timeRemaining = 0 ;
2015-09-30 03:49:22 +03:00
2016-12-06 22:21:52 +03:00
int iMinutes = timeRemaining / 60 ;
int iSeconds = timeRemaining % 60 ;
2015-09-30 03:49:22 +03:00
char secs [ 5 ] ;
2016-12-06 22:21:52 +03:00
char * temp = UTIL_dtos2 ( iSeconds ) ;
2015-09-30 03:49:22 +03:00
2016-12-06 22:21:52 +03:00
if ( iSeconds > = 10 )
2015-09-30 03:49:22 +03:00
{
secs [ 0 ] = temp [ 0 ] ;
secs [ 1 ] = temp [ 1 ] ;
secs [ 2 ] = ' \0 ' ;
}
else
{
secs [ 0 ] = ' 0 ' ;
secs [ 1 ] = temp [ 0 ] ;
secs [ 2 ] = ' \0 ' ;
}
2017-10-17 15:38:40 +03:00
ClientPrint ( pPlayer - > pev , HUD_PRINTTALK , " #Game_timelimit " , UTIL_dtos1 ( iMinutes ) , secs ) ;
2015-09-30 03:49:22 +03:00
}
}
else if ( FStrEq ( pcmd , " listplayers " ) )
{
2017-10-17 15:38:40 +03:00
if ( gpGlobals - > time > = pPlayer - > m_flLastCommandTime [ CMD_LISTPLAYERS ] )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
pPlayer - > m_flLastCommandTime [ CMD_LISTPLAYERS ] = gpGlobals - > time + 0.3f ;
ListPlayers ( pPlayer ) ;
2015-09-30 03:49:22 +03:00
}
}
else if ( FStrEq ( pcmd , " client_buy_open " ) )
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iMenu = = Menu_OFF )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
pPlayer - > m_iMenu = Menu_ClientBuy ;
2015-09-30 03:49:22 +03:00
}
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_signals . GetState ( ) & SIGNAL_BUY )
2015-09-30 03:49:22 +03:00
{
2016-12-06 22:21:52 +03:00
if ( TheTutor )
2015-09-30 03:49:22 +03:00
{
TheTutor - > OnEvent ( EVENT_TUTOR_BUY_MENU_OPENNED ) ;
}
}
else
{
2017-10-17 15:38:40 +03:00
MESSAGE_BEGIN ( MSG_ONE , gmsgBuyClose , nullptr , pPlayer - > pev ) ;
2015-09-30 03:49:22 +03:00
MESSAGE_END ( ) ;
}
}
else if ( FStrEq ( pcmd , " client_buy_close " ) )
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iMenu = = Menu_ClientBuy )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
pPlayer - > m_iMenu = Menu_OFF ;
2015-09-30 03:49:22 +03:00
}
}
else if ( FStrEq ( pcmd , " menuselect " ) )
{
2017-01-20 17:52:37 +03:00
int slot = Q_atoi ( parg1 ) ;
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iJoiningState = = JOINED | | ( pPlayer - > m_iMenu ! = Menu_ChooseAppearance & & pPlayer - > m_iMenu ! = Menu_ChooseTeam ) )
2015-09-30 03:49:22 +03:00
{
if ( slot = = 10 )
{
2017-10-17 15:38:40 +03:00
pPlayer - > m_iMenu = Menu_OFF ;
2015-09-30 03:49:22 +03:00
}
}
2016-07-14 17:12:17 +03:00
# ifdef REGAMEDLL_ADD
2017-10-17 15:38:40 +03:00
auto canOpenOldMenu = [ pPlayer ] ( ) - > bool
2016-07-14 17:12:17 +03:00
{
2017-10-17 15:38:40 +03:00
if ( ! pPlayer - > m_bVGUIMenus | | pPlayer - > CSPlayer ( ) - > m_bForceShowMenu ) {
pPlayer - > CSPlayer ( ) - > m_bForceShowMenu = false ;
2016-07-14 17:12:17 +03:00
return true ;
}
return false ;
} ;
# else
2017-10-17 15:38:40 +03:00
auto canOpenOldMenu = [ pPlayer ] ( ) - > bool {
return pPlayer - > m_bVGUIMenus = = false ;
2016-07-14 17:12:17 +03:00
} ;
# endif
2017-10-17 15:38:40 +03:00
switch ( pPlayer - > m_iMenu )
2015-09-30 03:49:22 +03:00
{
case Menu_OFF :
break ;
case Menu_ChooseTeam :
{
2017-10-17 15:38:40 +03:00
if ( canOpenOldMenu ( ) & & ! HandleMenu_ChooseTeam ( pPlayer , slot ) )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
pPlayer - > m_iMenu = Menu_ChooseTeam ;
if ( pPlayer - > m_iJoiningState = = JOINED )
ShowVGUIMenu ( pPlayer , VGUI_Menu_Team , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_5 | MENU_KEY_0 ) , " #IG_Team_Select " ) ;
2015-09-30 03:49:22 +03:00
else
2017-10-17 15:38:40 +03:00
ShowVGUIMenu ( pPlayer , VGUI_Menu_Team , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_5 ) , " #Team_Select " ) ;
2015-09-30 03:49:22 +03:00
}
break ;
}
case Menu_IGChooseTeam :
{
2016-07-14 17:12:17 +03:00
if ( canOpenOldMenu ( ) ) {
2017-10-17 15:38:40 +03:00
HandleMenu_ChooseTeam ( pPlayer , slot ) ;
2015-09-30 03:49:22 +03:00
}
break ;
}
case Menu_ChooseAppearance :
{
2016-07-14 17:12:17 +03:00
if ( canOpenOldMenu ( ) ) {
2017-10-17 15:38:40 +03:00
HandleMenu_ChooseAppearance ( pPlayer , slot ) ;
2015-09-30 03:49:22 +03:00
}
break ;
}
case Menu_Buy :
{
2016-07-14 17:12:17 +03:00
if ( canOpenOldMenu ( ) )
2015-09-30 03:49:22 +03:00
{
switch ( slot )
{
case VGUI_MenuSlot_Buy_Pistol :
{
2017-10-17 15:38:40 +03:00
pPlayer - > m_iMenu = Menu_BuyPistol ;
if ( pPlayer - > m_iTeam = = CT )
ShowVGUIMenu ( pPlayer , VGUI_Menu_Buy_Pistol , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_0 ) , " #CT_BuyPistol " ) ;
2015-09-30 03:49:22 +03:00
else
2017-10-17 15:38:40 +03:00
ShowVGUIMenu ( pPlayer , VGUI_Menu_Buy_Pistol , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_0 ) , " #T_BuyPistol " ) ;
2015-09-30 03:49:22 +03:00
break ;
}
case VGUI_MenuSlot_Buy_ShotGun :
{
2017-10-17 15:38:40 +03:00
pPlayer - > m_iMenu = Menu_BuyShotgun ;
if ( CSGameRules ( ) - > m_bMapHasVIPSafetyZone & & pPlayer - > m_iTeam = = TERRORIST )
ShowVGUIMenu ( pPlayer , VGUI_Menu_Buy_ShotGun , MENU_KEY_0 , " #AS_BuyShotgun " ) ;
2015-09-30 03:49:22 +03:00
else
2017-10-17 15:38:40 +03:00
ShowVGUIMenu ( pPlayer , VGUI_Menu_Buy_ShotGun , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_0 ) , " #BuyShotgun " ) ;
2015-09-30 03:49:22 +03:00
break ;
}
case VGUI_MenuSlot_Buy_SubMachineGun :
{
2017-10-17 15:38:40 +03:00
pPlayer - > m_iMenu = Menu_BuySubMachineGun ;
2016-12-06 22:21:52 +03:00
if ( CSGameRules ( ) - > m_bMapHasVIPSafetyZone )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iTeam = = CT )
ShowVGUIMenu ( pPlayer , VGUI_Menu_Buy_SubMachineGun , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_0 ) , " #AS_CT_BuySubMachineGun " ) ;
2015-09-30 03:49:22 +03:00
else
2017-10-17 15:38:40 +03:00
ShowVGUIMenu ( pPlayer , VGUI_Menu_Buy_SubMachineGun , ( MENU_KEY_1 | MENU_KEY_3 | MENU_KEY_0 ) , " #AS_T_BuySubMachineGun " ) ;
2015-09-30 03:49:22 +03:00
}
else
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iTeam = = CT )
ShowVGUIMenu ( pPlayer , VGUI_Menu_Buy_SubMachineGun , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_0 ) , " #CT_BuySubMachineGun " ) ;
2015-09-30 03:49:22 +03:00
else
2017-10-17 15:38:40 +03:00
ShowVGUIMenu ( pPlayer , VGUI_Menu_Buy_SubMachineGun , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_0 ) , " #T_BuySubMachineGun " ) ;
2015-09-30 03:49:22 +03:00
}
break ;
}
case VGUI_MenuSlot_Buy_Rifle :
{
2017-10-17 15:38:40 +03:00
pPlayer - > m_iMenu = Menu_BuyRifle ;
2016-12-06 22:21:52 +03:00
if ( CSGameRules ( ) - > m_bMapHasVIPSafetyZone )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iTeam = = CT )
ShowVGUIMenu ( pPlayer , VGUI_Menu_Buy_Rifle , ( MENU_KEY_1 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_0 ) , " #AS_CT_BuyRifle " ) ;
2015-09-30 03:49:22 +03:00
else
2017-10-17 15:38:40 +03:00
ShowVGUIMenu ( pPlayer , VGUI_Menu_Buy_Rifle , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_5 | MENU_KEY_0 ) , " #AS_T_BuyRifle " ) ;
2015-09-30 03:49:22 +03:00
}
else
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iTeam = = CT )
ShowVGUIMenu ( pPlayer , VGUI_Menu_Buy_Rifle , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0 ) , " #CT_BuyRifle " ) ;
2015-09-30 03:49:22 +03:00
else
2017-10-17 15:38:40 +03:00
ShowVGUIMenu ( pPlayer , VGUI_Menu_Buy_Rifle , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0 ) , " #T_BuyRifle " ) ;
2015-09-30 03:49:22 +03:00
}
break ;
}
case VGUI_MenuSlot_Buy_MachineGun :
{
2017-10-17 15:38:40 +03:00
pPlayer - > m_iMenu = Menu_BuyMachineGun ;
if ( CSGameRules ( ) - > m_bMapHasVIPSafetyZone & & pPlayer - > m_iTeam = = TERRORIST )
ShowVGUIMenu ( pPlayer , VGUI_Menu_Buy_MachineGun , MENU_KEY_0 , " #AS_T_BuyMachineGun " ) ;
2015-09-30 03:49:22 +03:00
else
2017-10-17 15:38:40 +03:00
ShowVGUIMenu ( pPlayer , VGUI_Menu_Buy_MachineGun , ( MENU_KEY_1 | MENU_KEY_0 ) , " #BuyMachineGun " ) ;
2015-09-30 03:49:22 +03:00
break ;
}
case VGUI_MenuSlot_Buy_PrimAmmo :
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_signals . GetState ( ) & SIGNAL_BUY )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
if ( BuyAmmo ( pPlayer , PRIMARY_WEAPON_SLOT , true ) )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
while ( BuyAmmo ( pPlayer , PRIMARY_WEAPON_SLOT , false ) )
2015-09-30 03:49:22 +03:00
;
2016-12-06 22:21:52 +03:00
if ( TheTutor )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
TheTutor - > OnEvent ( EVENT_PLAYER_BOUGHT_SOMETHING , pPlayer ) ;
2015-09-30 03:49:22 +03:00
}
}
2017-10-17 15:38:40 +03:00
pPlayer - > BuildRebuyStruct ( ) ;
2015-09-30 03:49:22 +03:00
}
break ;
}
case VGUI_MenuSlot_Buy_SecAmmo :
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_signals . GetState ( ) & SIGNAL_BUY )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
if ( BuyAmmo ( pPlayer , PISTOL_SLOT , true ) )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
while ( BuyAmmo ( pPlayer , PISTOL_SLOT , false ) )
2015-09-30 03:49:22 +03:00
;
2016-12-06 22:21:52 +03:00
if ( TheTutor )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
TheTutor - > OnEvent ( EVENT_PLAYER_BOUGHT_SOMETHING , pPlayer ) ;
2015-09-30 03:49:22 +03:00
}
}
2017-10-17 15:38:40 +03:00
pPlayer - > BuildRebuyStruct ( ) ;
2015-09-30 03:49:22 +03:00
}
2015-12-29 01:54:08 +03:00
break ;
2015-09-30 03:49:22 +03:00
}
case VGUI_MenuSlot_Buy_Item :
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_signals . GetState ( ) & SIGNAL_BUY )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
pPlayer - > m_iMenu = Menu_BuyItem ;
2016-02-23 02:13:52 +03:00
if ( CSGameRules ( ) - > m_bMapHasBombTarget )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iTeam = = CT )
ShowVGUIMenu ( pPlayer , VGUI_Menu_Buy_Item , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_7 | MENU_KEY_8 | MENU_KEY_0 ) , " #DCT_BuyItem " ) ;
2015-09-30 03:49:22 +03:00
else
2017-10-17 15:38:40 +03:00
ShowVGUIMenu ( pPlayer , VGUI_Menu_Buy_Item , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0 ) , " #DT_BuyItem " ) ;
2015-09-30 03:49:22 +03:00
}
else
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iTeam = = CT )
ShowVGUIMenu ( pPlayer , VGUI_Menu_Buy_Item , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_8 | MENU_KEY_0 ) , " #CT_BuyItem " ) ;
2015-09-30 03:49:22 +03:00
else
2017-10-17 15:38:40 +03:00
ShowVGUIMenu ( pPlayer , VGUI_Menu_Buy_Item , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0 ) , " #T_BuyItem " ) ;
2015-09-30 03:49:22 +03:00
}
}
break ;
}
}
}
break ;
}
case Menu_BuyPistol :
{
2019-09-22 17:16:07 +03:00
if ( canOpenOldMenu ( ) )
{
2017-10-17 15:38:40 +03:00
BuyPistol ( pPlayer , slot ) ;
2019-09-22 17:16:07 +03:00
# ifdef REGAMEDLL_FIXES
pPlayer - > BuildRebuyStruct ( ) ;
# endif
2015-09-30 03:49:22 +03:00
}
break ;
}
case Menu_BuyShotgun :
{
2019-09-22 17:16:07 +03:00
if ( canOpenOldMenu ( ) )
{
2017-10-17 15:38:40 +03:00
BuyShotgun ( pPlayer , slot ) ;
2019-09-22 17:16:07 +03:00
# ifdef REGAMEDLL_FIXES
pPlayer - > BuildRebuyStruct ( ) ;
# endif
2015-09-30 03:49:22 +03:00
}
break ;
}
case Menu_BuySubMachineGun :
{
2019-09-22 17:16:07 +03:00
if ( canOpenOldMenu ( ) )
{
2017-10-17 15:38:40 +03:00
BuySubMachineGun ( pPlayer , slot ) ;
2019-09-22 17:16:07 +03:00
# ifdef REGAMEDLL_FIXES
pPlayer - > BuildRebuyStruct ( ) ;
# endif
2015-09-30 03:49:22 +03:00
}
break ;
}
case Menu_BuyRifle :
{
2019-09-22 17:16:07 +03:00
if ( canOpenOldMenu ( ) )
{
2017-10-17 15:38:40 +03:00
BuyRifle ( pPlayer , slot ) ;
2019-09-22 17:16:07 +03:00
# ifdef REGAMEDLL_FIXES
pPlayer - > BuildRebuyStruct ( ) ;
# endif
2015-09-30 03:49:22 +03:00
}
break ;
}
case Menu_BuyMachineGun :
{
2019-09-22 17:16:07 +03:00
if ( canOpenOldMenu ( ) )
{
2017-10-17 15:38:40 +03:00
BuyMachineGun ( pPlayer , slot ) ;
2019-09-22 17:16:07 +03:00
# ifdef REGAMEDLL_FIXES
pPlayer - > BuildRebuyStruct ( ) ;
# endif
2015-09-30 03:49:22 +03:00
}
break ;
}
case Menu_BuyItem :
{
2019-09-22 17:16:07 +03:00
if ( canOpenOldMenu ( ) )
{
2017-10-17 15:38:40 +03:00
BuyItem ( pPlayer , slot ) ;
2019-09-22 17:16:07 +03:00
# ifdef REGAMEDLL_FIXES
pPlayer - > BuildRebuyStruct ( ) ;
# endif
2015-09-30 03:49:22 +03:00
}
break ;
}
case Menu_Radio1 :
{
2017-10-17 15:38:40 +03:00
Radio1 ( pPlayer , slot ) ;
2015-09-30 03:49:22 +03:00
break ;
}
case Menu_Radio2 :
{
2017-10-17 15:38:40 +03:00
Radio2 ( pPlayer , slot ) ;
2015-09-30 03:49:22 +03:00
break ;
}
case Menu_Radio3 :
{
2017-10-17 15:38:40 +03:00
Radio3 ( pPlayer , slot ) ;
2015-09-30 03:49:22 +03:00
break ;
}
default :
ALERT ( at_console , " ClientCommand(): Invalid menu selected \n " ) ;
break ;
}
}
else if ( FStrEq ( pcmd , " chooseteam " ) )
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iMenu = = Menu_ChooseAppearance )
2015-09-30 03:49:22 +03:00
return ;
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_bTeamChanged )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > pev - > deadflag ! = DEAD_NO )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Only_1_Team_Change " ) ;
2015-09-30 03:49:22 +03:00
return ;
}
}
2016-02-23 02:13:52 +03:00
if ( ! CSGameRules ( ) - > IsCareer ( ) )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
pPlayer - > m_iMenu = Menu_ChooseTeam ;
if ( CSGameRules ( ) - > m_bMapHasVIPSafetyZone & & pPlayer - > m_iJoiningState = = JOINED & & pPlayer - > m_iTeam = = CT )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
if ( CSGameRules ( ) - > IsFreezePeriod ( ) | | pPlayer - > pev - > deadflag ! = DEAD_NO )
ShowVGUIMenu ( pPlayer , VGUI_Menu_Team , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0 ) , " #IG_VIP_Team_Select_Spect " ) ;
2015-09-30 03:49:22 +03:00
else
2017-10-17 15:38:40 +03:00
ShowVGUIMenu ( pPlayer , VGUI_Menu_Team , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_5 | MENU_KEY_0 ) , " #IG_VIP_Team_Select " ) ;
2015-09-30 03:49:22 +03:00
}
else
{
2017-10-17 15:38:40 +03:00
if ( CSGameRules ( ) - > IsFreezePeriod ( ) | | pPlayer - > pev - > deadflag ! = DEAD_NO )
ShowVGUIMenu ( pPlayer , VGUI_Menu_Team , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0 ) , " #IG_Team_Select_Spect " ) ;
2015-09-30 03:49:22 +03:00
else
2017-10-17 15:38:40 +03:00
ShowVGUIMenu ( pPlayer , VGUI_Menu_Team , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_5 | MENU_KEY_0 ) , " #IG_Team_Select " ) ;
2015-09-30 03:49:22 +03:00
}
}
}
else if ( FStrEq ( pcmd , " showbriefing " ) )
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iMenu = = Menu_OFF )
2015-09-30 03:49:22 +03:00
{
if ( g_szMapBriefingText [ 0 ] ! = ' \0 ' )
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iTeam ! = UNASSIGNED & & ! ( pPlayer - > m_afPhysicsFlags & PFLAG_OBSERVER ) )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
pPlayer - > MenuPrint ( g_szMapBriefingText ) ;
pPlayer - > m_bMissionBriefing = true ;
2015-09-30 03:49:22 +03:00
}
}
}
}
else if ( FStrEq ( pcmd , " ignoremsg " ) )
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iIgnoreGlobalChat = = IGNOREMSG_NONE )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
pPlayer - > m_iIgnoreGlobalChat = IGNOREMSG_ENEMY ;
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Ignore_Broadcast_Messages " ) ;
2015-09-30 03:49:22 +03:00
}
2017-10-17 15:38:40 +03:00
else if ( pPlayer - > m_iIgnoreGlobalChat = = IGNOREMSG_ENEMY )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
pPlayer - > m_iIgnoreGlobalChat = IGNOREMSG_TEAM ;
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Ignore_Broadcast_Team_Messages " ) ;
2015-09-30 03:49:22 +03:00
}
2017-10-17 15:38:40 +03:00
else if ( pPlayer - > m_iIgnoreGlobalChat = = IGNOREMSG_TEAM )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
pPlayer - > m_iIgnoreGlobalChat = IGNOREMSG_NONE ;
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Accept_All_Messages " ) ;
2015-09-30 03:49:22 +03:00
}
}
else if ( FStrEq ( pcmd , " ignorerad " ) )
{
2017-10-17 15:38:40 +03:00
pPlayer - > m_bIgnoreRadio = ! pPlayer - > m_bIgnoreRadio ;
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , pPlayer - > m_bIgnoreRadio ? " #Ignore_Radio " : " #Accept_Radio " ) ;
2015-09-30 03:49:22 +03:00
}
else if ( FStrEq ( pcmd , " become_vip " ) )
{
2019-10-09 13:18:42 +03:00
if ( pPlayer - > m_iJoiningState ! = JOINED | | pPlayer - > m_iTeam ! = CT
# ifdef REGAMEDLL_FIXES
| | ! CSGameRules ( ) - > m_bMapHasVIPSafetyZone
# endif
)
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Command_Not_Available " ) ;
2015-09-30 03:49:22 +03:00
return ;
}
2017-10-17 15:38:40 +03:00
CSGameRules ( ) - > AddToVIPQueue ( pPlayer ) ;
2015-09-30 03:49:22 +03:00
}
2017-10-17 15:38:40 +03:00
else if ( FStrEq ( pcmd , " spectate " ) & & ( pPlayer - > pev - > flags & FL_PROXY ) ) // always allow proxies to become a spectator
2015-09-30 03:49:22 +03:00
{
// clients wants to become a spectator
2017-10-17 15:38:40 +03:00
HandleMenu_ChooseTeam ( pPlayer , MENU_SLOT_TEAM_SPECT ) ;
2015-09-30 03:49:22 +03:00
}
else if ( FStrEq ( pcmd , " specmode " ) )
{
// new spectator mode
2017-01-20 17:52:37 +03:00
int mode = Q_atoi ( parg1 ) ;
2018-02-08 12:37:02 +03:00
if ( pPlayer - > GetObserverMode ( ) ! = OBS_NONE & & pPlayer - > CanSwitchObserverModes ( ) )
2017-10-17 15:38:40 +03:00
pPlayer - > Observer_SetMode ( mode ) ;
2015-09-30 03:49:22 +03:00
else
2017-10-17 15:38:40 +03:00
pPlayer - > m_iObserverLastMode = mode ;
2015-09-30 03:49:22 +03:00
if ( mode = = OBS_CHASE_FREE )
{
2017-10-17 15:38:40 +03:00
MESSAGE_BEGIN ( MSG_ONE , gmsgADStop , nullptr , pPlayer - > pev ) ;
2015-09-30 03:49:22 +03:00
MESSAGE_END ( ) ;
}
}
else if ( FStrEq ( pcmd , " spec_set_ad " ) )
{
2017-01-20 17:52:37 +03:00
float val = Q_atof ( parg1 ) ;
2017-10-17 15:38:40 +03:00
pPlayer - > SetObserverAutoDirector ( val > 0.0f ) ;
2015-09-30 03:49:22 +03:00
}
else if ( FStrEq ( pcmd , " follownext " ) )
{
// follow next player
2017-01-20 17:52:37 +03:00
int arg = Q_atoi ( parg1 ) ;
2018-02-08 12:37:02 +03:00
if ( pPlayer - > GetObserverMode ( ) ! = OBS_NONE & & pPlayer - > CanSwitchObserverModes ( ) )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
pPlayer - > Observer_FindNextPlayer ( arg ! = 0 ) ;
2015-09-30 03:49:22 +03:00
}
}
else if ( FStrEq ( pcmd , " follow " ) )
{
2018-02-08 12:37:02 +03:00
if ( pPlayer - > GetObserverMode ( ) ! = OBS_NONE & & pPlayer - > CanSwitchObserverModes ( ) )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
pPlayer - > Observer_FindNextPlayer ( false , parg1 ) ;
2015-09-30 03:49:22 +03:00
}
}
2019-09-22 17:16:07 +03:00
# ifdef REGAMEDLL_FIXES
else if ( FStrEq ( pcmd , " cl_setautobuy " ) )
{
if ( pPlayer - > pev - > deadflag ! = DEAD_NO & & pPlayer - > m_autoBuyString [ 0 ] ! = ' \0 ' )
return ;
2020-02-06 15:11:07 +03:00
2019-09-22 17:16:07 +03:00
pPlayer - > ClearAutoBuyData ( ) ;
for ( int i = 1 ; i < CMD_ARGC_ ( ) ; i + + )
{
pPlayer - > AddAutoBuyData ( CMD_ARGV_ ( i ) ) ;
}
if ( pPlayer - > m_signals . GetState ( ) & SIGNAL_BUY )
{
bool oldval = g_bClientPrintEnable ;
g_bClientPrintEnable = false ;
pPlayer - > AutoBuy ( ) ;
g_bClientPrintEnable = oldval ;
}
}
else if ( FStrEq ( pcmd , " cl_setrebuy " ) )
{
2019-09-22 17:24:43 +03:00
if ( pPlayer - > pev - > deadflag ! = DEAD_NO & & pPlayer - > m_rebuyString )
2019-09-22 17:16:07 +03:00
return ;
2020-02-06 15:11:07 +03:00
2019-09-22 17:16:07 +03:00
if ( CMD_ARGC_ ( ) = = 2 )
{
pPlayer - > InitRebuyData ( parg1 ) ;
if ( pPlayer - > m_signals . GetState ( ) & SIGNAL_BUY )
{
bool oldval = g_bClientPrintEnable ;
g_bClientPrintEnable = false ;
pPlayer - > Rebuy ( ) ;
g_bClientPrintEnable = oldval ;
}
}
}
# endif
2015-09-30 03:49:22 +03:00
else
{
2016-03-17 20:44:52 +03:00
if ( g_pGameRules - > ClientCommand_DeadOrAlive ( GetClassPtr < CCSPlayer > ( ( CBasePlayer * ) pev ) , pcmd ) )
2015-09-30 03:49:22 +03:00
return ;
2016-12-06 22:21:52 +03:00
if ( TheBots )
2015-12-05 22:40:30 +03:00
{
2016-03-17 20:44:52 +03:00
if ( TheBots - > ClientCommand ( GetClassPtr < CCSPlayer > ( ( CBasePlayer * ) pev ) , pcmd ) )
2015-12-05 22:40:30 +03:00
return ;
}
2015-09-30 03:49:22 +03:00
if ( FStrEq ( pcmd , " mp_debug " ) )
{
2017-01-20 17:52:37 +03:00
UTIL_SetDprintfFlags ( parg1 ) ;
2015-09-30 03:49:22 +03:00
}
else if ( FStrEq ( pcmd , " jointeam " ) )
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iMenu = = Menu_ChooseAppearance )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Command_Not_Available " ) ;
2015-09-30 03:49:22 +03:00
return ;
}
2017-01-20 17:52:37 +03:00
int slot = Q_atoi ( parg1 ) ;
2017-10-17 15:38:40 +03:00
if ( HandleMenu_ChooseTeam ( pPlayer , slot ) )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
if ( slot = = MENU_SLOT_TEAM_VIP | | slot = = MENU_SLOT_TEAM_SPECT | | pPlayer - > m_bIsVIP )
2015-09-30 03:49:22 +03:00
{
2017-01-20 17:52:37 +03:00
# ifdef REGAMEDLL_FIXES
2017-10-17 15:38:40 +03:00
pPlayer - > ResetMenu ( ) ;
2017-01-20 17:52:37 +03:00
# else
2017-10-17 15:38:40 +03:00
pPlayer - > m_iMenu = Menu_OFF ;
2017-01-20 17:52:37 +03:00
# endif
2015-09-30 03:49:22 +03:00
}
else
2017-10-17 15:38:40 +03:00
pPlayer - > m_iMenu = Menu_ChooseAppearance ;
2015-09-30 03:49:22 +03:00
}
else
{
2017-10-17 15:38:40 +03:00
pPlayer - > m_iMenu = Menu_ChooseTeam ;
if ( pPlayer - > m_iJoiningState = = JOINED )
ShowVGUIMenu ( pPlayer , VGUI_Menu_Team , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_5 | MENU_KEY_0 ) , " #IG_Team_Select " ) ;
2015-09-30 03:49:22 +03:00
else
2017-10-17 15:38:40 +03:00
ShowVGUIMenu ( pPlayer , VGUI_Menu_Team , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_5 ) , " #Team_Select " ) ;
2015-09-30 03:49:22 +03:00
}
}
else if ( FStrEq ( pcmd , " joinclass " ) )
{
2017-01-20 17:52:37 +03:00
int slot = Q_atoi ( parg1 ) ;
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iMenu ! = Menu_ChooseAppearance )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
ClientPrint ( pPlayer - > pev , HUD_PRINTCENTER , " #Command_Not_Available " ) ;
2015-09-30 03:49:22 +03:00
return ;
}
2017-10-17 15:38:40 +03:00
HandleMenu_ChooseAppearance ( pPlayer , slot ) ;
2015-09-30 03:49:22 +03:00
}
2017-10-17 15:38:40 +03:00
else if ( pPlayer - > pev - > deadflag = = DEAD_NO )
2015-09-30 03:49:22 +03:00
{
if ( FStrEq ( pcmd , " nightvision " ) )
{
2017-10-17 15:38:40 +03:00
if ( gpGlobals - > time > = pPlayer - > m_flLastCommandTime [ CMD_NIGHTVISION ] )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
pPlayer - > m_flLastCommandTime [ CMD_NIGHTVISION ] = gpGlobals - > time + 0.3f ;
2015-09-30 03:49:22 +03:00
2017-10-17 15:38:40 +03:00
if ( ! pPlayer - > m_bHasNightVision )
2015-09-30 03:49:22 +03:00
return ;
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_bNightVisionOn )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
EMIT_SOUND ( ENT ( pPlayer - > pev ) , CHAN_ITEM , " items/nvg_off.wav " , RANDOM_FLOAT ( 0.92 , 1 ) , ATTN_NORM ) ;
2015-09-30 03:49:22 +03:00
2017-10-17 15:38:40 +03:00
MESSAGE_BEGIN ( MSG_ONE , gmsgNVGToggle , nullptr , pPlayer - > pev ) ;
2015-09-30 03:49:22 +03:00
WRITE_BYTE ( 0 ) ; // disable nightvision
MESSAGE_END ( ) ;
2017-10-17 15:38:40 +03:00
pPlayer - > m_bNightVisionOn = false ;
2015-09-30 03:49:22 +03:00
2017-10-17 15:38:40 +03:00
for ( int i = 1 ; i < = gpGlobals - > maxClients ; i + + )
2015-09-30 03:49:22 +03:00
{
2016-05-31 17:04:51 +03:00
CBasePlayer * pObserver = UTIL_PlayerByIndex ( i ) ;
2017-10-17 15:38:40 +03:00
if ( pObserver & & pObserver - > IsObservingPlayer ( pPlayer ) )
2015-09-30 03:49:22 +03:00
{
EMIT_SOUND ( ENT ( pObserver - > pev ) , CHAN_ITEM , " items/nvg_off.wav " , RANDOM_FLOAT ( 0.92 , 1 ) , ATTN_NORM ) ;
2017-10-12 17:50:56 +03:00
MESSAGE_BEGIN ( MSG_ONE , gmsgNVGToggle , nullptr , pObserver - > pev ) ;
2015-09-30 03:49:22 +03:00
WRITE_BYTE ( 0 ) ; // disable nightvision
MESSAGE_END ( ) ;
pObserver - > m_bNightVisionOn = false ;
}
}
}
else
{
2017-10-17 15:38:40 +03:00
EMIT_SOUND ( ENT ( pPlayer - > pev ) , CHAN_ITEM , " items/nvg_on.wav " , RANDOM_FLOAT ( 0.92 , 1 ) , ATTN_NORM ) ;
2015-09-30 03:49:22 +03:00
2017-10-17 15:38:40 +03:00
MESSAGE_BEGIN ( MSG_ONE , gmsgNVGToggle , nullptr , pPlayer - > pev ) ;
2015-09-30 03:49:22 +03:00
WRITE_BYTE ( 1 ) ; // enable nightvision
MESSAGE_END ( ) ;
2017-10-17 15:38:40 +03:00
pPlayer - > m_bNightVisionOn = true ;
2015-09-30 03:49:22 +03:00
2017-10-17 15:38:40 +03:00
for ( int i = 1 ; i < = gpGlobals - > maxClients ; i + + )
2015-09-30 03:49:22 +03:00
{
2016-05-31 17:04:51 +03:00
CBasePlayer * pObserver = UTIL_PlayerByIndex ( i ) ;
2017-10-17 15:38:40 +03:00
if ( pObserver & & pObserver - > IsObservingPlayer ( pPlayer ) )
2015-09-30 03:49:22 +03:00
{
EMIT_SOUND ( ENT ( pObserver - > pev ) , CHAN_ITEM , " items/nvg_on.wav " , RANDOM_FLOAT ( 0.92 , 1 ) , ATTN_NORM ) ;
2017-10-12 17:50:56 +03:00
MESSAGE_BEGIN ( MSG_ONE , gmsgNVGToggle , nullptr , pObserver - > pev ) ;
2015-09-30 03:49:22 +03:00
WRITE_BYTE ( 1 ) ; // enable nightvision
MESSAGE_END ( ) ;
pObserver - > m_bNightVisionOn = true ;
}
}
}
}
}
else if ( FStrEq ( pcmd , " radio1 " ) )
{
2017-10-17 15:38:40 +03:00
ShowMenu ( pPlayer , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0 ) , - 1 , FALSE , " #RadioA " ) ;
pPlayer - > m_iMenu = Menu_Radio1 ;
2015-09-30 03:49:22 +03:00
}
else if ( FStrEq ( pcmd , " radio2 " ) )
{
2017-10-17 15:38:40 +03:00
ShowMenu ( pPlayer , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0 ) , - 1 , FALSE , " #RadioB " ) ;
pPlayer - > m_iMenu = Menu_Radio2 ;
2015-09-30 03:49:22 +03:00
return ;
}
else if ( FStrEq ( pcmd , " radio3 " ) )
{
2017-10-17 15:38:40 +03:00
ShowMenu ( pPlayer , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_7 | MENU_KEY_8 | MENU_KEY_9 | MENU_KEY_0 ) , - 1 , FALSE , " #RadioC " ) ;
pPlayer - > m_iMenu = Menu_Radio3 ;
2015-09-30 03:49:22 +03:00
}
else if ( FStrEq ( pcmd , " drop " ) )
{
// player is dropping an item.
2017-10-17 15:38:40 +03:00
if ( pPlayer - > HasShield ( ) )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_pActiveItem & & pPlayer - > m_pActiveItem - > m_iId = = WEAPON_C4 )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
pPlayer - > DropPlayerItem ( " weapon_c4 " ) ;
2015-09-30 03:49:22 +03:00
}
else
2017-10-17 15:38:40 +03:00
pPlayer - > DropShield ( ) ;
2015-09-30 03:49:22 +03:00
}
else
2017-10-17 15:38:40 +03:00
pPlayer - > DropPlayerItem ( parg1 ) ;
2015-09-30 03:49:22 +03:00
}
else if ( FStrEq ( pcmd , " fov " ) )
{
#if 0
2019-06-07 21:16:15 +03:00
if ( CVAR_GET_FLOAT ( " sv_cheats " ) ! = 0.0f & & CMD_ARGC ( ) > 1 )
2016-03-17 20:44:52 +03:00
GetClassPtr < CCSPlayer > ( ( CBasePlayer * ) pev ) - > m_iFOV = Q_atoi ( CMD_ARGV ( 1 ) ) ;
2015-09-30 03:49:22 +03:00
else
2016-03-17 20:44:52 +03:00
CLIENT_PRINTF ( pEntity , print_console , UTIL_VarArgs ( " \" fov \" is \" %d \" \n " , int ( GetClassPtr < CCSPlayer > ( ( CBasePlayer * ) pev ) - > m_iFOV ) ) ) ;
2015-09-30 03:49:22 +03:00
# endif
}
else if ( FStrEq ( pcmd , " use " ) )
{
2017-01-20 17:52:37 +03:00
GetClassPtr < CCSPlayer > ( ( CBasePlayer * ) pev ) - > SelectItem ( parg1 ) ;
2015-09-30 03:49:22 +03:00
}
2016-12-06 22:21:52 +03:00
else if ( ( ( pstr = Q_strstr ( pcmd , " weapon_ " ) ) ) & & ( pstr = = pcmd ) )
2015-09-30 03:49:22 +03:00
{
2016-03-17 20:44:52 +03:00
GetClassPtr < CCSPlayer > ( ( CBasePlayer * ) pev ) - > SelectItem ( pcmd ) ;
2015-09-30 03:49:22 +03:00
}
else if ( FStrEq ( pcmd , " lastinv " ) )
{
2016-03-17 20:44:52 +03:00
GetClassPtr < CCSPlayer > ( ( CBasePlayer * ) pev ) - > SelectLastItem ( ) ;
2015-09-30 03:49:22 +03:00
}
else if ( FStrEq ( pcmd , " buyammo1 " ) )
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_signals . GetState ( ) & SIGNAL_BUY )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
BuyAmmo ( pPlayer , PRIMARY_WEAPON_SLOT , true ) ;
pPlayer - > BuildRebuyStruct ( ) ;
2015-12-05 22:40:30 +03:00
2016-12-06 22:21:52 +03:00
if ( TheTutor )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
TheTutor - > OnEvent ( EVENT_PLAYER_BOUGHT_SOMETHING , pPlayer ) ;
2015-09-30 03:49:22 +03:00
}
}
}
else if ( FStrEq ( pcmd , " buyammo2 " ) )
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_signals . GetState ( ) & SIGNAL_BUY )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
BuyAmmo ( pPlayer , PISTOL_SLOT , true ) ;
pPlayer - > BuildRebuyStruct ( ) ;
2015-12-05 22:40:30 +03:00
2016-12-06 22:21:52 +03:00
if ( TheTutor )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
TheTutor - > OnEvent ( EVENT_PLAYER_BOUGHT_SOMETHING , pPlayer ) ;
2015-09-30 03:49:22 +03:00
}
}
}
else if ( FStrEq ( pcmd , " buyequip " ) )
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_signals . GetState ( ) & SIGNAL_BUY )
2015-09-30 03:49:22 +03:00
{
2016-02-23 02:13:52 +03:00
if ( CSGameRules ( ) - > m_bMapHasBombTarget )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iTeam = = CT )
ShowVGUIMenu ( pPlayer , VGUI_Menu_Buy_Item , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_7 | MENU_KEY_8 | MENU_KEY_0 ) , " #DCT_BuyItem " ) ;
2015-09-30 03:49:22 +03:00
else
2017-10-17 15:38:40 +03:00
ShowVGUIMenu ( pPlayer , VGUI_Menu_Buy_Item , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0 ) , " #DT_BuyItem " ) ;
2015-09-30 03:49:22 +03:00
}
else
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_iTeam = = CT )
ShowVGUIMenu ( pPlayer , VGUI_Menu_Buy_Item , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_8 | MENU_KEY_0 ) , " #CT_BuyItem " ) ;
2015-09-30 03:49:22 +03:00
else
2017-10-17 15:38:40 +03:00
ShowVGUIMenu ( pPlayer , VGUI_Menu_Buy_Item , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_0 ) , " #T_BuyItem " ) ;
2015-09-30 03:49:22 +03:00
}
2017-10-17 15:38:40 +03:00
pPlayer - > m_iMenu = Menu_BuyItem ;
2015-09-30 03:49:22 +03:00
}
}
else if ( FStrEq ( pcmd , " buy " ) )
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_signals . GetState ( ) & SIGNAL_BUY )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
ShowVGUIMenu ( pPlayer , VGUI_Menu_Buy , ( MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_7 | MENU_KEY_8 | MENU_KEY_0 ) , " #Buy " ) ;
pPlayer - > m_iMenu = Menu_Buy ;
2015-09-30 03:49:22 +03:00
2016-12-06 22:21:52 +03:00
if ( TheBots )
2015-09-30 03:49:22 +03:00
{
TheBots - > OnEvent ( EVENT_TUTOR_BUY_MENU_OPENNED ) ;
}
}
}
2019-09-22 17:16:07 +03:00
# ifndef REGAMEDLL_FIXES
// Moved to above
2015-09-30 03:49:22 +03:00
else if ( FStrEq ( pcmd , " cl_setautobuy " ) )
{
2017-10-17 15:38:40 +03:00
pPlayer - > ClearAutoBuyData ( ) ;
2015-09-30 03:49:22 +03:00
2017-11-22 20:27:55 +03:00
for ( int i = 1 ; i < CMD_ARGC_ ( ) ; i + + )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
pPlayer - > AddAutoBuyData ( CMD_ARGV_ ( i ) ) ;
2015-09-30 03:49:22 +03:00
}
bool oldval = g_bClientPrintEnable ;
g_bClientPrintEnable = false ;
2017-10-17 15:38:40 +03:00
pPlayer - > AutoBuy ( ) ;
2015-09-30 03:49:22 +03:00
g_bClientPrintEnable = oldval ;
}
else if ( FStrEq ( pcmd , " cl_setrebuy " ) )
{
if ( CMD_ARGC_ ( ) = = 2 )
{
2017-10-17 15:38:40 +03:00
pPlayer - > InitRebuyData ( parg1 ) ;
2015-09-30 03:49:22 +03:00
bool oldval = g_bClientPrintEnable ;
g_bClientPrintEnable = false ;
2017-10-17 15:38:40 +03:00
pPlayer - > Rebuy ( ) ;
2015-09-30 03:49:22 +03:00
g_bClientPrintEnable = oldval ;
}
}
2019-09-22 17:16:07 +03:00
# endif
2015-09-30 03:49:22 +03:00
else if ( FStrEq ( pcmd , " cl_autobuy " ) )
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_signals . GetState ( ) & SIGNAL_BUY )
2015-09-30 03:49:22 +03:00
{
bool oldval = g_bClientPrintEnable ;
g_bClientPrintEnable = false ;
2017-10-17 15:38:40 +03:00
pPlayer - > AutoBuy ( ) ;
2015-09-30 03:49:22 +03:00
g_bClientPrintEnable = oldval ;
}
}
else if ( FStrEq ( pcmd , " cl_rebuy " ) )
{
2017-10-17 15:38:40 +03:00
if ( pPlayer - > m_signals . GetState ( ) & SIGNAL_BUY )
2015-09-30 03:49:22 +03:00
{
bool oldval = g_bClientPrintEnable ;
g_bClientPrintEnable = false ;
2017-10-17 15:38:40 +03:00
pPlayer - > Rebuy ( ) ;
2015-09-30 03:49:22 +03:00
g_bClientPrintEnable = oldval ;
}
}
else if ( FStrEq ( pcmd , " smartradio " ) )
{
2017-10-17 15:38:40 +03:00
pPlayer - > SmartRadio ( ) ;
2015-09-30 03:49:22 +03:00
}
2019-09-22 17:41:57 +03:00
# ifdef REGAMEDLL_ADD
else if ( FStrEq ( pcmd , " give " ) )
{
if ( CVAR_GET_FLOAT ( " sv_cheats " ) ! = 0.0f & & CMD_ARGC ( ) > 1 & & FStrnEq ( parg1 , " weapon_ " , sizeof ( " weapon_ " ) - 1 ) )
{
const auto pInfo = GetWeaponInfo ( parg1 ) ;
if ( pInfo )
{
if ( pInfo - > id ! = WEAPON_GLOCK & & pInfo - > id ! = WEAPON_C4 /* && pInfo->id != WEAPON_KNIFE */ )
{
pPlayer - > GiveNamedItemEx ( pInfo - > entityName ) ;
pPlayer - > GiveAmmo ( pInfo - > maxRounds , pInfo - > ammoName2 ) ;
}
}
}
}
# endif
2015-09-30 03:49:22 +03:00
else
{
2017-10-17 15:38:40 +03:00
if ( HandleBuyAliasCommands ( pPlayer , pcmd ) )
2015-09-30 03:49:22 +03:00
return ;
2017-10-17 15:38:40 +03:00
if ( HandleRadioAliasCommands ( pPlayer , pcmd ) )
2015-09-30 03:49:22 +03:00
return ;
2016-03-17 20:44:52 +03:00
if ( ! g_pGameRules - > ClientCommand ( GetClassPtr < CCSPlayer > ( ( CBasePlayer * ) pev ) , pcmd ) )
2015-09-30 03:49:22 +03:00
{
// tell the user they entered an unknown command
char command [ 128 ] ;
// check the length of the command (prevents crash)
// max total length is 192 ...and we're adding a string below ("Unknown command: %s\n")
Q_strncpy ( command , pcmd , sizeof ( command ) - 1 ) ;
command [ sizeof ( command ) - 1 ] = ' \0 ' ;
2017-07-17 15:15:35 +03:00
# ifdef REGAMEDLL_FIXES
// Add extra '\n' to make command string safe
// This extra '\n' is removed by the client, so it is ok
command [ sizeof ( command ) - 2 ] = ' \0 ' ;
command [ Q_strlen ( command ) ] = ' \n ' ;
# endif
2015-09-30 03:49:22 +03:00
// tell the user they entered an unknown command
ClientPrint ( & pEntity - > v , HUD_PRINTCONSOLE , " #Game_unknown_command " , command ) ;
}
}
}
}
}
2017-01-20 17:52:37 +03:00
// Use CMD_ARGV, CMD_ARGV, and CMD_ARGC to get pointers the character string command.
void EXT_FUNC ClientCommand_ ( edict_t * pEntity )
{
// Is the client spawned yet?
if ( ! pEntity - > pvPrivateData )
return ;
2017-01-29 02:56:29 +03:00
static char command [ 128 ] = " " ;
Q_strncpy ( command , CMD_ARGV_ ( 0 ) , sizeof command - 1 ) ;
command [ sizeof command - 1 ] = ' \0 ' ;
g_ReGameHookchains . m_InternalCommand . callChain ( InternalCommand , pEntity , command , CMD_ARGV_ ( 1 ) ) ;
2017-01-20 17:52:37 +03:00
}
2016-06-14 01:13:13 +03:00
// called after the player changes userinfo - gives dll a chance to modify it before it gets sent into the rest of the engine.
2015-12-09 01:39:54 +03:00
void EXT_FUNC ClientUserInfoChanged ( edict_t * pEntity , char * infobuffer )
2015-09-30 03:49:22 +03:00
{
// Is the client spawned yet?
if ( ! pEntity - > pvPrivateData )
return ;
2016-06-14 01:13:13 +03:00
CBasePlayer * pPlayer = CBasePlayer : : Instance ( pEntity ) ;
2015-09-30 03:49:22 +03:00
char * szBufferName = GET_KEY_VALUE ( infobuffer , " name " ) ;
2017-01-20 17:52:37 +03:00
// msg everyone if someone changes their name, and it isn't the first time (changing no name to current name)
2015-09-30 03:49:22 +03:00
if ( pEntity - > v . netname & & STRING ( pEntity - > v . netname ) [ 0 ] ! = ' \0 ' & & ! FStrEq ( STRING ( pEntity - > v . netname ) , szBufferName ) )
{
char szName [ 32 ] ;
Q_snprintf ( szName , sizeof ( szName ) , " %s " , szBufferName ) ;
// First parse the name and remove any %'s
2016-12-06 22:21:52 +03:00
for ( char * pPct = szName ; pPct & & * pPct ! = ' \0 ' ; pPct + + )
2015-09-30 03:49:22 +03:00
{
// Replace it with a space
if ( * pPct = = ' % ' | | * pPct = = ' & ' )
* pPct = ' ' ;
}
if ( szName [ 0 ] = = ' # ' )
szName [ 0 ] = ' * ' ;
2016-12-06 22:21:52 +03:00
// Can set it a new name?
if ( ! pPlayer - > SetClientUserInfoName ( infobuffer , szName ) )
{
// so to back old name into buffer
2020-12-25 15:40:01 +03:00
SET_CLIENT_KEY_VALUE ( pPlayer - > entindex ( ) , infobuffer , " name " , STRING ( pPlayer - > pev - > netname ) ) ;
2016-12-06 22:21:52 +03:00
}
2015-09-30 03:49:22 +03:00
}
2016-06-03 18:32:33 +03:00
// was already checking on pvPrivateData
# ifndef REGAMEDLL_FIXES
2016-03-17 20:44:52 +03:00
g_pGameRules - > ClientUserInfoChanged ( GetClassPtr < CCSPlayer > ( ( CBasePlayer * ) & pEntity - > v ) , infobuffer ) ;
2016-06-03 18:32:33 +03:00
# else
g_pGameRules - > ClientUserInfoChanged ( pPlayer , infobuffer ) ;
# endif
2015-09-30 03:49:22 +03:00
}
2016-02-04 03:18:26 +03:00
void EXT_FUNC ServerDeactivate ( )
2015-09-30 03:49:22 +03:00
{
// It's possible that the engine will call this function more times than is necessary
2016-07-14 17:12:17 +03:00
// Therefore, only run it one time for each call to ServerActivate
if ( ! g_bServerActive )
2015-09-30 03:49:22 +03:00
return ;
2016-07-14 17:12:17 +03:00
g_bServerActive = false ;
2015-09-30 03:49:22 +03:00
// Peform any shutdown operations here...
g_pGameRules - > ServerDeactivate ( ) ;
CLocalNav : : Reset ( ) ;
2016-07-14 17:12:17 +03:00
if ( TheBots )
2015-12-05 22:40:30 +03:00
{
TheBots - > ServerDeactivate ( ) ;
}
2016-07-14 17:12:17 +03:00
if ( g_pHostages )
2015-09-30 03:49:22 +03:00
{
g_pHostages - > ServerDeactivate ( ) ;
}
2016-12-18 14:27:39 +03:00
WeaponInfoReset ( ) ;
2015-09-30 03:49:22 +03:00
}
2015-12-09 01:39:54 +03:00
void EXT_FUNC ServerActivate ( edict_t * pEdictList , int edictCount , int clientMax )
2015-09-30 03:49:22 +03:00
{
int i ;
CBaseEntity * pClass ;
// Every call to ServerActivate should be matched by a call to ServerDeactivate
2016-07-14 17:12:17 +03:00
g_bServerActive = true ;
2015-09-30 03:49:22 +03:00
EmptyEntityHashTable ( ) ;
// Clients have not been initialized yet
2017-11-22 20:27:55 +03:00
for ( i = 0 ; i < edictCount ; i + + )
2015-09-30 03:49:22 +03:00
{
edict_t * pEdict = & pEdictList [ i ] ;
if ( pEdict - > free )
continue ;
// Clients aren't necessarily initialized until ClientPutInServer()
if ( i < clientMax | | ! pEdict - > pvPrivateData )
continue ;
pClass = CBaseEntity : : Instance ( pEdict ) ;
// Activate this entity if it's got a class & isn't dormant
2017-11-22 20:27:55 +03:00
if ( pClass & & ! pClass - > IsDormant ( ) )
2015-09-30 03:49:22 +03:00
{
AddEntityHashValue ( & pEdict - > v , STRING ( pEdict - > v . classname ) , CLASSNAME ) ;
pClass - > Activate ( ) ;
}
else
2017-11-22 20:27:55 +03:00
{
2015-09-30 03:49:22 +03:00
ALERT ( at_console , " Can't instance %s \n " , STRING ( pEdict - > v . classname ) ) ;
2017-11-22 20:27:55 +03:00
}
2015-09-30 03:49:22 +03:00
}
// Link user messages here to make sure first client can get them...
LinkUserMessages ( ) ;
WriteSigonMessages ( ) ;
2016-12-06 22:21:52 +03:00
if ( g_pGameRules )
2015-09-30 03:49:22 +03:00
{
g_pGameRules - > CheckMapConditions ( ) ;
}
2016-12-06 22:21:52 +03:00
if ( TheBots )
2015-12-05 22:40:30 +03:00
{
TheBots - > ServerActivate ( ) ;
}
2015-09-30 03:49:22 +03:00
2016-12-06 22:21:52 +03:00
if ( g_pHostages )
2015-09-30 03:49:22 +03:00
{
g_pHostages - > ServerActivate ( ) ;
}
2016-06-02 01:08:22 +03:00
# ifdef REGAMEDLL_ADD
CSGameRules ( ) - > ServerActivate ( ) ;
# endif
2015-09-30 03:49:22 +03:00
}
2015-12-09 01:39:54 +03:00
void EXT_FUNC PlayerPreThink ( edict_t * pEntity )
2015-09-30 03:49:22 +03:00
{
entvars_t * pev = & pEntity - > v ;
CBasePlayer * pPlayer = ( CBasePlayer * ) GET_PRIVATE ( pEntity ) ;
if ( pPlayer )
{
pPlayer - > PreThink ( ) ;
}
}
2015-12-09 01:39:54 +03:00
void EXT_FUNC PlayerPostThink ( edict_t * pEntity )
2015-09-30 03:49:22 +03:00
{
entvars_t * pev = & pEntity - > v ;
CBasePlayer * pPlayer = ( CBasePlayer * ) GET_PRIVATE ( pEntity ) ;
if ( pPlayer )
{
pPlayer - > PostThink ( ) ;
}
}
2016-02-04 03:18:26 +03:00
void EXT_FUNC ParmsNewLevel ( )
2015-09-30 03:49:22 +03:00
{
;
}
2016-02-04 03:18:26 +03:00
void EXT_FUNC ParmsChangeLevel ( )
2015-09-30 03:49:22 +03:00
{
// retrieve the pointer to the save data
SAVERESTOREDATA * pSaveData = ( SAVERESTOREDATA * ) gpGlobals - > pSaveData ;
if ( pSaveData )
{
pSaveData - > connectionCount = BuildChangeList ( pSaveData - > levelList , MAX_LEVEL_CONNECTIONS ) ;
}
}
2016-02-04 03:18:26 +03:00
void EXT_FUNC StartFrame ( )
2015-09-30 03:49:22 +03:00
{
2016-12-06 22:21:52 +03:00
if ( g_pGameRules )
{
2015-09-30 03:49:22 +03:00
g_pGameRules - > Think ( ) ;
2016-12-06 22:21:52 +03:00
if ( g_pGameRules - > IsGameOver ( ) )
return ;
2015-09-30 03:49:22 +03:00
}
CLocalNav : : Think ( ) ;
gpGlobals - > teamplay = 1.0f ;
2017-10-19 20:12:02 +03:00
g_iSkillLevel = g_pskill ? ( int ) g_pskill - > value : 0 ;
2015-09-30 03:49:22 +03:00
2016-07-14 17:12:17 +03:00
if ( TheBots ) {
2015-12-05 22:40:30 +03:00
TheBots - > StartFrame ( ) ;
}
2015-09-30 03:49:22 +03:00
2016-07-14 17:12:17 +03:00
if ( TheTutor ) {
2015-09-30 03:49:22 +03:00
TheTutor - > StartFrame ( gpGlobals - > time ) ;
}
2017-10-12 20:37:01 +03:00
EndFrame ( ) ;
}
void EndFrame ( )
{
CTriggerSetOriginManager : : getInstance ( ) - > Update ( ) ;
2015-09-30 03:49:22 +03:00
}
2016-02-04 03:18:26 +03:00
void ClientPrecache ( )
2015-09-30 03:49:22 +03:00
{
int i ;
PRECACHE_SOUND ( " weapons/dryfire_pistol.wav " ) ;
PRECACHE_SOUND ( " weapons/dryfire_rifle.wav " ) ;
PRECACHE_SOUND ( " player/pl_shot1.wav " ) ;
PRECACHE_SOUND ( " player/pl_die1.wav " ) ;
PRECACHE_SOUND ( " player/headshot1.wav " ) ;
PRECACHE_SOUND ( " player/headshot2.wav " ) ;
PRECACHE_SOUND ( " player/headshot3.wav " ) ;
PRECACHE_SOUND ( " player/bhit_flesh-1.wav " ) ;
PRECACHE_SOUND ( " player/bhit_flesh-2.wav " ) ;
PRECACHE_SOUND ( " player/bhit_flesh-3.wav " ) ;
PRECACHE_SOUND ( " player/bhit_kevlar-1.wav " ) ;
PRECACHE_SOUND ( " player/bhit_helmet-1.wav " ) ;
PRECACHE_SOUND ( " player/die1.wav " ) ;
PRECACHE_SOUND ( " player/die2.wav " ) ;
PRECACHE_SOUND ( " player/die3.wav " ) ;
PRECACHE_SOUND ( " player/death6.wav " ) ;
PRECACHE_SOUND ( " radio/locknload.wav " ) ;
PRECACHE_SOUND ( " radio/letsgo.wav " ) ;
PRECACHE_SOUND ( " radio/moveout.wav " ) ;
PRECACHE_SOUND ( " radio/com_go.wav " ) ;
PRECACHE_SOUND ( " radio/rescued.wav " ) ;
PRECACHE_SOUND ( " radio/rounddraw.wav " ) ;
PRECACHE_SOUND ( " items/kevlar.wav " ) ;
PRECACHE_SOUND ( " items/ammopickup2.wav " ) ;
PRECACHE_SOUND ( " items/nvg_on.wav " ) ;
PRECACHE_SOUND ( " items/nvg_off.wav " ) ;
PRECACHE_SOUND ( " items/equip_nvg.wav " ) ;
PRECACHE_SOUND ( " weapons/c4_beep1.wav " ) ;
PRECACHE_SOUND ( " weapons/c4_beep2.wav " ) ;
PRECACHE_SOUND ( " weapons/c4_beep3.wav " ) ;
PRECACHE_SOUND ( " weapons/c4_beep4.wav " ) ;
PRECACHE_SOUND ( " weapons/c4_beep5.wav " ) ;
PRECACHE_SOUND ( " weapons/c4_explode1.wav " ) ;
PRECACHE_SOUND ( " weapons/c4_plant.wav " ) ;
PRECACHE_SOUND ( " weapons/c4_disarm.wav " ) ;
PRECACHE_SOUND ( " weapons/c4_disarmed.wav " ) ;
PRECACHE_SOUND ( " weapons/explode3.wav " ) ;
PRECACHE_SOUND ( " weapons/explode4.wav " ) ;
PRECACHE_SOUND ( " weapons/explode5.wav " ) ;
PRECACHE_SOUND ( " player/sprayer.wav " ) ;
PRECACHE_SOUND ( " player/pl_fallpain2.wav " ) ;
PRECACHE_SOUND ( " player/pl_fallpain3.wav " ) ;
PRECACHE_SOUND ( " player/pl_snow1.wav " ) ;
PRECACHE_SOUND ( " player/pl_snow2.wav " ) ;
PRECACHE_SOUND ( " player/pl_snow3.wav " ) ;
PRECACHE_SOUND ( " player/pl_snow4.wav " ) ;
PRECACHE_SOUND ( " player/pl_snow5.wav " ) ;
PRECACHE_SOUND ( " player/pl_snow6.wav " ) ;
PRECACHE_SOUND ( " player/pl_step1.wav " ) ;
PRECACHE_SOUND ( " player/pl_step2.wav " ) ;
PRECACHE_SOUND ( " player/pl_step3.wav " ) ;
PRECACHE_SOUND ( " player/pl_step4.wav " ) ;
PRECACHE_SOUND ( " common/npc_step1.wav " ) ;
PRECACHE_SOUND ( " common/npc_step2.wav " ) ;
PRECACHE_SOUND ( " common/npc_step3.wav " ) ;
PRECACHE_SOUND ( " common/npc_step4.wav " ) ;
PRECACHE_SOUND ( " player/pl_metal1.wav " ) ;
PRECACHE_SOUND ( " player/pl_metal2.wav " ) ;
PRECACHE_SOUND ( " player/pl_metal3.wav " ) ;
PRECACHE_SOUND ( " player/pl_metal4.wav " ) ;
PRECACHE_SOUND ( " player/pl_dirt1.wav " ) ;
PRECACHE_SOUND ( " player/pl_dirt2.wav " ) ;
PRECACHE_SOUND ( " player/pl_dirt3.wav " ) ;
PRECACHE_SOUND ( " player/pl_dirt4.wav " ) ;
PRECACHE_SOUND ( " player/pl_duct1.wav " ) ;
PRECACHE_SOUND ( " player/pl_duct2.wav " ) ;
PRECACHE_SOUND ( " player/pl_duct3.wav " ) ;
PRECACHE_SOUND ( " player/pl_duct4.wav " ) ;
PRECACHE_SOUND ( " player/pl_grate1.wav " ) ;
PRECACHE_SOUND ( " player/pl_grate2.wav " ) ;
PRECACHE_SOUND ( " player/pl_grate3.wav " ) ;
PRECACHE_SOUND ( " player/pl_grate4.wav " ) ;
PRECACHE_SOUND ( " player/pl_slosh1.wav " ) ;
PRECACHE_SOUND ( " player/pl_slosh2.wav " ) ;
PRECACHE_SOUND ( " player/pl_slosh3.wav " ) ;
PRECACHE_SOUND ( " player/pl_slosh4.wav " ) ;
PRECACHE_SOUND ( " player/pl_tile1.wav " ) ;
PRECACHE_SOUND ( " player/pl_tile2.wav " ) ;
PRECACHE_SOUND ( " player/pl_tile3.wav " ) ;
PRECACHE_SOUND ( " player/pl_tile4.wav " ) ;
PRECACHE_SOUND ( " player/pl_tile5.wav " ) ;
PRECACHE_SOUND ( " player/pl_swim1.wav " ) ;
PRECACHE_SOUND ( " player/pl_swim2.wav " ) ;
PRECACHE_SOUND ( " player/pl_swim3.wav " ) ;
PRECACHE_SOUND ( " player/pl_swim4.wav " ) ;
PRECACHE_SOUND ( " player/pl_ladder1.wav " ) ;
PRECACHE_SOUND ( " player/pl_ladder2.wav " ) ;
PRECACHE_SOUND ( " player/pl_ladder3.wav " ) ;
PRECACHE_SOUND ( " player/pl_ladder4.wav " ) ;
PRECACHE_SOUND ( " player/pl_wade1.wav " ) ;
PRECACHE_SOUND ( " player/pl_wade2.wav " ) ;
PRECACHE_SOUND ( " player/pl_wade3.wav " ) ;
PRECACHE_SOUND ( " player/pl_wade4.wav " ) ;
PRECACHE_SOUND ( " debris/wood1.wav " ) ;
PRECACHE_SOUND ( " debris/wood2.wav " ) ;
PRECACHE_SOUND ( " debris/wood3.wav " ) ;
PRECACHE_SOUND ( " plats/train_use1.wav " ) ;
PRECACHE_SOUND ( " plats/vehicle_ignition.wav " ) ;
PRECACHE_SOUND ( " buttons/spark5.wav " ) ;
PRECACHE_SOUND ( " buttons/spark6.wav " ) ;
PRECACHE_SOUND ( " debris/glass1.wav " ) ;
PRECACHE_SOUND ( " debris/glass2.wav " ) ;
PRECACHE_SOUND ( " debris/glass3.wav " ) ;
2017-10-12 17:50:56 +03:00
PRECACHE_SOUND ( SOUND_FLASHLIGHT_ON ) ;
PRECACHE_SOUND ( SOUND_FLASHLIGHT_OFF ) ;
2015-09-30 03:49:22 +03:00
PRECACHE_SOUND ( " common/bodysplat.wav " ) ;
PRECACHE_SOUND ( " player/pl_pain2.wav " ) ;
PRECACHE_SOUND ( " player/pl_pain4.wav " ) ;
PRECACHE_SOUND ( " player/pl_pain5.wav " ) ;
PRECACHE_SOUND ( " player/pl_pain6.wav " ) ;
PRECACHE_SOUND ( " player/pl_pain7.wav " ) ;
int numPlayerModels ;
2017-10-12 17:50:56 +03:00
if ( AreRunningCZero ( ) )
2015-09-30 03:49:22 +03:00
numPlayerModels = ARRAYSIZE ( sPlayerModelFiles ) ;
else
numPlayerModels = ARRAYSIZE ( sPlayerModelFiles ) - 2 ;
2017-11-22 20:27:55 +03:00
for ( i = 0 ; i < numPlayerModels ; i + + )
2015-09-30 03:49:22 +03:00
PRECACHE_MODEL ( sPlayerModelFiles [ i ] ) ;
2017-10-12 17:50:56 +03:00
if ( AreRunningCZero ( ) )
2015-09-30 03:49:22 +03:00
{
2017-11-22 20:27:55 +03:00
for ( i = FirstCustomSkin ; i < = LastCustomSkin ; i + + )
2015-12-05 22:40:30 +03:00
{
const char * fname = TheBotProfiles - > GetCustomSkinFname ( i ) ;
2015-09-30 03:49:22 +03:00
2015-12-05 22:40:30 +03:00
if ( ! fname )
break ;
2015-09-30 03:49:22 +03:00
2020-12-25 15:40:01 +03:00
PRECACHE_MODEL ( fname ) ;
2015-12-05 22:40:30 +03:00
}
2015-09-30 03:49:22 +03:00
}
PRECACHE_MODEL ( " models/p_ak47.mdl " ) ;
PRECACHE_MODEL ( " models/p_aug.mdl " ) ;
PRECACHE_MODEL ( " models/p_awp.mdl " ) ;
PRECACHE_MODEL ( " models/p_c4.mdl " ) ;
PRECACHE_MODEL ( " models/w_c4.mdl " ) ;
PRECACHE_MODEL ( " models/p_deagle.mdl " ) ;
PRECACHE_MODEL ( " models/shield/p_shield_deagle.mdl " ) ;
PRECACHE_MODEL ( " models/p_flashbang.mdl " ) ;
PRECACHE_MODEL ( " models/shield/p_shield_flashbang.mdl " ) ;
PRECACHE_MODEL ( " models/p_hegrenade.mdl " ) ;
PRECACHE_MODEL ( " models/shield/p_shield_hegrenade.mdl " ) ;
PRECACHE_MODEL ( " models/p_glock18.mdl " ) ;
PRECACHE_MODEL ( " models/shield/p_shield_glock18.mdl " ) ;
PRECACHE_MODEL ( " models/p_p228.mdl " ) ;
PRECACHE_MODEL ( " models/shield/p_shield_p228.mdl " ) ;
PRECACHE_MODEL ( " models/p_smokegrenade.mdl " ) ;
PRECACHE_MODEL ( " models/shield/p_shield_smokegrenade.mdl " ) ;
PRECACHE_MODEL ( " models/p_usp.mdl " ) ;
PRECACHE_MODEL ( " models/shield/p_shield_usp.mdl " ) ;
PRECACHE_MODEL ( " models/p_fiveseven.mdl " ) ;
PRECACHE_MODEL ( " models/shield/p_shield_fiveseven.mdl " ) ;
PRECACHE_MODEL ( " models/p_knife.mdl " ) ;
PRECACHE_MODEL ( " models/shield/p_shield_knife.mdl " ) ;
PRECACHE_MODEL ( " models/w_flashbang.mdl " ) ;
PRECACHE_MODEL ( " models/w_hegrenade.mdl " ) ;
PRECACHE_MODEL ( " models/p_sg550.mdl " ) ;
PRECACHE_MODEL ( " models/p_g3sg1.mdl " ) ;
PRECACHE_MODEL ( " models/p_m249.mdl " ) ;
PRECACHE_MODEL ( " models/p_m3.mdl " ) ;
PRECACHE_MODEL ( " models/p_m4a1.mdl " ) ;
PRECACHE_MODEL ( " models/p_mac10.mdl " ) ;
PRECACHE_MODEL ( " models/p_mp5.mdl " ) ;
PRECACHE_MODEL ( " models/p_ump45.mdl " ) ;
PRECACHE_MODEL ( " models/p_p90.mdl " ) ;
PRECACHE_MODEL ( " models/p_scout.mdl " ) ;
PRECACHE_MODEL ( " models/p_sg552.mdl " ) ;
PRECACHE_MODEL ( " models/w_smokegrenade.mdl " ) ;
PRECACHE_MODEL ( " models/p_tmp.mdl " ) ;
PRECACHE_MODEL ( " models/p_elite.mdl " ) ;
PRECACHE_MODEL ( " models/p_xm1014.mdl " ) ;
PRECACHE_MODEL ( " models/p_galil.mdl " ) ;
PRECACHE_MODEL ( " models/p_famas.mdl " ) ;
PRECACHE_MODEL ( " models/p_shield.mdl " ) ;
PRECACHE_MODEL ( " models/w_shield.mdl " ) ;
Vector temp = g_vecZero ;
2016-05-11 17:06:43 +03:00
Vector vMin ( - 38 , - 24 , - 41 ) ;
Vector vMax ( 38 , 24 , 41 ) ;
2015-09-30 03:49:22 +03:00
2017-11-22 20:27:55 +03:00
for ( i = 0 ; i < numPlayerModels ; i + + )
2015-09-30 03:49:22 +03:00
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , sPlayerModelFiles [ i ] ) ;
2017-10-12 17:50:56 +03:00
if ( AreRunningCZero ( ) )
2015-09-30 03:49:22 +03:00
{
2017-11-22 20:27:55 +03:00
for ( i = FirstCustomSkin ; i < = LastCustomSkin ; i + + )
2015-12-05 22:40:30 +03:00
{
const char * fname = TheBotProfiles - > GetCustomSkinFname ( i ) ;
if ( ! fname )
break ;
2015-09-30 03:49:22 +03:00
2015-12-05 22:40:30 +03:00
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds_if_avail , ( float * ) & vMin , ( float * ) & vMax , fname ) ;
}
2015-09-30 03:49:22 +03:00
}
ENGINE_FORCE_UNMODIFIED ( force_exactfile , ( float * ) & temp , ( float * ) & temp , " sprites/black_smoke1.spr " ) ;
ENGINE_FORCE_UNMODIFIED ( force_exactfile , ( float * ) & temp , ( float * ) & temp , " sprites/black_smoke2.spr " ) ;
ENGINE_FORCE_UNMODIFIED ( force_exactfile , ( float * ) & temp , ( float * ) & temp , " sprites/black_smoke3.spr " ) ;
ENGINE_FORCE_UNMODIFIED ( force_exactfile , ( float * ) & temp , ( float * ) & temp , " sprites/black_smoke4.spr " ) ;
ENGINE_FORCE_UNMODIFIED ( force_exactfile , ( float * ) & temp , ( float * ) & temp , " sprites/fast_wallpuff1.spr " ) ;
ENGINE_FORCE_UNMODIFIED ( force_exactfile , ( float * ) & temp , ( float * ) & temp , " sprites/smokepuff.spr " ) ;
ENGINE_FORCE_UNMODIFIED ( force_exactfile , ( float * ) & temp , ( float * ) & temp , " sprites/gas_puff_01.spr " ) ;
ENGINE_FORCE_UNMODIFIED ( force_exactfile , ( float * ) & temp , ( float * ) & temp , " sprites/scope_arc.tga " ) ;
ENGINE_FORCE_UNMODIFIED ( force_exactfile , ( float * ) & temp , ( float * ) & temp , " sprites/scope_arc_nw.tga " ) ;
ENGINE_FORCE_UNMODIFIED ( force_exactfile , ( float * ) & temp , ( float * ) & temp , " sprites/scope_arc_ne.tga " ) ;
ENGINE_FORCE_UNMODIFIED ( force_exactfile , ( float * ) & temp , ( float * ) & temp , " sprites/scope_arc_sw.tga " ) ;
2017-10-12 17:50:56 +03:00
if ( AreRunningCZero ( ) )
2015-09-30 03:49:22 +03:00
{
vMin = Vector ( - 13 , - 6 , - 22 ) ;
vMax = Vector ( 13 , 6 , 22 ) ;
}
else
{
vMin = Vector ( - 12 , - 6 , - 22 ) ;
vMax = Vector ( 12 , 6 , 22 ) ;
}
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/p_deagle.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/p_p228.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/p_elite.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/p_usp.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/p_fiveseven.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/p_glock18.mdl " ) ;
2017-10-12 17:50:56 +03:00
if ( AreRunningCZero ( ) )
2015-09-30 03:49:22 +03:00
{
vMin = Vector ( - 26 , - 19 , - 21 ) ;
vMax = Vector ( 26 , 23 , 21 ) ;
}
else
{
vMin = Vector ( - 25 , - 19 , - 21 ) ;
vMax = Vector ( 25 , 23 , 21 ) ;
}
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/p_xm1014.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/p_m3.mdl " ) ;
2017-10-12 17:50:56 +03:00
if ( AreRunningCZero ( ) )
2015-09-30 03:49:22 +03:00
{
vMin = Vector ( - 23 , - 9 , - 20 ) ;
vMax = Vector ( 23 , 17 , 20 ) ;
}
else
{
vMin = Vector ( - 23 , - 8 , - 20 ) ;
vMax = Vector ( 23 , 8 , 20 ) ;
}
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/p_mac10.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/p_mp5.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/p_ump45.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/p_tmp.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/p_p90.mdl " ) ;
2017-10-12 17:50:56 +03:00
if ( AreRunningCZero ( ) )
2015-09-30 03:49:22 +03:00
{
vMin = Vector ( - 38 , - 33 , - 22 ) ;
vMax = Vector ( 38 , 15 , 35 ) ;
}
else
{
vMin = Vector ( - 31 , - 8 , - 21 ) ;
vMax = Vector ( 31 , 12 , 31 ) ;
}
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/p_ak47.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/p_aug.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/p_awp.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/p_g3sg1.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/p_sg550.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/p_m4a1.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/p_scout.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/p_sg552.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/p_famas.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/p_galil.mdl " ) ;
2017-10-12 17:50:56 +03:00
if ( AreRunningCZero ( ) )
2015-09-30 03:49:22 +03:00
{
vMin = Vector ( - 30 , - 10 , - 20 ) ;
vMax = Vector ( 30 , 11 , 20 ) ;
}
else
{
vMin = Vector ( - 24 , - 10 , - 20 ) ;
vMax = Vector ( 25 , 10 , 20 ) ;
}
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/p_m249.mdl " ) ;
vMin = Vector ( - 7 , - 7 , - 15 ) ;
vMax = Vector ( 7 , 7 , 15 ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/p_c4.mdl " ) ;
vMin = Vector ( - 4 , - 8 , - 3 ) ;
vMax = Vector ( 3 , 7 , 3 ) ;
2017-10-12 17:50:56 +03:00
if ( AreRunningCZero ( ) )
2015-09-30 03:49:22 +03:00
{
vMin = Vector ( - 17 , - 8 , - 3 ) ;
vMax = Vector ( 17 , 7 , 3 ) ;
}
else
{
vMin = Vector ( - 4 , - 8 , - 3 ) ;
vMax = Vector ( 3 , 7 , 3 ) ;
}
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/w_c4.mdl " ) ;
2017-10-12 17:50:56 +03:00
if ( AreRunningCZero ( ) )
2015-09-30 03:49:22 +03:00
{
vMin = Vector ( - 7 , - 3 , - 18 ) ;
vMax = Vector ( 7 , 2 , 18 ) ;
}
else
{
vMin = Vector ( - 7 , - 2 , - 18 ) ;
vMax = Vector ( 7 , 2 , 18 ) ;
}
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/p_flashbang.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/p_hegrenade.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/p_smokegrenade.mdl " ) ;
2017-10-12 17:50:56 +03:00
if ( AreRunningCZero ( ) )
2015-09-30 03:49:22 +03:00
vMin = Vector ( - 5 , - 5 , - 7 ) ;
else
vMin = Vector ( - 5 , - 5 , - 5 ) ;
vMax = Vector ( 5 , 5 , 14 ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/w_flashbang.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/w_hegrenade.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/w_smokegrenade.mdl " ) ;
vMin = Vector ( - 7 , - 11 , - 18 ) ;
vMax = Vector ( 7 , 6 , 18 ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/p_knife.mdl " ) ;
2017-10-12 17:50:56 +03:00
if ( AreRunningCZero ( ) )
2015-09-30 03:49:22 +03:00
{
vMin = Vector ( - 21 , - 25 , - 54 ) ;
vMax = Vector ( 21 , 23 , 24 ) ;
}
else
{
vMin = Vector ( - 16 , - 8 , - 54 ) ;
vMax = Vector ( 16 , 6 , 24 ) ;
}
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/shield/p_shield_deagle.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/shield/p_shield_fiveseven.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/shield/p_shield_flashbang.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/shield/p_shield_glock18.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/shield/p_shield_hegrenade.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/shield/p_shield_knife.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/shield/p_shield_p228.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/shield/p_shield_smokegrenade.mdl " ) ;
ENGINE_FORCE_UNMODIFIED ( force_model_specifybounds , ( float * ) & vMin , ( float * ) & vMax , " models/shield/p_shield_usp.mdl " ) ;
PRECACHE_SOUND ( " common/wpn_hudoff.wav " ) ;
PRECACHE_SOUND ( " common/wpn_hudon.wav " ) ;
PRECACHE_SOUND ( " common/wpn_moveselect.wav " ) ;
PRECACHE_SOUND ( " common/wpn_select.wav " ) ;
PRECACHE_SOUND ( " common/wpn_denyselect.wav " ) ;
PRECACHE_SOUND ( " player/geiger6.wav " ) ;
PRECACHE_SOUND ( " player/geiger5.wav " ) ;
PRECACHE_SOUND ( " player/geiger4.wav " ) ;
PRECACHE_SOUND ( " player/geiger3.wav " ) ;
PRECACHE_SOUND ( " player/geiger2.wav " ) ;
PRECACHE_SOUND ( " player/geiger1.wav " ) ;
g_iShadowSprite = PRECACHE_MODEL ( " sprites/shadow_circle.spr " ) ;
PRECACHE_MODEL ( " sprites/wall_puff1.spr " ) ;
PRECACHE_MODEL ( " sprites/wall_puff2.spr " ) ;
PRECACHE_MODEL ( " sprites/wall_puff3.spr " ) ;
PRECACHE_MODEL ( " sprites/wall_puff4.spr " ) ;
PRECACHE_MODEL ( " sprites/black_smoke1.spr " ) ;
PRECACHE_MODEL ( " sprites/black_smoke2.spr " ) ;
PRECACHE_MODEL ( " sprites/black_smoke3.spr " ) ;
PRECACHE_MODEL ( " sprites/black_smoke4.spr " ) ;
2017-10-31 00:29:22 +03:00
# ifdef REGAMEDLL_FIXES
PRECACHE_MODEL ( " sprites/gas_puff_01.spr " ) ;
# endif
2015-09-30 03:49:22 +03:00
PRECACHE_MODEL ( " sprites/fast_wallpuff1.spr " ) ;
PRECACHE_MODEL ( " sprites/pistol_smoke1.spr " ) ;
PRECACHE_MODEL ( " sprites/pistol_smoke2.spr " ) ;
PRECACHE_MODEL ( " sprites/rifle_smoke1.spr " ) ;
PRECACHE_MODEL ( " sprites/rifle_smoke2.spr " ) ;
PRECACHE_MODEL ( " sprites/rifle_smoke3.spr " ) ;
PRECACHE_GENERIC ( " sprites/scope_arc.tga " ) ;
PRECACHE_GENERIC ( " sprites/scope_arc_nw.tga " ) ;
PRECACHE_GENERIC ( " sprites/scope_arc_ne.tga " ) ;
PRECACHE_GENERIC ( " sprites/scope_arc_sw.tga " ) ;
m_usResetDecals = g_engfuncs . pfnPrecacheEvent ( 1 , " events/decal_reset.sc " ) ;
}
2016-02-04 03:18:26 +03:00
const char * EXT_FUNC GetGameDescription ( )
2015-09-30 03:49:22 +03:00
{
2016-06-14 01:13:13 +03:00
# ifdef REGAMEDLL_ADD
if ( CSGameRules ( ) ) {
return CSGameRules ( ) - > GetGameDescription ( ) ;
}
# else
2017-10-12 17:50:56 +03:00
if ( AreRunningCZero ( ) ) {
2016-06-14 01:13:13 +03:00
return " Condition Zero " ;
}
# endif
return " Counter-Strike " ;
2015-09-30 03:49:22 +03:00
}
2016-12-12 18:24:02 +03:00
void EXT_FUNC SysEngine_Error ( const char * error_string )
2015-09-30 03:49:22 +03:00
{
;
}
2015-12-09 01:39:54 +03:00
void EXT_FUNC PlayerCustomization ( edict_t * pEntity , customization_t * pCust )
2015-09-30 03:49:22 +03:00
{
CBasePlayer * pPlayer = ( CBasePlayer * ) GET_PRIVATE ( pEntity ) ;
if ( ! pPlayer )
{
ALERT ( at_console , " PlayerCustomization: Couldn't get player! \n " ) ;
return ;
}
if ( ! pCust )
{
ALERT ( at_console , " PlayerCustomization: NULL customization! \n " ) ;
return ;
}
switch ( pCust - > resource . type )
{
2015-12-09 01:39:54 +03:00
case t_decal :
pPlayer - > SetCustomDecalFrames ( pCust - > nUserData2 ) ;
break ;
case t_sound :
case t_skin :
case t_model :
break ;
default :
ALERT ( at_console , " PlayerCustomization: Unknown customization type! \n " ) ;
break ;
2015-09-30 03:49:22 +03:00
}
}
2015-12-09 01:39:54 +03:00
void EXT_FUNC SpectatorConnect ( edict_t * pEntity )
2015-09-30 03:49:22 +03:00
{
CBaseSpectator * pPlayer = ( CBaseSpectator * ) GET_PRIVATE ( pEntity ) ;
if ( pPlayer )
{
pPlayer - > SpectatorConnect ( ) ;
}
}
2015-12-09 01:39:54 +03:00
void EXT_FUNC SpectatorDisconnect ( edict_t * pEntity )
2015-09-30 03:49:22 +03:00
{
CBaseSpectator * pPlayer = ( CBaseSpectator * ) GET_PRIVATE ( pEntity ) ;
if ( pPlayer )
{
pPlayer - > SpectatorDisconnect ( ) ;
}
}
2015-12-09 01:39:54 +03:00
void EXT_FUNC SpectatorThink ( edict_t * pEntity )
2015-09-30 03:49:22 +03:00
{
CBaseSpectator * pPlayer = ( CBaseSpectator * ) GET_PRIVATE ( pEntity ) ;
if ( pPlayer )
{
pPlayer - > SpectatorThink ( ) ;
}
}
2015-12-09 01:39:54 +03:00
void EXT_FUNC SetupVisibility ( edict_t * pViewEntity , edict_t * pClient , unsigned char * * pvs , unsigned char * * pas )
2015-09-30 03:49:22 +03:00
{
edict_t * pView = pClient ;
// Find the client's PVS
if ( pViewEntity )
{
pView = pViewEntity ;
}
if ( pClient - > v . flags & FL_PROXY )
{
2016-06-14 01:13:13 +03:00
* pvs = nullptr ; // the spectator proxy sees
* pas = nullptr ; // and hears everything
2015-09-30 03:49:22 +03:00
return ;
}
2016-06-14 01:13:13 +03:00
CBasePlayer * pPlayer = CBasePlayer : : Instance ( pClient ) ;
if ( pPlayer & & pPlayer - > pev - > iuser2 & & pPlayer - > m_hObserverTarget )
2015-09-30 03:49:22 +03:00
{
if ( pPlayer - > m_afPhysicsFlags & PFLAG_OBSERVER )
{
pView = pPlayer - > m_hObserverTarget - > edict ( ) ;
UTIL_SetOrigin ( pPlayer - > pev , pPlayer - > m_hObserverTarget - > pev - > origin ) ;
}
}
Vector org = pView - > v . origin + pView - > v . view_ofs ;
if ( pView - > v . flags & FL_DUCKING )
{
org = org + ( VEC_HULL_MIN - VEC_DUCK_HULL_MIN ) ;
}
* pvs = ENGINE_SET_PVS ( ( float * ) & org ) ;
* pas = ENGINE_SET_PAS ( ( float * ) & org ) ;
}
void ResetPlayerPVS ( edict_t * client , int clientnum )
{
PLAYERPVSSTATUS * pvs = & g_PVSStatus [ clientnum ] ;
Q_memset ( pvs , 0 , sizeof ( * pvs ) ) ;
pvs - > headnode = client - > headnode ;
pvs - > num_leafs = client - > num_leafs ;
Q_memcpy ( pvs - > leafnums , client - > leafnums , sizeof ( pvs - > leafnums ) ) ;
}
bool CheckPlayerPVSLeafChanged ( edict_t * client , int clientnum )
{
PLAYERPVSSTATUS * pvs = & g_PVSStatus [ clientnum ] ;
if ( pvs - > headnode ! = client - > headnode | | pvs - > num_leafs ! = client - > num_leafs )
return true ;
2017-11-22 20:27:55 +03:00
for ( int i = 0 ; i < pvs - > num_leafs ; i + + )
2015-09-30 03:49:22 +03:00
{
if ( client - > leafnums [ i ] ! = pvs - > leafnums [ i ] )
return true ;
}
2017-11-22 20:27:55 +03:00
2015-09-30 03:49:22 +03:00
return false ;
}
void MarkEntityInPVS ( int clientnum , int entitynum , float time , bool inpvs )
{
PLAYERPVSSTATUS * pvs ;
ENTITYPVSSTATUS * es ;
pvs = & g_PVSStatus [ clientnum ] ;
es = & pvs - > m_Status [ entitynum ] ;
if ( inpvs )
es - > m_fTimeEnteredPVS = time ;
else
es - > m_fTimeEnteredPVS = 0 ;
}
bool CheckEntityRecentlyInPVS ( int clientnum , int entitynum , float currenttime )
{
PLAYERPVSSTATUS * pvs ;
ENTITYPVSSTATUS * es ;
pvs = & g_PVSStatus [ clientnum ] ;
es = & pvs - > m_Status [ entitynum ] ;
if ( es - > m_fTimeEnteredPVS & & es - > m_fTimeEnteredPVS + 1.0f > = currenttime )
{
return true ;
}
return false ;
}
2017-10-31 00:29:22 +03:00
BOOL EXT_FUNC AddToFullPack ( struct entity_state_s * state , int e , edict_t * ent , edict_t * host , int hostflags , BOOL player , unsigned char * pSet )
2015-09-30 03:49:22 +03:00
{
2019-08-29 18:31:33 +03:00
if ( ent ! = host )
{
if ( ( ent - > v . effects & EF_NODRAW ) = = EF_NODRAW )
return FALSE ;
# ifdef REGAMEDLL_ADD
if ( ent - > v . owner = = host )
{
// the owner can't see this entity
if ( ( ent - > v . effects & EF_OWNER_NO_VISIBILITY ) = = EF_OWNER_NO_VISIBILITY )
return FALSE ;
}
// no one can't see this entity except the owner
else if ( ( ent - > v . effects & EF_OWNER_VISIBILITY ) = = EF_OWNER_VISIBILITY )
return FALSE ;
# endif
}
2015-09-30 03:49:22 +03:00
if ( ! ent - > v . modelindex | | ! STRING ( ent - > v . model ) )
2017-10-31 00:29:22 +03:00
return FALSE ;
2015-09-30 03:49:22 +03:00
if ( ( ent - > v . flags & FL_SPECTATOR ) = = FL_SPECTATOR & & ent ! = host )
2017-10-31 00:29:22 +03:00
return FALSE ;
2015-09-30 03:49:22 +03:00
int i ;
int hostnum = ENTINDEX ( host ) - 1 ;
if ( CheckPlayerPVSLeafChanged ( host , hostnum ) )
ResetPlayerPVS ( host , hostnum ) ;
2019-08-29 16:51:41 +03:00
# ifdef REGAMEDLL_ADD
if ( ( ent - > v . effects & EF_FORCEVISIBILITY ) ! = EF_FORCEVISIBILITY )
# endif
2015-09-30 03:49:22 +03:00
{
2019-08-29 16:51:41 +03:00
if ( ent ! = host )
2015-09-30 03:49:22 +03:00
{
2019-08-29 16:51:41 +03:00
if ( ! CheckEntityRecentlyInPVS ( hostnum , e , gpGlobals - > time ) )
2015-09-30 03:49:22 +03:00
{
2019-08-29 16:51:41 +03:00
if ( ! ENGINE_CHECK_VISIBILITY ( ent , pSet ) )
{
MarkEntityInPVS ( hostnum , e , 0 , false ) ;
return FALSE ;
}
2015-09-30 03:49:22 +03:00
2019-08-29 16:51:41 +03:00
MarkEntityInPVS ( hostnum , e , gpGlobals - > time , true ) ;
}
2015-09-30 03:49:22 +03:00
}
}
if ( ( ent - > v . flags & FL_SKIPLOCALHOST ) = = FL_SKIPLOCALHOST & & ( hostflags & 1 ) & & ent - > v . owner = = host )
2017-10-31 00:29:22 +03:00
return FALSE ;
2015-09-30 03:49:22 +03:00
if ( host - > v . groupinfo )
{
UTIL_SetGroupTrace ( host - > v . groupinfo , GROUP_OP_AND ) ;
if ( ent - > v . groupinfo )
{
if ( g_groupop = = GROUP_OP_AND )
{
if ( ! ( ent - > v . groupinfo & host - > v . groupinfo ) )
2017-10-31 00:29:22 +03:00
return FALSE ;
2015-09-30 03:49:22 +03:00
}
else if ( g_groupop = = GROUP_OP_NAND )
{
if ( ent - > v . groupinfo & host - > v . groupinfo )
2017-10-31 00:29:22 +03:00
return FALSE ;
2015-09-30 03:49:22 +03:00
}
}
UTIL_UnsetGroupTrace ( ) ;
}
2015-11-24 00:01:09 +03:00
Q_memset ( state , 0 , sizeof ( entity_state_t ) ) ;
2015-09-30 03:49:22 +03:00
state - > number = e ;
state - > entityType = ENTITY_NORMAL ;
if ( ent - > v . flags & FL_CUSTOMENTITY )
state - > entityType = ENTITY_BEAM ;
2016-02-23 02:13:52 +03:00
state - > animtime = int ( 1000.0 * ent - > v . animtime ) / 1000.0 ;
2015-09-30 03:49:22 +03:00
Q_memcpy ( state - > origin , ent - > v . origin , sizeof ( float ) * 3 ) ;
Q_memcpy ( state - > angles , ent - > v . angles , sizeof ( float ) * 3 ) ;
Q_memcpy ( state - > mins , ent - > v . mins , sizeof ( float ) * 3 ) ;
Q_memcpy ( state - > maxs , ent - > v . maxs , sizeof ( float ) * 3 ) ;
Q_memcpy ( state - > startpos , ent - > v . startpos , sizeof ( float ) * 3 ) ;
Q_memcpy ( state - > endpos , ent - > v . endpos , sizeof ( float ) * 3 ) ;
state - > impacttime = ent - > v . impacttime ;
state - > starttime = ent - > v . starttime ;
state - > modelindex = ent - > v . modelindex ;
state - > frame = ent - > v . frame ;
state - > skin = ent - > v . skin ;
state - > effects = ent - > v . effects ;
2018-12-23 13:49:27 +03:00
# ifdef REGAMEDLL_ADD
2019-08-29 18:31:33 +03:00
// don't send unhandled custom bits to client
state - > effects & = ~ ( EF_FORCEVISIBILITY | EF_OWNER_VISIBILITY | EF_OWNER_NO_VISIBILITY ) ;
2019-08-29 16:51:41 +03:00
2018-12-23 13:49:27 +03:00
if ( ent - > v . skin = = CONTENTS_LADDER & &
( host - > v . iuser3 & PLAYER_PREVENT_CLIMB ) = = PLAYER_PREVENT_CLIMB ) {
state - > skin = CONTENTS_EMPTY ;
}
# endif
2015-09-30 03:49:22 +03:00
if ( ! player & & ent - > v . animtime & & ! ent - > v . velocity . x & & ! ent - > v . velocity . y & & ! ent - > v . velocity . z )
state - > eflags | = EFLAG_SLERP ;
state - > scale = ent - > v . scale ;
state - > solid = ent - > v . solid ;
state - > colormap = ent - > v . colormap ;
state - > movetype = ent - > v . movetype ;
state - > sequence = ent - > v . sequence ;
state - > framerate = ent - > v . framerate ;
state - > body = ent - > v . body ;
2017-11-22 20:27:55 +03:00
for ( i = 0 ; i < 4 ; i + + )
2015-09-30 03:49:22 +03:00
state - > controller [ i ] = ent - > v . controller [ i ] ;
2017-11-22 20:27:55 +03:00
for ( i = 0 ; i < 2 ; i + + )
2015-09-30 03:49:22 +03:00
state - > blending [ i ] = ent - > v . blending [ i ] ;
state - > rendermode = ent - > v . rendermode ;
2016-02-23 02:13:52 +03:00
state - > renderamt = int ( ent - > v . renderamt ) ;
2015-09-30 03:49:22 +03:00
state - > renderfx = ent - > v . renderfx ;
2016-02-23 02:13:52 +03:00
state - > rendercolor . r = byte ( ent - > v . rendercolor . x ) ;
state - > rendercolor . g = byte ( ent - > v . rendercolor . y ) ;
state - > rendercolor . b = byte ( ent - > v . rendercolor . z ) ;
2015-09-30 03:49:22 +03:00
state - > aiment = 0 ;
if ( ent - > v . aiment )
state - > aiment = ENTINDEX ( ent - > v . aiment ) ;
state - > owner = 0 ;
if ( ent - > v . owner )
{
int owner = ENTINDEX ( ent - > v . owner ) ;
if ( owner > = 1 & & owner < = gpGlobals - > maxClients )
state - > owner = owner ;
}
if ( player )
{
Q_memcpy ( state - > basevelocity , ent - > v . basevelocity , sizeof ( float ) * 3 ) ;
state - > weaponmodel = MODEL_INDEX ( STRING ( ent - > v . weaponmodel ) ) ;
state - > gaitsequence = ent - > v . gaitsequence ;
state - > spectator = ( ent - > v . flags & FL_SPECTATOR ) ? TRUE : FALSE ;
state - > friction = ent - > v . friction ;
state - > gravity = ent - > v . gravity ;
state - > usehull = ( ent - > v . flags & FL_DUCKING ) ? 1 : 0 ;
2016-02-23 02:13:52 +03:00
state - > health = int ( ent - > v . health ) ;
2015-09-30 03:49:22 +03:00
}
else
state - > playerclass = ent - > v . playerclass ;
state - > iuser4 = ent - > v . iuser4 ;
2017-10-31 00:29:22 +03:00
return TRUE ;
2015-09-30 03:49:22 +03:00
}
// Creates baselines used for network encoding, especially for player data since players are not spawned until connect time.
2017-10-17 15:38:40 +03:00
void EXT_FUNC CreateBaseline ( int player , int eindex , struct entity_state_s * baseline , edict_t * entity , int playermodelindex , Vector player_mins , Vector player_maxs )
2015-09-30 03:49:22 +03:00
{
baseline - > origin = entity - > v . origin ;
baseline - > angles = entity - > v . angles ;
baseline - > frame = entity - > v . frame ;
baseline - > skin = ( short ) entity - > v . skin ;
// render information
2016-02-23 02:13:52 +03:00
baseline - > rendermode = byte ( entity - > v . rendermode ) ;
baseline - > renderamt = byte ( entity - > v . renderamt ) ;
baseline - > rendercolor . r = byte ( entity - > v . rendercolor . x ) ;
baseline - > rendercolor . g = byte ( entity - > v . rendercolor . y ) ;
baseline - > rendercolor . b = byte ( entity - > v . rendercolor . z ) ;
baseline - > renderfx = byte ( entity - > v . renderfx ) ;
2015-09-30 03:49:22 +03:00
if ( player )
{
baseline - > mins = player_mins ;
baseline - > maxs = player_maxs ;
baseline - > colormap = eindex ;
baseline - > modelindex = playermodelindex ;
baseline - > friction = 1.0 ;
baseline - > movetype = MOVETYPE_WALK ;
baseline - > solid = SOLID_SLIDEBOX ;
baseline - > scale = entity - > v . scale ;
baseline - > framerate = 1.0 ;
baseline - > gravity = 1.0 ;
}
else
{
baseline - > mins = entity - > v . mins ;
baseline - > maxs = entity - > v . maxs ;
baseline - > colormap = 0 ;
baseline - > modelindex = entity - > v . modelindex ;
baseline - > movetype = entity - > v . movetype ;
baseline - > scale = entity - > v . scale ;
baseline - > solid = entity - > v . solid ;
baseline - > framerate = entity - > v . framerate ;
baseline - > gravity = entity - > v . gravity ;
}
}
void Entity_FieldInit ( struct delta_s * pFields )
{
2017-10-19 20:12:02 +03:00
entity_field_alias [ FIELD_ORIGIN0 ] . field = DELTA_FINDFIELD ( pFields , entity_field_alias [ FIELD_ORIGIN0 ] . name ) ;
entity_field_alias [ FIELD_ORIGIN1 ] . field = DELTA_FINDFIELD ( pFields , entity_field_alias [ FIELD_ORIGIN1 ] . name ) ;
entity_field_alias [ FIELD_ORIGIN2 ] . field = DELTA_FINDFIELD ( pFields , entity_field_alias [ FIELD_ORIGIN2 ] . name ) ;
entity_field_alias [ FIELD_ANGLES0 ] . field = DELTA_FINDFIELD ( pFields , entity_field_alias [ FIELD_ANGLES0 ] . name ) ;
entity_field_alias [ FIELD_ANGLES1 ] . field = DELTA_FINDFIELD ( pFields , entity_field_alias [ FIELD_ANGLES1 ] . name ) ;
entity_field_alias [ FIELD_ANGLES2 ] . field = DELTA_FINDFIELD ( pFields , entity_field_alias [ FIELD_ANGLES2 ] . name ) ;
2015-09-30 03:49:22 +03:00
}
// Callback for sending entity_state_t info over network.
void Entity_Encode ( struct delta_s * pFields , const unsigned char * from , const unsigned char * to )
{
entity_state_t * f , * t ;
int localplayer = 0 ;
static int initialized = 0 ;
if ( ! initialized )
{
Entity_FieldInit ( pFields ) ;
initialized = 1 ;
}
f = ( entity_state_t * ) from ;
t = ( entity_state_t * ) to ;
// Never send origin to local player, it's sent with more resolution in clientdata_t structure
2017-01-20 17:52:37 +03:00
localplayer = ( t - > number - 1 ) = = ENGINE_CURRENT_PLAYER ( ) ;
2015-09-30 03:49:22 +03:00
if ( localplayer )
{
2017-10-19 20:12:02 +03:00
DELTA_UNSETBYINDEX ( pFields , entity_field_alias [ FIELD_ORIGIN0 ] . field ) ;
DELTA_UNSETBYINDEX ( pFields , entity_field_alias [ FIELD_ORIGIN1 ] . field ) ;
DELTA_UNSETBYINDEX ( pFields , entity_field_alias [ FIELD_ORIGIN2 ] . field ) ;
2015-09-30 03:49:22 +03:00
}
if ( t - > impacttime ! = 0 & & t - > starttime ! = 0 )
{
2017-10-19 20:12:02 +03:00
DELTA_UNSETBYINDEX ( pFields , entity_field_alias [ FIELD_ORIGIN0 ] . field ) ;
DELTA_UNSETBYINDEX ( pFields , entity_field_alias [ FIELD_ORIGIN1 ] . field ) ;
DELTA_UNSETBYINDEX ( pFields , entity_field_alias [ FIELD_ORIGIN2 ] . field ) ;
2015-09-30 03:49:22 +03:00
2017-10-19 20:12:02 +03:00
DELTA_UNSETBYINDEX ( pFields , entity_field_alias [ FIELD_ANGLES0 ] . field ) ;
DELTA_UNSETBYINDEX ( pFields , entity_field_alias [ FIELD_ANGLES1 ] . field ) ;
DELTA_UNSETBYINDEX ( pFields , entity_field_alias [ FIELD_ANGLES2 ] . field ) ;
2015-09-30 03:49:22 +03:00
}
if ( t - > movetype = = MOVETYPE_FOLLOW & & t - > aiment ! = 0 )
{
2017-10-19 20:12:02 +03:00
DELTA_UNSETBYINDEX ( pFields , entity_field_alias [ FIELD_ORIGIN0 ] . field ) ;
DELTA_UNSETBYINDEX ( pFields , entity_field_alias [ FIELD_ORIGIN1 ] . field ) ;
DELTA_UNSETBYINDEX ( pFields , entity_field_alias [ FIELD_ORIGIN2 ] . field ) ;
2015-09-30 03:49:22 +03:00
}
else if ( t - > aiment ! = f - > aiment )
{
2017-10-19 20:12:02 +03:00
DELTA_SETBYINDEX ( pFields , entity_field_alias [ FIELD_ORIGIN0 ] . field ) ;
DELTA_SETBYINDEX ( pFields , entity_field_alias [ FIELD_ORIGIN1 ] . field ) ;
DELTA_SETBYINDEX ( pFields , entity_field_alias [ FIELD_ORIGIN2 ] . field ) ;
2015-09-30 03:49:22 +03:00
}
}
void Player_FieldInit ( struct delta_s * pFields )
{
2017-10-19 20:12:02 +03:00
player_field_alias [ FIELD_ORIGIN0 ] . field = DELTA_FINDFIELD ( pFields , player_field_alias [ FIELD_ORIGIN0 ] . name ) ;
player_field_alias [ FIELD_ORIGIN1 ] . field = DELTA_FINDFIELD ( pFields , player_field_alias [ FIELD_ORIGIN1 ] . name ) ;
player_field_alias [ FIELD_ORIGIN2 ] . field = DELTA_FINDFIELD ( pFields , player_field_alias [ FIELD_ORIGIN2 ] . name ) ;
2015-09-30 03:49:22 +03:00
}
// Callback for sending entity_state_t for players info over network.
void Player_Encode ( struct delta_s * pFields , const unsigned char * from , const unsigned char * to )
{
entity_state_t * f , * t ;
int localplayer = 0 ;
static int initialized = 0 ;
if ( ! initialized )
{
Player_FieldInit ( pFields ) ;
initialized = 1 ;
}
f = ( entity_state_t * ) from ;
t = ( entity_state_t * ) to ;
// Never send origin to local player, it's sent with more resolution in clientdata_t structure
2017-01-20 17:52:37 +03:00
localplayer = ( t - > number - 1 ) = = ENGINE_CURRENT_PLAYER ( ) ;
2015-09-30 03:49:22 +03:00
if ( localplayer )
{
2017-10-19 20:12:02 +03:00
DELTA_UNSETBYINDEX ( pFields , entity_field_alias [ FIELD_ORIGIN0 ] . field ) ;
DELTA_UNSETBYINDEX ( pFields , entity_field_alias [ FIELD_ORIGIN1 ] . field ) ;
DELTA_UNSETBYINDEX ( pFields , entity_field_alias [ FIELD_ORIGIN2 ] . field ) ;
2015-09-30 03:49:22 +03:00
}
if ( t - > movetype = = MOVETYPE_FOLLOW & & t - > aiment ! = 0 )
{
2017-10-19 20:12:02 +03:00
DELTA_UNSETBYINDEX ( pFields , entity_field_alias [ FIELD_ORIGIN0 ] . field ) ;
DELTA_UNSETBYINDEX ( pFields , entity_field_alias [ FIELD_ORIGIN1 ] . field ) ;
DELTA_UNSETBYINDEX ( pFields , entity_field_alias [ FIELD_ORIGIN2 ] . field ) ;
2015-09-30 03:49:22 +03:00
}
else if ( t - > aiment ! = f - > aiment )
{
2017-10-19 20:12:02 +03:00
DELTA_SETBYINDEX ( pFields , entity_field_alias [ FIELD_ORIGIN0 ] . field ) ;
DELTA_SETBYINDEX ( pFields , entity_field_alias [ FIELD_ORIGIN1 ] . field ) ;
DELTA_SETBYINDEX ( pFields , entity_field_alias [ FIELD_ORIGIN2 ] . field ) ;
2015-09-30 03:49:22 +03:00
}
}
void Custom_Entity_FieldInit ( delta_s * pFields )
{
2017-10-19 20:12:02 +03:00
custom_entity_field_alias [ CUSTOMFIELD_ORIGIN0 ] . field = DELTA_FINDFIELD ( pFields , custom_entity_field_alias [ CUSTOMFIELD_ORIGIN0 ] . name ) ;
custom_entity_field_alias [ CUSTOMFIELD_ORIGIN1 ] . field = DELTA_FINDFIELD ( pFields , custom_entity_field_alias [ CUSTOMFIELD_ORIGIN1 ] . name ) ;
custom_entity_field_alias [ CUSTOMFIELD_ORIGIN2 ] . field = DELTA_FINDFIELD ( pFields , custom_entity_field_alias [ CUSTOMFIELD_ORIGIN2 ] . name ) ;
custom_entity_field_alias [ CUSTOMFIELD_ANGLES0 ] . field = DELTA_FINDFIELD ( pFields , custom_entity_field_alias [ CUSTOMFIELD_ANGLES0 ] . name ) ;
custom_entity_field_alias [ CUSTOMFIELD_ANGLES1 ] . field = DELTA_FINDFIELD ( pFields , custom_entity_field_alias [ CUSTOMFIELD_ANGLES1 ] . name ) ;
custom_entity_field_alias [ CUSTOMFIELD_ANGLES2 ] . field = DELTA_FINDFIELD ( pFields , custom_entity_field_alias [ CUSTOMFIELD_ANGLES2 ] . name ) ;
custom_entity_field_alias [ CUSTOMFIELD_SKIN ] . field = DELTA_FINDFIELD ( pFields , custom_entity_field_alias [ CUSTOMFIELD_SKIN ] . name ) ;
custom_entity_field_alias [ CUSTOMFIELD_SEQUENCE ] . field = DELTA_FINDFIELD ( pFields , custom_entity_field_alias [ CUSTOMFIELD_SEQUENCE ] . name ) ;
custom_entity_field_alias [ CUSTOMFIELD_ANIMTIME ] . field = DELTA_FINDFIELD ( pFields , custom_entity_field_alias [ CUSTOMFIELD_ANIMTIME ] . name ) ;
2015-09-30 03:49:22 +03:00
}
// Callback for sending entity_state_t info ( for custom entities ) over network.
void Custom_Encode ( struct delta_s * pFields , const unsigned char * from , const unsigned char * to )
{
entity_state_t * f , * t ;
int beamType ;
static int initialized = 0 ;
if ( ! initialized )
{
Custom_Entity_FieldInit ( pFields ) ;
initialized = 1 ;
}
f = ( entity_state_t * ) from ;
t = ( entity_state_t * ) to ;
beamType = t - > rendermode & 0x0F ;
if ( beamType ! = BEAM_POINTS )
{
if ( beamType ! = BEAM_ENTPOINT )
{
2017-10-19 20:12:02 +03:00
DELTA_UNSETBYINDEX ( pFields , custom_entity_field_alias [ CUSTOMFIELD_ORIGIN0 ] . field ) ;
DELTA_UNSETBYINDEX ( pFields , custom_entity_field_alias [ CUSTOMFIELD_ORIGIN1 ] . field ) ;
DELTA_UNSETBYINDEX ( pFields , custom_entity_field_alias [ CUSTOMFIELD_ORIGIN2 ] . field ) ;
2015-09-30 03:49:22 +03:00
}
2017-10-19 20:12:02 +03:00
DELTA_UNSETBYINDEX ( pFields , custom_entity_field_alias [ CUSTOMFIELD_ANGLES0 ] . field ) ;
DELTA_UNSETBYINDEX ( pFields , custom_entity_field_alias [ CUSTOMFIELD_ANGLES1 ] . field ) ;
DELTA_UNSETBYINDEX ( pFields , custom_entity_field_alias [ CUSTOMFIELD_ANGLES2 ] . field ) ;
2015-09-30 03:49:22 +03:00
}
if ( beamType ! = BEAM_ENTS & & beamType ! = BEAM_ENTPOINT )
{
2017-10-19 20:12:02 +03:00
DELTA_UNSETBYINDEX ( pFields , custom_entity_field_alias [ CUSTOMFIELD_SKIN ] . field ) ;
DELTA_UNSETBYINDEX ( pFields , custom_entity_field_alias [ CUSTOMFIELD_SEQUENCE ] . field ) ;
2015-09-30 03:49:22 +03:00
}
// animtime is compared by rounding first
// see if we really shouldn't actually send it
2016-02-23 02:13:52 +03:00
if ( int ( f - > animtime ) = = int ( t - > animtime ) )
2015-09-30 03:49:22 +03:00
{
2017-10-19 20:12:02 +03:00
DELTA_UNSETBYINDEX ( pFields , custom_entity_field_alias [ CUSTOMFIELD_ANIMTIME ] . field ) ;
2015-09-30 03:49:22 +03:00
}
}
2016-06-14 01:13:13 +03:00
// Allows game .dll to override network encoding of certain types of entities and tweak values, etc.
2016-02-04 03:18:26 +03:00
void EXT_FUNC RegisterEncoders ( )
2015-09-30 03:49:22 +03:00
{
DELTA_ADDENCODER ( " Entity_Encode " , Entity_Encode ) ;
DELTA_ADDENCODER ( " Custom_Encode " , Custom_Encode ) ;
DELTA_ADDENCODER ( " Player_Encode " , Player_Encode ) ;
}
2017-10-17 15:38:40 +03:00
int EXT_FUNC GetWeaponData ( edict_t * pEdict , struct weapon_data_s * info )
2015-09-30 03:49:22 +03:00
{
2016-06-14 01:13:13 +03:00
# ifdef CLIENT_WEAPONS
2017-10-17 15:38:40 +03:00
entvars_t * pev = & pEdict - > v ;
2016-06-14 01:13:13 +03:00
CBasePlayer * pPlayer = CBasePlayer : : Instance ( pev ) ;
2015-09-30 03:49:22 +03:00
Q_memset ( info , 0 , sizeof ( weapon_data_t ) * MAX_WEAPONS ) ;
2016-06-14 01:13:13 +03:00
if ( ! pPlayer )
2015-09-30 03:49:22 +03:00
return 1 ;
2016-06-14 01:13:13 +03:00
// go through all of the weapons and make a list of the ones to pack
2017-10-12 17:50:56 +03:00
for ( int i = 0 ; i < MAX_ITEM_TYPES ; i + + )
2015-09-30 03:49:22 +03:00
{
2016-06-14 01:13:13 +03:00
auto pPlayerItem = pPlayer - > m_rgpPlayerItems [ i ] ;
2017-10-12 17:50:56 +03:00
while ( pPlayerItem )
2015-09-30 03:49:22 +03:00
{
2016-06-14 01:13:13 +03:00
// there's a weapon here. Should I pack it?
auto weapon = ( CBasePlayerWeapon * ) pPlayerItem - > GetWeaponPtr ( ) ;
if ( weapon & & weapon - > UseDecrement ( ) )
2015-09-30 03:49:22 +03:00
{
2016-06-14 01:13:13 +03:00
// Get The ID
2015-09-30 03:49:22 +03:00
ItemInfo II ;
Q_memset ( & II , 0 , sizeof ( II ) ) ;
2020-02-12 14:34:40 +03:00
# ifdef REGAMEDLL_API
pPlayerItem - > CSPlayerItem ( ) - > GetItemInfo ( & II ) ;
# else
2016-06-14 01:13:13 +03:00
weapon - > GetItemInfo ( & II ) ;
2020-02-12 14:34:40 +03:00
# endif
2015-09-30 03:49:22 +03:00
if ( II . iId > = 0 & & II . iId < MAX_WEAPONS )
{
2016-06-14 01:13:13 +03:00
auto item = & info [ II . iId ] ;
2015-09-30 03:49:22 +03:00
item - > m_iId = II . iId ;
2016-06-14 01:13:13 +03:00
item - > m_iClip = weapon - > m_iClip ;
item - > m_flTimeWeaponIdle = Q_max ( weapon - > m_flTimeWeaponIdle , - 0.001f ) ;
item - > m_flNextPrimaryAttack = Q_max ( weapon - > m_flNextPrimaryAttack , - 0.001f ) ;
item - > m_flNextSecondaryAttack = Q_max ( weapon - > m_flNextSecondaryAttack , - 0.001f ) ;
item - > m_flNextReload = Q_max ( weapon - > m_flNextReload , - 0.001f ) ;
item - > m_fInReload = weapon - > m_fInReload ;
item - > m_fInSpecialReload = weapon - > m_fInSpecialReload ;
item - > m_fInZoom = weapon - > m_iShotsFired ;
item - > m_fAimedDamage = weapon - > m_flLastFire ;
item - > m_iWeaponState = weapon - > m_iWeaponState ;
item - > fuser2 = weapon - > m_flStartThrow ;
item - > fuser3 = weapon - > m_flReleaseThrow ;
item - > iuser1 = weapon - > m_iSwing ;
2023-09-28 12:08:35 +03:00
# ifdef REGAMEDLL_FIXES
if ( pPlayerItem = = pPlayer - > m_pActiveItem & & ! weapon - > m_fInReload & & weapon - > m_iClip = = II . iMaxClip )
{
const WeaponInfoStruct * wpnInfo = GetDefaultWeaponInfo ( II . iId ) ;
if ( wpnInfo & & wpnInfo - > gunClipSize ! = II . iMaxClip )
2023-10-25 07:37:32 +03:00
item - > m_iClip = wpnInfo - > gunClipSize ;
2023-09-28 12:08:35 +03:00
}
# endif
2015-09-30 03:49:22 +03:00
}
}
pPlayerItem = pPlayerItem - > m_pNext ;
}
}
2016-06-14 01:13:13 +03:00
# else
Q_memset ( info , 0 , sizeof ( weapon_data_t ) * MAX_WEAPONS ) ;
# endif
2015-09-30 03:49:22 +03:00
return 1 ;
}
2016-06-14 01:13:13 +03:00
// Data sent to current client only engine sets cd to 0 before calling.
2017-10-17 15:38:40 +03:00
void EXT_FUNC UpdateClientData ( const edict_t * ent , int sendweapons , struct clientdata_s * cd )
2015-09-30 03:49:22 +03:00
{
if ( ! ent | | ! ent - > pvPrivateData )
return ;
2016-06-14 01:13:13 +03:00
entvars_t * pevOrg = nullptr ;
2016-02-04 03:18:26 +03:00
entvars_t * pev = const_cast < entvars_t * > ( & ent - > v ) ;
2016-06-14 01:13:13 +03:00
CBasePlayer * pPlayer = CBasePlayer : : Instance ( pev ) ;
2015-09-30 03:49:22 +03:00
2016-06-14 01:13:13 +03:00
// if user is spectating different player in First person, override some vars
if ( pPlayer & & pPlayer - > pev - > iuser1 = = OBS_IN_EYE & & pPlayer - > m_hObserverTarget )
2015-09-30 03:49:22 +03:00
{
pevOrg = pev ;
2016-06-14 01:13:13 +03:00
pev = pPlayer - > m_hObserverTarget - > pev ;
pPlayer = CBasePlayer : : Instance ( pev ) ;
2015-09-30 03:49:22 +03:00
}
cd - > flags = pev - > flags ;
cd - > health = pev - > health ;
cd - > viewmodel = MODEL_INDEX ( STRING ( pev - > viewmodel ) ) ;
cd - > waterlevel = pev - > waterlevel ;
cd - > watertype = pev - > watertype ;
cd - > weapons = pev - > weapons ;
cd - > origin = pev - > origin ;
cd - > velocity = pev - > velocity ;
cd - > view_ofs = pev - > view_ofs ;
cd - > punchangle = pev - > punchangle ;
cd - > bInDuck = pev - > bInDuck ;
cd - > flTimeStepSound = pev - > flTimeStepSound ;
cd - > flDuckTime = pev - > flDuckTime ;
cd - > flSwimTime = pev - > flSwimTime ;
2016-02-23 02:13:52 +03:00
cd - > waterjumptime = int ( pev - > teleport_time ) ;
2015-09-30 03:49:22 +03:00
Q_strcpy ( cd - > physinfo , ENGINE_GETPHYSINFO ( ent ) ) ;
cd - > maxspeed = pev - > maxspeed ;
cd - > fov = pev - > fov ;
cd - > weaponanim = pev - > weaponanim ;
cd - > pushmsec = pev - > pushmsec ;
if ( pevOrg )
{
cd - > iuser1 = pevOrg - > iuser1 ;
cd - > iuser2 = pevOrg - > iuser2 ;
cd - > iuser3 = pevOrg - > iuser3 ;
}
else
{
cd - > iuser1 = pev - > iuser1 ;
cd - > iuser2 = pev - > iuser2 ;
cd - > iuser3 = pev - > iuser3 ;
}
cd - > fuser1 = pev - > fuser1 ;
cd - > fuser3 = pev - > fuser3 ;
cd - > fuser2 = pev - > fuser2 ;
2016-06-14 01:13:13 +03:00
if ( sendweapons & & pPlayer )
2015-09-30 03:49:22 +03:00
{
2016-06-14 01:13:13 +03:00
cd - > ammo_shells = pPlayer - > ammo_buckshot ;
cd - > ammo_nails = pPlayer - > ammo_9mm ;
cd - > ammo_cells = pPlayer - > ammo_556nato ;
cd - > ammo_rockets = pPlayer - > ammo_556natobox ;
cd - > vuser2 . x = pPlayer - > ammo_762nato ;
cd - > vuser2 . y = pPlayer - > ammo_45acp ;
cd - > vuser2 . z = pPlayer - > ammo_50ae ;
cd - > vuser3 . x = pPlayer - > ammo_338mag ;
cd - > vuser3 . y = pPlayer - > ammo_57mm ;
cd - > vuser3 . z = pPlayer - > ammo_357sig ;
cd - > m_flNextAttack = pPlayer - > m_flNextAttack ;
2015-09-30 03:49:22 +03:00
int iUser3 = 0 ;
2020-05-02 13:11:49 +03:00
if (
# ifdef REGAMEDLL_API
pPlayer - > CSPlayer ( ) - > m_bCanShootOverride | |
# endif
( pPlayer - > m_bCanShoot & & ! pPlayer - > m_bIsDefusing ) )
2016-12-06 22:21:52 +03:00
iUser3 | = PLAYER_CAN_SHOOT ;
2015-09-30 03:49:22 +03:00
if ( g_pGameRules - > IsFreezePeriod ( ) )
2016-12-06 22:21:52 +03:00
iUser3 | = PLAYER_FREEZE_TIME_OVER ;
2015-09-30 03:49:22 +03:00
2016-06-14 01:13:13 +03:00
if ( pPlayer - > m_signals . GetState ( ) & SIGNAL_BOMB )
2016-12-06 22:21:52 +03:00
iUser3 | = PLAYER_IN_BOMB_ZONE ;
2015-09-30 03:49:22 +03:00
2016-06-14 01:13:13 +03:00
if ( pPlayer - > HasShield ( ) )
2016-12-06 22:21:52 +03:00
iUser3 | = PLAYER_HOLDING_SHIELD ;
2015-09-30 03:49:22 +03:00
2016-06-14 01:13:13 +03:00
if ( pPlayer - > pev - > iuser1 = = OBS_NONE & & ! pevOrg )
2016-06-02 01:08:22 +03:00
{
# ifdef REGAMEDLL_ADD
// useful for mods
iUser3 | = pev - > iuser3 ;
# endif
2015-09-30 03:49:22 +03:00
cd - > iuser3 = iUser3 ;
2016-06-02 01:08:22 +03:00
}
2015-09-30 03:49:22 +03:00
2016-06-14 01:13:13 +03:00
if ( pPlayer - > m_pActiveItem )
2015-09-30 03:49:22 +03:00
{
ItemInfo II ;
Q_memset ( & II , 0 , sizeof ( II ) ) ;
2016-06-14 01:13:13 +03:00
CBasePlayerWeapon * weapon = ( CBasePlayerWeapon * ) pPlayer - > m_pActiveItem - > GetWeaponPtr ( ) ;
2020-02-12 14:34:40 +03:00
if ( weapon & & weapon - > UseDecrement ( ) & &
# ifdef REGAMEDLL_API
weapon - > CSPlayerItem ( ) - > GetItemInfo ( & II )
# else
weapon - > GetItemInfo ( & II )
# endif
)
2015-09-30 03:49:22 +03:00
{
cd - > m_iId = II . iId ;
2016-07-27 17:08:42 +03:00
if ( ( unsigned int ) weapon - > m_iPrimaryAmmoType < MAX_AMMO_SLOTS )
2015-09-30 03:49:22 +03:00
{
2016-06-14 01:13:13 +03:00
cd - > vuser4 . x = weapon - > m_iPrimaryAmmoType ;
2017-10-19 20:12:02 +03:00
cd - > vuser4 . y = pPlayer - > m_rgAmmo [ weapon - > m_iPrimaryAmmoType ] ;
2015-09-30 03:49:22 +03:00
}
else
{
cd - > vuser4 . x = - 1.0 ;
cd - > vuser4 . y = 0 ;
}
}
}
}
}
2017-10-17 15:38:40 +03:00
void EXT_FUNC CmdStart ( const edict_t * pEdict , const struct usercmd_s * cmd , unsigned int random_seed )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
entvars_t * pev = const_cast < entvars_t * > ( & pEdict - > v ) ;
2016-06-14 01:13:13 +03:00
CBasePlayer * pPlayer = CBasePlayer : : Instance ( pev ) ;
2015-09-30 03:49:22 +03:00
2016-06-14 01:13:13 +03:00
if ( ! pPlayer )
return ;
2015-09-30 03:49:22 +03:00
2016-06-14 01:13:13 +03:00
if ( pPlayer - > pev - > groupinfo )
UTIL_SetGroupTrace ( pPlayer - > pev - > groupinfo , GROUP_OP_AND ) ;
pPlayer - > random_seed = random_seed ;
2015-09-30 03:49:22 +03:00
}
2017-10-17 15:38:40 +03:00
void EXT_FUNC CmdEnd ( const edict_t * pEdict )
2015-09-30 03:49:22 +03:00
{
2017-10-17 15:38:40 +03:00
entvars_t * pev = const_cast < entvars_t * > ( & pEdict - > v ) ;
2016-06-14 01:13:13 +03:00
CBasePlayer * pPlayer = CBasePlayer : : Instance ( pev ) ;
2015-09-30 03:49:22 +03:00
2016-06-14 01:13:13 +03:00
if ( ! pPlayer )
return ;
2015-09-30 03:49:22 +03:00
2016-06-14 01:13:13 +03:00
if ( pPlayer - > pev - > groupinfo )
UTIL_UnsetGroupTrace ( ) ;
if ( pev - > flags & FL_DUCKING )
UTIL_SetSize ( pev , VEC_DUCK_HULL_MIN , VEC_DUCK_HULL_MAX ) ;
2015-09-30 03:49:22 +03:00
}
2015-12-09 01:39:54 +03:00
int EXT_FUNC ConnectionlessPacket ( const struct netadr_s * net_from , const char * args , char * response_buffer , int * response_buffer_size )
2015-09-30 03:49:22 +03:00
{
// Parse stuff from args
int max_buffer_size = * response_buffer_size ;
// Zero it out since we aren't going to respond.
// If we wanted to response, we'd write data into response_buffer
* response_buffer_size = 0 ;
// Since we don't listen for anything here, just respond that it's a bogus message
// If we didn't reject the message, we'd return 1 for success instead.
return 0 ;
}
2019-04-17 13:47:52 +03:00
BOOL EXT_FUNC GetHullBounds ( int hullnumber , float * mins , float * maxs )
2015-09-30 03:49:22 +03:00
{
2019-04-17 13:47:52 +03:00
# ifdef REGAMEDLL_ADD
if ( hullbounds_sets . value = = 0.0f )
{
return ( hullnumber < 3 ) ? TRUE : FALSE ;
}
# endif
2017-07-15 18:15:39 +03:00
# ifdef REGAMEDLL_FIXES
switch ( hullnumber )
{
case 0 : // Normal player
Q_memcpy ( mins , ( float * ) VEC_HULL_MIN , sizeof ( vec3_t ) ) ;
Q_memcpy ( maxs , ( float * ) VEC_HULL_MAX , sizeof ( vec3_t ) ) ;
return TRUE ;
case 1 : // Crouched player
Q_memcpy ( mins , ( float * ) VEC_DUCK_HULL_MIN , sizeof ( vec3_t ) ) ;
Q_memcpy ( maxs , ( float * ) VEC_DUCK_HULL_MAX , sizeof ( vec3_t ) ) ;
return TRUE ;
case 2 : // Point based hull
Q_memcpy ( mins , ( float * ) Vector ( 0 , 0 , 0 ) , sizeof ( vec3_t ) ) ;
Q_memcpy ( maxs , ( float * ) Vector ( 0 , 0 , 0 ) , sizeof ( vec3_t ) ) ;
return TRUE ;
default :
return FALSE ;
}
# else // REGAMEDLL_FIXES
switch ( hullnumber )
{
case 0 : // Normal player
mins = VEC_HULL_MIN ;
maxs = VEC_HULL_MAX ;
return TRUE ;
case 1 : // Crouched player
mins = VEC_DUCK_HULL_MIN ;
maxs = VEC_DUCK_HULL_MAX ;
return TRUE ;
case 2 : // Point based hull
mins = Vector ( 0 , 0 , 0 ) ;
maxs = Vector ( 0 , 0 , 0 ) ;
return TRUE ;
default :
return FALSE ;
}
# endif // REGAMEDLL_FIXES
2015-09-30 03:49:22 +03:00
}
// Create pseudo-baselines for items that aren't placed in the map at spawn time, but which are likely
// to be created during play ( e.g., grenades, ammo packs, projectiles, corpses, etc. )
2016-02-04 03:18:26 +03:00
void EXT_FUNC CreateInstancedBaselines ( )
2015-09-30 03:49:22 +03:00
{
2016-02-23 02:13:52 +03:00
# ifndef REGAMEDLL_FIXES
2015-09-30 03:49:22 +03:00
int iret = 0 ;
entity_state_t state ;
Q_memset ( & state , 0 , sizeof ( state ) ) ;
// Create any additional baselines here for things like grendates, etc.
// iret = ENGINE_INSTANCE_BASELINE(pc->pev->classname, &state);
// Destroy objects.
// UTIL_Remove(pc);
2016-02-23 02:13:52 +03:00
# endif
2015-09-30 03:49:22 +03:00
}
2017-10-17 15:38:40 +03:00
int EXT_FUNC InconsistentFile ( const edict_t * pEdict , const char * filename , char * disconnect_message )
2015-09-30 03:49:22 +03:00
{
// Server doesn't care?
2016-12-10 21:27:53 +03:00
if ( ! CVAR_GET_FLOAT ( " mp_consistency " ) )
2015-09-30 03:49:22 +03:00
return 0 ;
// Default behavior is to kick the player
Q_sprintf ( disconnect_message , " Server is enforcing file consistency for %s \n " , filename ) ;
// Kick now with specified disconnect message.
return 1 ;
}
// The game .dll should return 1 if lag compensation should be allowed ( could also just set
// the sv_unlag cvar.
// Most games right now should return 0, until client-side weapon prediction code is written
// and tested for them ( note you can predict weapons, but not do lag compensation, too,
// if you want.
2016-02-04 03:18:26 +03:00
int EXT_FUNC AllowLagCompensation ( )
2015-09-30 03:49:22 +03:00
{
return 1 ;
}