• protecting console commands
    6 replies, posted
how would I protect a console command from being used by a player, but still letting a gamemode use it?
[lua]function hello(ply, cmd, args) if ply:IsValid() then return end // code here end concommand.Add("hello", hello)[/lua]
I think he wants the gamemode to run the command on the client though
[QUOTE=Willox;23098327]I think he wants the gamemode to run the command on the client though[/QUOTE] yes, I want it to be used on the client.
[QUOTE=Carmine3777;23111953]yes, I want it to be used on the client.[/QUOTE] In the /server/ file put [lua] function test(ply,cmd,args) if args[1] == nil then ply:ChatPrint("Must contain arguements") return end if ply:IsAdmin() or not ValidEntity(ply) then -- if we're admin or console then continue PrintMessage(HUD_PRINTTALK, args[1]) end end concommand.Add("AdminMessage", test) [/lua]
Use [url]http://wiki.garrysmod.com/?title=Umsg[/url] or [url]http://wiki.garrysmod.com/?title=Datastream[/url] instead of the command.
[QUOTE=yoBrelliKX;23150555]Use [url]http://wiki.garrysmod.com/?title=Umsg[/url] or [url]http://wiki.garrysmod.com/?title=Datastream[/url] instead of the command.[/QUOTE] concommand.Add does the same as that but if you want to protect it use if ply:IsAdmin() then protected end in the server file, it's not like they're gonna magically know what console command you put in the server side anyway.
Sorry, you need to Log In to post a reply to this thread.