I want to make a simple Derma Panel that opens up, allowing me to select a player then press a button and it will kill them. However I am getting the following error:
attempt to index local 'frame' (a nil value)
Client:
function DrawGUI()
local frame = vgui.Create("DFrame")
frame:SetSize(200, 200)
frame:Center()
frame:MakePopup()
local playerbox = vgui.Create("DComboBox", frame)
playerbox:SetPos(45, 75)
playerbox:SetSize(120, 20)
playerbox:SetText("Choose a Player")
for k, v in pairs( player.GetAll() ) do
playerbox:AddChoice( tostring( v:Nick() ) )
end
local killbutton = vgui.Create("DButton", frame)
killbutton:SetSize(120, 20)
killbutton:SetPos(45, 95)
killbutton:SetText("Kill")
killbutton.DoClick = function()
net.Start("KillSelectedPlayer")
net.WriteString(playerbox:GetSelected())
net.SendToServer()
end
return frame
end
net.Receive( "test_opengui", DrawGUI)
Server:
AddCSLuaFile("autorun/client/cl_test.lua")
util.AddNetworkString( "test_opengui" )
util.AddNetworkString("KillSelectedPlayer")
function ChatCommand( ply, txt, pub )
if string.sub( string.lower( txt ), 1, 5 ) == "!test" then
net.Start( "test_opengui" )
net.Send( ply )
return ""
end
end
hook.Add("PlayerSay" , "ChatCommand", ChatCommand)
net.Receive( "KillSelectedPlayer", function( len, ply )
local targetply = net.ReadString()
if targetply == IsPlayer() then
targetply:Kill()
end
end
Sorry, you need to Log In to post a reply to this thread.