• Send Player Back To Server
    4 replies, posted
On the client-side, if you list players in a DListView window... [CODE] local PlayerList = vgui.Create( "DListView", PlayerListContainer ) PlayerList:SetMultiSelect( false ) PlayerList:AddColumn( "Player Name") for k, v in pairs(player.GetAll()) do PlayerList:AddLine( v:Nick() ) end [/CODE] What's the best ( most efficient ) way to send the selected player back to the server? Or multiple players?
[QUOTE=Semajnad;49514174]On the client-side, if you list players in a DListView window... [CODE] local PlayerList = vgui.Create( "DListView", PlayerListContainer ) PlayerList:SetMultiSelect( false ) PlayerList:AddColumn( "Player Name") for k, v in pairs(player.GetAll()) do PlayerList:AddLine( v:Nick() ) end [/CODE] What's the best ( most efficient ) way to send the selected player back to the server? Or multiple players?[/QUOTE] net.WriteEntity
[QUOTE=Ylsid;49514247]net.WriteEntity[/QUOTE] So it's not more effecient to send back an I'd and get the player on serverside? If sending the entity to the server, how do you store the player object in each row so you can access it again when the players made their choice?
[QUOTE=Ylsid;49514247]net.WriteEntity[/QUOTE] net.WriteEntity won't help you with a nickname. [CODE]local PlayerList = vgui.Create( "DListView", PlayerListContainer ) PlayerList:SetMultiSelect( false ) PlayerList:AddColumn( "Player Name") for k, v in pairs(player.GetAll()) do local new_line = PlayerList:AddLine( v:Nick() ) new_line.SteamID = v:SteamID() --// you can save variables in derma elements like they are tables end --// when sending net.Start("whatever") net.WriteEntity(player.GetBySteamID(line.SteamID)) --// or net.WriteString(line.SteamID) --// then do stuff on server net.SendToServer()[/CODE]
[QUOTE=BillyOnWiiU;49514331]net.WriteEntity won't help you with a nickname. [CODE]local PlayerList = vgui.Create( "DListView", PlayerListContainer ) PlayerList:SetMultiSelect( false ) PlayerList:AddColumn( "Player Name") for k, v in pairs(player.GetAll()) do local new_line = PlayerList:AddLine( v:Nick() ) new_line.SteamID = v:SteamID() --// you can save variables in derma elements like they are tables end --// when sending net.Start("whatever") net.WriteEntity(player.GetBySteamID(line.SteamID)) --// or net.WriteString(line.SteamID) --// then do stuff on server net.SendToServer()[/CODE][/QUOTE] Thank you, I should have known this. Thanks a lot.
Sorry, you need to Log In to post a reply to this thread.