• Derma Menu - Change another player's class by pressing a button
    6 replies, posted
This code when pressed will change the class of a player to citizen. Is there a way to use the 'v:Nick()' values to make it so when I press on a person's button it'll turn them to a citizen? Client: [lua] function MyCoolMenu() local DermaPanel = vgui.Create( "DFrame" ) DermaPanel:SetPos( 100,100 ) DermaPanel:SetSize( 500, 700 ) DermaPanel:SetTitle( "Make A Cop" ) DermaPanel:SetVisible( true ) DermaPanel:SetDraggable( true ) DermaPanel:ShowCloseButton( true ) DermaPanel:MakePopup() local DermaListView = vgui.Create("DListView") DermaListView:SetParent(DermaPanel) DermaListView:SetPos(25, 50) DermaListView:SetSize(450, 625) DermaListView:SetMultiSelect(false) DermaListView:AddColumn("Name") for k,v in pairs(player.GetAll()) do DermaListView:AddLine(v:Nick()) end DermaListView.DoDoubleClick = function(ply) net.Start("Test") net.SendToServer() end end [/lua] Server: [lua] util.AddNetworkString("Test") net.Receive( "Test", function(len,ply) ply:changeTeam(TEAM_CITIZEN) end) [/lua]
Currently the Doubleclick function sets the player that doubleclicks to citizen.
[QUOTE=whitestar;48773376]Currently the Doubleclick function sets the player that doubleclicks to citizen.[/QUOTE] Yeah, I meant I want the person who was clicked on the derma menu to be changed to citizen.
[code] -- Clientside function MyCoolMenu() local DermaPanel = vgui.Create( "DFrame" ) DermaPanel:SetPos( 100,100 ) DermaPanel:SetSize( 500, 700 ) DermaPanel:SetTitle( "Make A Cop" ) DermaPanel:SetVisible( true ) DermaPanel:SetDraggable( true ) DermaPanel:ShowCloseButton( true ) DermaPanel:MakePopup() local DermaListView = vgui.Create("DListView") DermaListView:SetParent(DermaPanel) DermaListView:SetPos(25, 50) DermaListView:SetSize(450, 625) DermaListView:SetMultiSelect(false) DermaListView:AddColumn("Name") for k,v in pairs(player.GetAll()) do local line = DermaListView:AddLine(v:Nick()) line.ply = v end function DermaListView:DoDoubleClick(lineid, line) net.Start("Test") net.WriteEntity(line.ply) net.SendToServer() end end -- Serverside util.AddNetworkString("Test") net.Receive("Test",function(len, ply) local target = net.ReadEntity() target:changeTeam(TEAM_CITIZEN, true) end) [/code] Don't know if DarkRPs code is intelligent enough to convert its variable to the team number, since I dont know the number of TEAM_CITIZEN. Sure the code is exploitable, but Idunno how to secure it better, since I am bad in the netlib :p
[QUOTE=whitestar;48773869][code] -- Clientside function MyCoolMenu() local DermaPanel = vgui.Create( "DFrame" ) DermaPanel:SetPos( 100,100 ) DermaPanel:SetSize( 500, 700 ) DermaPanel:SetTitle( "Make A Cop" ) DermaPanel:SetVisible( true ) DermaPanel:SetDraggable( true ) DermaPanel:ShowCloseButton( true ) DermaPanel:MakePopup() local DermaListView = vgui.Create("DListView") DermaListView:SetParent(DermaPanel) DermaListView:SetPos(25, 50) DermaListView:SetSize(450, 625) DermaListView:SetMultiSelect(false) DermaListView:AddColumn("Name") for k,v in pairs(player.GetAll()) do local line = DermaListView:AddLine(v:Nick()) line.ply = v end function DermaListView:DoDoubleClick(lineid, line) net.Start("Test") net.WriteEntity(line.ply) net.SendToServer() end end -- Serverside util.AddNetworkString("Test") net.Receive("Test",function(len, ply) local target = net.ReadEntity() target:changeTeam(TEAM_CITIZEN, true) end) [/code] Don't know if DarkRPs code is intelligent enough to convert its variable to the team number, since I dont know the number of TEAM_CITIZEN. Sure the code is exploitable, but Idunno how to secure it better, since I am bad in the netlib :p[/QUOTE] alright, it works thanks. Do you mind telling me what it means exactly though?
your netmessage didn't send the clicked lines player, also you didnt assign the line an player, I changed those, and serverside it reads the player entity, and uses th darkrp "PLAYER:changeTeam()" function, to set the assigned job, and forces to bypass any restrictions, aka vote or anything.
[QUOTE=whitestar;48774664]your netmessage didn't send the clicked lines player, also you didnt assign the line an player, I changed those, and serverside it reads the player entity, and uses th darkrp "PLAYER:changeTeam()" function, to set the assigned job, and forces to bypass any restrictions, aka vote or anything.[/QUOTE] alright, makes sense. Thank you!
Sorry, you need to Log In to post a reply to this thread.