Skip to content

[ALL] Add new UTIL_GetNearestPlayer() function#1842

Open
YourSourceBoiii wants to merge 2 commits intoValveSoftware:masterfrom
YourSourceBoiii:getnearestplayer
Open

[ALL] Add new UTIL_GetNearestPlayer() function#1842
YourSourceBoiii wants to merge 2 commits intoValveSoftware:masterfrom
YourSourceBoiii:getnearestplayer

Conversation

@YourSourceBoiii
Copy link
Copy Markdown

@YourSourceBoiii YourSourceBoiii commented Mar 15, 2026

UTIL_GetLocalPlayer is a function that's used extensively in the Source SDK 2013 code base. Unfortunately, it always returns null in Multiplayer, which ends up breaking many things, namely NPCs in Half Life 2 Deathmatch and Half Life Deathmatch Source.

Having a function UTIL_GetNearestPlayer that can just return the player which is nearest to any given entity would allow us to push community fixes for many broken NPCs in HL2DM and HLDMS. Furthermore, it could be useful in the TF2 code too and open up possibilities for many new community made features and fixes

(For clarification: I took this code from the Valve developer community at https://developer.valvesoftware.com/wiki/GetLocalPlayer, not my original work but it's royalty free to use according to the VDC license and it still fully conforms to the legal terms in this repo's contributing file.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant