Guest User

Untitled

a guest
Jul 21st, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.37 KB | None | 0 0
  1. COMMAND = openAura.command:New();
  2. COMMAND.tip = "Set the class of your character.";
  3. COMMAND.text = "<string Class>";
  4. COMMAND.flags = CMD_HEAVY;
  5. COMMAND.arguments = 1;
  6.  
  7. -- Called when the command has been run.
  8. function COMMAND:OnRun(player, arguments)
  9.     local class = openAura.class:Get( arguments[1] );
  10.    
  11.     if ( player:InVehicle() ) then
  12.         openAura.player:Notify(player, "You don't have permission to do this right now!");
  13.        
  14.         return;
  15.     end;
  16.    
  17.     if (class) then
  18.         local limit = openAura.class:GetLimit(class.name);
  19.        
  20.         if ( openAura.plugin:Call("PlayerCanBypassClassLimit", player, class.index) ) then
  21.             limit = MaxPlayers();
  22.         end;
  23.        
  24.         if (_team.NumPlayers(class.index) >= limit) then
  25.             openAura.player:Notify(player, "There are too many characters with this class!");
  26.         else
  27.             local previousTeam = player:Team();
  28.            
  29.             if (player:Team() != class.index) then
  30.                 if ( openAura.plugin:Call("PlayerCanChangeClass", player, class) ) then
  31.                         local success, fault = openAura.class:Set(player, class.index, nil, true);
  32.                        
  33.                         if (!success) then
  34.                             openAura.player:Notify(player, fault);
  35.                         end;
  36.                     end;
  37.                 else
  38.                     openAura.player:Notify(player, "You do not have access to this class!");
  39.                 end;
  40.             end;
  41.         end;
  42.     else
  43.         openAura.player:Notify(player, "This is not a valid class!");
  44.     end;
  45. end;
  46.  
  47. openAura.command:Register(COMMAND, "SetClass");
Add Comment
Please, Sign In to add comment