MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / OnClientPutInServer

Method OnClientPutInServer

core/PlayerManager.cpp:617–769  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

615}
616
617void PlayerManager::OnClientPutInServer(edict_t *pEntity, const char *playername)
618{
619 cell_t res;
620 int client = IndexOfEdict(pEntity);
621 CPlayer *pPlayer = &m_Players[client];
622
623 /* If they're not connected, they're a bot */
624 if (!pPlayer->IsConnected())
625 {
626 /* Run manual connection routines */
627 char error[255];
628
629 pPlayer->m_bFakeClient = true;
630
631 /*
632 * While we're already filtered to just bots, we'll do other checks to
633 * make sure that the requisite services are enabled and that the bots
634 * have joined at the expected time.
635 *
636 * Checking playerinfo's IsHLTV and IsReplay would be better and less
637 * error-prone but will always show false until later in the frame,
638 * after PutInServer and Activate, and we want it now!
639 *
640 * These checks are hairy as hell due to differences between engines and games.
641 *
642 * Most engines use "Replay" and "SourceTV" as bot names for these when they're
643 * created. EP2V, CSS and Nuclear Dawn (but not L4D2) differ from this by now using
644 * replay_/tv_name directly when creating the bot(s). To complicate it slightly
645 * further, the cvar can be empty and the engine's fallback to "unnamed" will be used.
646 * We can maybe just rip out the name checks at some point and rely solely on whether
647 * they're enabled and the join order.
648 */
649
650 // This doesn't actually get incremented until OnClientConnect. Fake it to check.
651 int newCount = m_PlayersSinceActive + 1;
652
653 int userId = engine->GetPlayerUserId(pEntity);
654#if (SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_TF2 || SOURCE_ENGINE == SE_SDK2013 \
655 || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_NUCLEARDAWN || SOURCE_ENGINE == SE_PVKII)
656 static ConVar *tv_name = icvar->FindVar("tv_name");
657#endif
658#if SOURCE_ENGINE == SE_TF2
659 static ConVar *replay_name = icvar->FindVar("replay_name");
660#endif
661
662#if SOURCE_ENGINE == SE_TF2
663 if (m_bIsReplayActive && newCount == 1
664 && (m_ReplayUserId == userId
665 || (replay_name && strcmp(playername, replay_name->GetString()) == 0) || (replay_name && replay_name->GetString()[0] == 0 && strcmp(playername, "unnamed") == 0)
666 )
667 )
668 {
669 pPlayer->m_bIsReplay = true;
670 m_ReplayUserId = userId;
671 }
672#endif
673
674 if (m_bIsSourceTVActive

Callers

nothing calls this directly

Calls 15

IndexOfEdictFunction · 0.85
IsConnectedMethod · 0.80
PushCellMethod · 0.80
AuthorizeMethod · 0.80
GetSteam2IdMethod · 0.80
GetFunctionCountMethod · 0.80
PushStringMethod · 0.80
Authorize_PostMethod · 0.80
GetPlayerInfoMethod · 0.80
IsAuthorizedMethod · 0.80
GetStringMethod · 0.45

Tested by

no test coverage detected