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

Method OnClientConnect

core/PlayerManager.cpp:495–576  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

493}
494
495bool PlayerManager::OnClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen)
496{
497 int client = IndexOfEdict(pEntity);
498 CPlayer *pPlayer = &m_Players[client];
499 ++m_PlayersSinceActive;
500
501 if (pPlayer->IsConnected())
502 {
503 if (sm_debug_connect.GetBool())
504 {
505 const char *pAuth = pPlayer->GetAuthString(false);
506 if (pAuth == NULL)
507 {
508 pAuth = "";
509 }
510
511 logger->LogMessage("\"%s<%d><%s><>\" was already connected to the server.", pPlayer->GetName(), pPlayer->GetUserId(), pAuth);
512 }
513
514 OnClientDisconnect(pPlayer->GetEdict());
515 OnClientDisconnect_Post(pPlayer->GetEdict());
516 }
517
518 pPlayer->Initialize(pszName, pszAddress, pEntity);
519
520 /* Get the client's language */
521 if (m_QueryLang)
522 {
523#if SOURCE_ENGINE == SE_CSGO || SOURCE_ENGINE == SE_BLADE || SOURCE_ENGINE == SE_MCV
524 pPlayer->m_LangId = translator->GetServerLanguage();
525#else
526 const char *name;
527 if (!pPlayer->IsFakeClient() && (name=engine->GetClientConVarValue(client, "cl_language")))
528 {
529 unsigned int langid;
530 pPlayer->m_LangId = (translator->GetLanguageByName(name, &langid)) ? langid : translator->GetServerLanguage();
531
532 OnClientLanguageChanged(client, pPlayer->m_LangId);
533 } else {
534 pPlayer->m_LangId = translator->GetServerLanguage();
535 }
536#endif
537 pPlayer->m_OriginalLangId = pPlayer->m_LangId;
538 }
539
540 List<IClientListener *>::iterator iter;
541 IClientListener *pListener = NULL;
542 for (iter=m_hooks.begin(); iter!=m_hooks.end(); iter++)
543 {
544 pListener = (*iter);
545 if (!pListener->InterceptClientConnect(client, reject, maxrejectlen))
546 {
547 RETURN_META_VALUE(MRES_SUPERCEDE, false);
548 }
549 }
550
551 cell_t res = 1;
552

Callers

nothing calls this directly

Calls 15

IndexOfEdictFunction · 0.85
IsConnectedMethod · 0.80
GetBoolMethod · 0.80
GetAuthStringMethod · 0.80
GetUserIdMethod · 0.80
GetEdictMethod · 0.80
GetServerLanguageMethod · 0.80
IsFakeClientMethod · 0.80
GetClientConVarValueMethod · 0.80
GetLanguageByNameMethod · 0.80
PushCellMethod · 0.80
PushStringExMethod · 0.80

Tested by

no test coverage detected