Skip to content

Commit

Permalink
add helper to find player by steamid64
Browse files Browse the repository at this point in the history
  • Loading branch information
wootguy committed Dec 21, 2024
1 parent dd92571 commit 7392727
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions dlls/util/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,18 @@ CBasePlayer* UTIL_PlayerBySteamId(const char* id) {
return NULL;
}

CBasePlayer* UTIL_PlayerBySteamId64(uint64_t id) {
for (int i = 1; i <= gpGlobals->maxClients; i++) {
CBasePlayer* pPlayer = UTIL_PlayerByIndex(i);

if (pPlayer && id == pPlayer->GetSteamID64()) {
return pPlayer;
}
}

return NULL;
}

edict_t* UTIL_ClientsInPVS(edict_t* edict, int& playerCount) {
// TODO: reimplement engine func so that it only iterates 32 edicts
edict_t* pvsents = UTIL_EntitiesInPVS(edict);
Expand Down
1 change: 1 addition & 0 deletions dlls/util/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ EXPORT CBaseEntity *UTIL_FindEntityGeneric(const char *szName, Vector &vecSrc, f
EXPORT extern CBasePlayer *UTIL_PlayerByIndex( int playerIndex );
EXPORT extern CBasePlayer *UTIL_PlayerByUserId( int userid );
EXPORT extern CBasePlayer *UTIL_PlayerBySteamId(const char* id);
EXPORT extern CBasePlayer *UTIL_PlayerBySteamId64(uint64_t id);

#define UTIL_EntitiesInPVS(pent) (*g_engfuncs.pfnEntitiesInPVS)(pent)
EXPORT edict_t* UTIL_ClientsInPVS(edict_t* edict, int& playerCount);
Expand Down

0 comments on commit 7392727

Please sign in to comment.