making a command that runs other commands

is there a way to make a command that runs other commands when used. if not how do people make game modes in ttt such as tdm and free for all.

Can you give us a better explanation about what you want please?

well im thing of making a command that will run the commands that increase amount of traitors and decreases amounts of innos and dects for like a minigame in ttt

Are they ulx commands, chat commands, console commands…?

ulx

[editline]5th July 2015[/editline]

and console

Why you aren’t use a config file ?

example:
alias mysupermegacommand “ttt_detective_max 10;ttt_traitor_max 100”

i want to be able to turn it off and on at any time




local on = false 
concommand.Add("command", function()
   if !on then
     on = true
     RunConsoleCommand("ttt_detective_max", "10")
     RunConsolecommand("ttt_traitor_max", "100")
   else
     on = false
     RunConsoleCommand("ttt_detective_max", "turn off value")
     RunConsoleCommand("ttt_traitor_max", "turn off value")
   end
end )


Or just make a config file in your cfg folder. Then from Console you can just type “exec minigames” which then will exec the minigames.cfg you have created.

Could be a good method, but its better doing it so that a admin player types in chat a command and it execs some commands via server console.
For example:
Serverside


hook.Add("PlayerSay", "TestCommand", function(ply, text)
     if text == "!COMMAND" and ply:IsAdmin() then
          RunConsoleCommand("COMMANDS")
          RunConsoleCommand("MORE COMMANDS", "ARGS")
          return false --If you want to hide the command
     end
end)

This is the easy way, but asswell, you can do it a ULX command or simply a console command

ok im new to all this so what do i do with those lines of codes

Place it inside a .lua file and then place it in a folder called server.
Then place server folder inside autorun, and that inside lua.
To complete, place lua folder inside another folder called whatever you want and place that into addons folder. :words:

and to run


local on = false 
concommand.Add("command", function()
   if !on then
     on = true
     RunConsoleCommand("ttt_detective_max", "10")
     RunConsolecommand("ttt_traitor_max", "100")
   else
     on = false
     RunConsoleCommand("ttt_detective_max", "turn off value")
     RunConsoleCommand("ttt_traitor_max", "turn off value")
   end
end )

what would i do to run it in game

Type command in your console.

Also if you want the command to change, you should change command the first line (


concommand.Add("command", function()

) by the command you’d like to, as for example, turn_on, that on it, it would change from this:


local on = false 
concommand.Add("command", function()
   if !on then
     on = true
     RunConsoleCommand("ttt_detective_max", "10")
     RunConsolecommand("ttt_traitor_max", "100")
   else
     on = false
     RunConsoleCommand("ttt_detective_max", "turn off value")
     RunConsoleCommand("ttt_traitor_max", "turn off value")
   end
end )

to this:


local on = false 
concommand.Add("turn_on", function()
   if !on then
     on = true
     RunConsoleCommand("ttt_detective_max", "10")
     RunConsolecommand("ttt_traitor_max", "100")
   else
     on = false
     RunConsoleCommand("ttt_detective_max", "turn off value")
     RunConsoleCommand("ttt_traitor_max", "turn off value")
   end
end )

Also, where it has to go, to be clearly is on:
garrysmod’s server folder/lua/autorun/server
and it should be SOMETHING.lua