Listing players in a nearby radius in a drop down box in Vgui Frame
7 replies, posted
Hey
So yea, I am working with vgui at the moment (a bit out of my comfort zone, but eh) and I was wondering if their is a way of listing all players nearby by using DScrollPanel or something similar.
I am using an entity to open the menu, and I want to list player around the entity.
Thanks
-Tom
[editline]5th May 2016[/editline]
Bump
Loop through all players and calculate the distance from the player to the entity. If the player is within a threshold distance, then add them to a table you should have previously created that should contain only players. After the loop is done, loop through the table of players within bounds, and create an element for each corresponding player.
Alternatively, don't store the players in the table, simply ignore the current loop iteration if the player is out of bounds.
Here's what I did for my esp in my clientside "hacks." This should work the same.
[CODE]
local Distance = 4000
for k,v in pairs(player.GetAll()) do
if ply:GetPos():Distance(v:GetPos()) <= Distance then
--code code code
[/CODE]
Sadly I don't know how to do anything else you asked except check if players are within a certain distance.
[QUOTE=dannyf127;50258606]Here's what I did for my esp in my clientside "hacks." This should work the same.
[CODE]
local Distance = 4000
for k,v in pairs(player.GetAll()) do
if ply:GetPos():Distance(v:GetPos()) <= Distance then
--code code code
[/CODE]
Sadly I don't know how to do anything else you asked except check if players are within a certain distance.[/QUOTE]
Thank you, will try this, and will let you know if it works
Ok, so does anyone know how I would list them into a combo box, help is really appreciated.
[CODE]local Distance = 4000
for k,v in pairs(player.GetAll()) do
if ply:GetPos():Distance(v:GetPos()) <= Distance then
--code code code
[/CODE]
There is a example on the wiki: [url]https://wiki.garrysmod.com/page/Category:DComboBox[/url]
also this: [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/DComboBox/AddChoice]DComboBox:AddChoice[/url]
[QUOTE=Invule;50261801]There is a example on the wiki: [url]https://wiki.garrysmod.com/page/Category:DComboBox[/url]
also this: [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/DComboBox/AddChoice]DComboBox:AddChoice[/url][/QUOTE]
Ok, that's all good, but do you know how I could use the list from the radius into the choices.
Like I want to use DComboBox:AddChoice and then list all of the players from this code:
[CODE]local Distance = 4000
for k,v in pairs(player.GetAll()) do
if ply:GetPos():Distance(v:GetPos()) <= Distance then
--code code code
[/CODE]
draw your vgui shit then in the code that was given to you, you addchoice(v:Nick()) or something
Sorry, you need to Log In to post a reply to this thread.