Skip to content

Commit

Permalink
Adds ix.util.GetUserByCharacterID
Browse files Browse the repository at this point in the history
  • Loading branch information
bleonheart authored Oct 9, 2024
1 parent 7926b72 commit 04b4fb5
Showing 1 changed file with 19 additions and 1 deletion.
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

0 comments on commit 04b4fb5

Please sign in to comment.