From 7392727427fd1993ffe683c40b4368e8863e6a1e Mon Sep 17 00:00:00 2001 From: wootguy Date: Fri, 20 Dec 2024 20:24:47 -0800 Subject: [PATCH] add helper to find player by steamid64 --- dlls/util/util.cpp | 12 ++++++++++++ dlls/util/util.h | 1 + 2 files changed, 13 insertions(+) diff --git a/dlls/util/util.cpp b/dlls/util/util.cpp index 51aadfc6..4ed51cdc 100644 --- a/dlls/util/util.cpp +++ b/dlls/util/util.cpp @@ -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); diff --git a/dlls/util/util.h b/dlls/util/util.h index 6dad60df..9216a0b2 100644 --- a/dlls/util/util.h +++ b/dlls/util/util.h @@ -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);