Hey
So i am experimenting with VGUI and I want to know how to list all players into a DForm:ComboBox
Thanks
-Tom
Sort by their name?
[CODE]
local DComboBox, label = DForm:ComboBox( 'sometitle', 'someconvar' )
for k,v in pairs( player.GetHumans() ) do
DComboBox:AddChoice( v:Nick() )
end
[/CODE]
[editline]7th May 2016[/editline]
Wait, you didn't say you wanted the names sorted... fixed the code so it won't sort (unless you wanted that)
[QUOTE=MPan1;50272423]Sort by their name?
[CODE]
for k,v in SortedPairsByValue( player.GetAll() ) do
DComboBox:AddChoice( v:GetName() )
end
[/CODE]
[editline]7th May 2016[/editline]
Not sure if that'd work, but worth a shot (thank god gmod has pair-sorting functions like that or it'd be way harder)[/QUOTE]
Thanks, will try this out
[editline]7th May 2016[/editline]
Sorry to be a pain, but does anyone know how to assign a player a number, iesetting them to 1 and then running a functio later saying if they = 1 do an action?
Sorry, you need to Log In to post a reply to this thread.