who could explain to me where to place them tells me how to make them work
------------------------------------
DListView/OnRowRightClick
-----------
RunConsoleCommand
--------------
DListView/OnRowSelected
So you want it to change gravity of the player you right click on?
this is for example
Try this:
local frame = vgui.Create("DFrame") --Frame keeping the list
frame:SetSize(300,300)
frame:Center()
frame:SetTitle("Gravity")
frame:SetDraggable(true)
frame:MakePopup()
local plist = vgui.Create("DListView" , frame) --Parents the DListView to the frame so when dragged it will stay with frame
plist:Dock( FILL )
plist:SetMultiSelect(false)
plist:AddColumn("Player")
plist:AddColumn("SteamID")
for k , v in pairs(player.GetAll()) do
plist:AddLine( v:Nick() , v:SteamID() )
end --Creates a loop that will list every players name and steamid
plist.OnRowSelected = function( panel , line )
print(plist:GetLine(line):GetValue(1)) --Prints name of player you click (testing if it works)
end local
button = vgui.Create("DButton" , frame)
button:SetSize ( 200 , 40 )
button:Center()
button:SetText ( "Set Gravity" )
button.DoClick = function ()
--Put anything you want to run as a script here(After DoClick)
( "sv_gravity", "400" )
end
Thank you guy really question I tried to find a site to help me in Glua will you have a site has me advice?
Garry's Mod Wiki is good
Maurits has some well structured code to learn from (A lot of it is outdated though)
and <CODE BLUE> Does some good youtube tutorials if you want to check him out.
[ERROR] lua/testl.lua:24: ')' expected near ','
1. unknown - lua/testl.lua:0
whenever you put in code it miss-places some things, you're going to have to put a space between "endlocal"
to add on to the previous response, Section rules and resources contains some other helpful glua stuff as well as lua stuff in general
local frame = vgui.Create("DFrame") --Frame keeping the list
frame:SetSize(300,300)
frame:Center()
frame:SetTitle("Gravity")
frame:SetDraggable(true)
frame:MakePopup()
local plist = vgui.Create("DListView" , frame) --Parents the DListView to the frame so when dragged it will stay with frame
plist:Dock( FILL )
plist:SetMultiSelect(false)
plist:AddColumn("Player")
plist:AddColumn("SteamID")
for k , v in pairs( player.GetAll () ) do
plist:AddLine( v:Nick() , v:SteamID() )
end--Creates a loop that will list every players name and steamid
plist.OnRowSelected = function( panel , line )print(plist:GetLine(line):GetValue(1)) --Prints name of player you click (testing if it works) endlocal
button = vgui.Create("DButton" , frame)
button:SetSize ( 200 , 40 )
button:Center()
button:SetText ( "Set Gravity" )
button.DoClick = function ()--Put anything you want to run as a script here(After DoClick)
( "sv_gravity", "400" )
end
Yeah, put aa space between "endlocal" so it is "end local"
"plist.OnRowSelected = function( panel , line )print(plist:GetLine(line):GetValue(1)) --Prints name of player you click (testing if it works) end
local button = vgui.Create("DButton" , frame)"
like this.
local Window = vgui.Create("DFrame")
Window:SetSize(300,300)
Window:Center()
Window:SetTitle("Gravity")
Window:SetDraggable(true)
Window:MakePopup()
local list = vgui.Create("DListView" , Window)
list:Dock( FILL )
list:SetMultiSelect(false)
list:AddColumn("Player")
list:AddColumn("SteamID")
for k , v in pairs(player.GetAll()) do
list:AddLine( v:Nick() , v:SteamID() )
end
list.OnRowSelected = function( panel , line )print(list:GetLine(line):GetValue(1))
end local
button = vgui.Create("DButton" , Window)
button:SetSize ( 200 , 40 )
button:Center()
button:SetText ( "Set Gravity" )
button.DoClick = function ()
( "sv_gravity", "400" )
Sorry, you need to Log In to post a reply to this thread.