Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds ix.util.GetUserByCharacterID #453

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion gamemode/core/sh_util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,25 @@ do
return iterator, player.GetAll()
end
end

--- Retrieves the client associated with a character by their character ID.
-- @realm shared
-- @tparam number ID The ID of the character to find the associated client
-- @treturn player|nil The client associated with the character, or `nil` if no client is found
-- @usage
-- local client = ix.util.GetUserByCharacterID(123)
-- if IsValid(client) then
-- print(client:Nick() .. " is the player associated with the character ID.")
-- else
-- print("No client found for that character ID.")
-- end
function ix.util.GetUserByCharacterID(ID)
ID = tonumber(ID)
for client, character in ix.util.GetCharacters() do
if not character then continue end
if character:GetID() == ID then return client end
end
return nil
end
if (CLIENT) then
local blur = ix.util.GetMaterial("pp/blurscreen")
local surface = surface
Expand Down
Loading