I've made a derma panel based around the use of console commands;
The panel uses commands like "kill" or "explode" (Just examples) ~
The problem is that the console commands can be done without the panel being open,
is there anyway I can disallow the console command from being used unless the panel is open?
It's quite essential, as without it, the panel itself is pointless.
I am quite certain this has been answered before, but I can't find it (I'm useless, I know).
Thanks.
-snip-
posted code below vvv
[QUOTE=Richtofen;47101244]This might not be what your looking for
but I believe you should be able to create a concommand when the panel is created.
[lua]
local PANEL={}
function PANEL:Init()
self:SetSize(200,200)
self:Center()
self:MakePopup()
concommand.Add( "commandname", function( ply, cmd, args, str )
print( ply:Nick(), cmd )
PrintTable( args )
end )
end
vgui.Register("pnlCOMMAND",PANEL,"DPanel")
[/lua]
please correct me if i'm wrong.
edit: works, but I think you might be talking about allowing the command to ONLY run when this panel is open. This just creates the concommand when the panel is created, which means when it closes it will still run the command.[/QUOTE]
That not what I was looking for, it's my fault I didn't make the OP detailed enough. Anyway, thank you for the reply!
[QUOTE=CoachConners;47101291]That not what I was looking for, it's my fault I didn't make the OP detailed enough. Anyway, thank you for the reply![/QUOTE]
This will work perfect for what you need, assuming i'm correct in thinking you only want the command to run while the panel is being displayed/created on the screen.
[lua]
local PANEL={}
function PANEL:Init()
self:SetSize(200,200)
self:Center()
self:MakePopup()
concommand.Add('test', function(ply,cmd,args,str)
print(ply:Nick(), cmd)
end)
end
function PANEL:OnRemove()
concommand.Remove('test')
end
vgui.Register("pnlCommand",PANEL,"DPanel")
[/lua]
Sorry, you need to Log In to post a reply to this thread.