🆔User ID - Source
Getting the User (static) ID
The following code is a server-side script that demonstrates a simple way to retrieve a player's static User ID using the infCore
framework.
Trying to get the id of a offline user would return the value -1.
-- Create a shorter alias for the infCore export for readability
local infCore = exports.infCore
-- Register a server-side command "getMyId"
RegisterCommand("getMyId", function ()
local source = source -- The player who triggered the command
local user_id = infCore:getUserId(source) -- Fetch the static User ID
print(user_id) -- Output the ID to the server console
end)
Getting the user source for the User ID
The following code is a server-side script that demonstrates a simple way to retrieve a player's source from the user id using the infCore
framework.
Trying to get the source of a offline user would return the value "-1".
-- Create a shorter alias for the infCore export for readability
local infCore = exports.infCore
-- Register a server-side command "getSource"
RegisterCommand("getSource", function(source, args, rawCommand)
local source = infCore:getUserSource(user_id) -- Get the player's source
print(source)
end)
Last updated