player.GetByID

From GMod Wiki

Jump to: navigation, search
Function
Syntax player.GetByID( id )
Where is this used?
Description:
Retrieve a player object based upon his entity index
Returns: Player object.
Part of Library: Player
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Player.GetByID]Player.GetByID [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionThis example prints out the first player's name
Used onNewerShared.png
Code
local player_1 = player.GetByID(1)
Msg( player_1:Nick() .. "\n")
 
OutputN/A


DescriptionIf you want to print a table of the users by their id, do;
Used onNewerShared.png
Code
for _,v in pairs ( player.GetAll() ) do
print( v:Nick().." = "..v:EntIndex() )
end
 
 
OutputPrint's a table that looks like this;
 
name1 = 1
name2 = 2
name3 = 3
etc...
 


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox