ConCommands
![]() | Article about concommands. |
![]() | Dim1xs |
![]() | September 28th 2023 |
This article will learn you, how to create/remove lua ConCommands.
The beginning
ConCommand is executing to the game automatically,
if the script is located in '../lua/autorun' , or the function is runned via/from SWEP/ENTITY.
if the script is located in '../lua/autorun' , or the function is runned via/from SWEP/ENTITY.
concommand.Add
For adding ConCommand you can use this function:concommand.Add("ConsoleCommand", FunctionName)There are two different ways to use this, above is the first. Here the second way:
concommand.Add("ConsoleCommand", function() print("ConCommand is Working!") end)function() is supporting arguments:
concommand.Add("ConsoleCommand", function(ply, cmd, arg) print("ConCommand is Working!") if arg ~= nil then print(ply:GetPlayerName().." executed command: "..cmd.." with "..arg.." as argument. ") end end)
Output:
ConCommand is Working! Dim1xs executed command: ConsoleCommand with 1 as argument.
concommand.Remove
Sometimes, you might want to remove a console command. It's going to be very simple, since there is only one argument in the function and that would be the console command:
JOIN HL2GMED DISCORD SERVER!
concommand.Remove("ConsoleCommand")Thank you for reading this tutorial, see ya later!
JOIN HL2GMED DISCORD SERVER!