Advertisement
actuallykane

EssentialMode command handler

Aug 12th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.97 KB | None | 0 0
  1. function addCommand(command, callback, suggestion, arguments)
  2.     commands[command] = {}
  3.     commands[command].perm = 0
  4.     commands[command].group = "user"
  5.     commands[command].cmd = callback
  6.     commands[command].arguments = arguments or -1
  7.  
  8.     if suggestion then
  9.         if not suggestion.params or not type(suggestion.params) == "table" then suggestion.params = {} end
  10.         if not suggestion.help or not type(suggestion.help) == "string" then suggestion.help = "" end
  11.  
  12.         commandSuggestions[command] = suggestion
  13.     end
  14.  
  15.     if(settings.defaultSettings.disableCommandHandler ~= 'false')then
  16.         RegisterCommand(command, function(source, args)
  17.             if((#args <= commands[command].arguments and #args == commands[command].arguments) or commands[command].arguments == -1)then
  18.                 callback(source, args, Users[source])
  19.             else
  20.                 TriggerEvent("es:incorrectAmountOfArguments", source, commands[command].arguments, #args, Users[source])
  21.             end
  22.         end, false)
  23.     end
  24.  
  25.     debugMsg("Command added: " .. command)
  26. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement