• DListView Problems
    6 replies, posted
[code] function adminmenu() local stuffs = vgui.Create("DFrame") stuffs:SetSize(400,300) stuffs:SetTitle("Admin Menu") stuffs:SetVisible(true) stuffs:SetDraggable(false) stuffs:ShowCloseButton(true) stuffs:Center() stuffs:MakePopup() local listything = vgui.Create("DListView",stuffs) listything:SetPos(10,35) listything:SetSize(stuffs:GetWide()-20,stuffs:GetTall()-45) listything:SetMultiSelect(false) listything:AddColumn("Player") for k,v in pairs(player.GetAll()) do listything:AddLine(v:Nick()) end listything.OnClickLine = function() local listyoptions = DermaMenu() listyoptions:AddOption("Kick", function() LocalPlayer():ConCommand("Kick "..listything:GetLine()) end) listyoptions:AddOption("Ban", function() LocalPlayer():ConCommand("Ban "..listything:GetValue(listything:GetSelectedLine())) end) listyoptions:Open() end end concommand.Add("AdminMenu",adminmenu)[/code] Using the line: [code]listyoptions:AddOption("Kick", function() LocalPlayer():ConCommand("Kick "..listything:GetLine()) end)[/code] I've tried many ways, but I'm trying to get the value, in this case, the players name, when you click on the line it'll open a cheaky menu. This'll allow you to click either option (ban and kick). Either will run a concommand and kick the player. The listything seems to be a bit "sketchy" and I can't seem to get it to work with anything. I've tried: [code] :GetValue() :GetLine() :GetSelected() [/code] Some current errors are (I'll edit when I try a few more): [code] [DeathMatch\gamemode\Client\cl_admin.lua:31] attempt to concatenate a nil value [/code] None of them seem to work, any help will be appreciated, cheers.
Didn't I help you with this earlier?
Does the "Ban" command work?
I didn't test the ban function, but the kick function works. [lua]function adminmenu() local stuffs = vgui.Create( "DFrame" ) stuffs:SetSize( 400, 300 ) stuffs:SetTitle( "Admin Menu" ) stuffs:SetVisible( true ) stuffs:SetDraggable( false ) stuffs:ShowCloseButton( true ) stuffs:Center() stuffs:MakePopup() local listything = vgui.Create( "DListView", stuffs ) listything:SetPos( 10, 35 ) listything:SetSize( stuffs:GetWide() - 20, stuffs:GetTall() - 45 ) listything:SetMultiSelect( false ) listything:AddColumn( "Player" ) listything:AddColumn( "Steam ID" ) for k, v in pairs(player.GetAll()) do listything:AddLine( v:Nick(), v:SteamID() ) end listything.OnClickLine = function( parent, line, bSelected ) local listyoptions = DermaMenu() listyoptions:AddOption( "Kick", function() RunConsoleCommand( "kick", line:GetValue(1) ) end ) listyoptions:AddOption( "Ban", function() RunConsoleCommand( "banid", 1, line:GetValue(2), "Ban reason goes here." ) end ) listyoptions:Open() end end concommand.Add( "AdminMenu", adminmenu )[/lua]
[QUOTE=samm5506;28355869]I didn't test the ban function, but the kick function works. [codestuffs][/QUOTE] Thanks, but the banid requires ID (use id or steam id) to my knowledge. I have an idea of getting around this...
[QUOTE=vipersoul;28364125]Thanks, but the banid requires ID (use id or steam id) to my knowledge. I have an idea of getting around this...[/QUOTE] Did you even look at what I added? [lua] listything:AddColumn( "Player" ) listything:AddColumn( "Steam ID" ) for k, v in pairs(player.GetAll()) do listything:AddLine( v:Nick(), v:SteamID() ) end listyoptions:AddOption( "Ban", function() RunConsoleCommand( "banid", 1, line:GetValue(2), "Ban reason goes here." ) end )[/lua]
[QUOTE=samm5506;28364857]Did you even look at what I added? [lua] listything:AddColumn( "Player" ) listything:AddColumn( "Steam ID" ) for k, v in pairs(player.GetAll()) do listything:AddLine( v:Nick(), v:SteamID() ) end listyoptions:AddOption( "Ban", function() RunConsoleCommand( "banid", 1, line:GetValue(2), "Ban reason goes here." ) end )[/lua][/QUOTE] Oh sorry, I just looked at the line I needed. Didn't notice that. I have a tendency to do things like that. Thanks. :)
Sorry, you need to Log In to post a reply to this thread.