Advertisement
Rochet2

Untitled

Jan 24th, 2015
435
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- command, minGMLevel, syntax
  2. local Table =  {
  3.     ["vipinfo"]     = { 0, ".vipinfo <player name>" },
  4.     ["viplevel"]    = { 1, ".viplevel <player name> <new level>"},
  5. }
  6.  
  7. -- Here we check if the written command exists in the table
  8. -- If command exists in table then we handle
  9. local function CommandsSystem(event, player, command)
  10.     local cmd, parameters = command:match("([^%s]+)%s?(.*)")
  11.     if not cmd then
  12.         return
  13.     end
  14.     for com,_ in pairs(Table) do
  15.         if (string.find(com, cmd) == 1) then
  16.             player:HandleCommand(com, parameters)
  17.             return false
  18.         end
  19.     end
  20. end
  21.  
  22. -- Here we handle all available commands
  23. -- We check if player has required gm level to use that command
  24. function Player:HandleCommand(command, parameters)
  25.     if (self:GetGMRank() >= Table[command][1]) then
  26.         if (command == "vipinfo") then
  27.             SendWorldMessage("Here we do something for command vipinfo")
  28.         else
  29.             self:SendBroadcastMessage("|cffFF0000Command not yet handled!")
  30.         end
  31.     end
  32. end
  33.  
  34. RegisterPlayerEvent(42, CommandsSystem)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement