Advertisement
Deozaan

changejob.lua

Oct 13th, 2016
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.19 KB | None | 0 0
  1. ---------------------------------------------------------------------------------------------------
  2. -- func: changejob
  3. -- desc: Changes the players current job.
  4. ---------------------------------------------------------------------------------------------------
  5.  
  6. require("scripts/globals/status");
  7.  
  8. cmdprops =
  9. {
  10.     permission = 1,
  11.     parameters = "si"
  12. };
  13.  
  14. function onTrigger(player, jobId, level)
  15.     jobId = tonumber(jobId) or JOBS[string.upper(jobId)];
  16.  
  17.     if (jobId == nil) then
  18.         player:PrintToPlayer("You must enter a job ID or short-name.");
  19.         return;
  20.     end
  21.  
  22.    if (jobId <= 0 or jobId >= MAX_JOB_TYPE) then
  23.        player:PrintToPlayer(string.format("Invalid job '%s' given. Use short-name or id. e.g. WAR", jobId));
  24.        return;
  25.    end
  26.  
  27.     -- Change the player's job.
  28.     player:changeJob(jobId);
  29.    
  30.     -- Don't affect the level if it wasn't passed in.
  31.     if (level == nil) then
  32.         player:setLevel(player:getMainLvl());
  33.         return;
  34.     end
  35.  
  36.     -- Attempt to set the players level.
  37.     if (level > 0 and level <= 99) then
  38.         player:setLevel(level);
  39.     else
  40.         player:PrintToPlayer("Invalid level given. Level must be between 1 and 99!");
  41.     end
  42. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement