onilink_

Untitled

Jul 8th, 2020
1,410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.05 KB | None | 0 0
  1.  
  2. function execCommand(ctx, args, cursor)
  3.    
  4.     local rarity = MonsterRarity:new(0)
  5.    
  6.     if #args < 1 then
  7.         return 0
  8.     end
  9.    
  10.     local i = 1
  11.     while i<#args do
  12.         local arg = args[i]
  13.         if string.sub(arg, 1, 1) == '-'
  14.         then
  15.             cmd = string.sub(arg, 2)
  16.             print("cmd:",cmd)
  17.             if cmd == "s" or cmd == "shiny" then
  18.                 table.remove(args, i)
  19.                 local r = args[i]
  20.                 if r == "uncommon" then
  21.                     rarity = MonsterRarity:new(0, MonsterRarityColor.Uncomon)
  22.                 elseif r == "rare" then
  23.                     rarity = MonsterRarity:new(0, MonsterRarityColor.Rare)
  24.                 elseif r == "divine" then
  25.                     rarity = MonsterRarity:new(0, MonsterRarityColor.Divine)
  26.                 elseif r == "legendary" then
  27.                     rarity = MonsterRarity:new(0, MonsterRarityColor.Legendary)
  28.                 end
  29.             elseif cmd == "r" or cmd == "rarity" then
  30.                 table.remove(args, i)
  31.                 local r = tonumber(args[i])
  32.                 rarity = MonsterRarity:new(r)
  33.             end
  34.            
  35.             table.remove(args, i)
  36.         else
  37.             i = i+1
  38.         end
  39.     end
  40.    
  41.     if #args < 1 then
  42.         return 0
  43.     end
  44.    
  45.     local level = 1
  46.     local entry = pcEntryIdFromString(args[1])
  47.    
  48.     if #args >= 2 then
  49.         level = tonumber(args[2])
  50.         if level > 50000 then
  51.             level = 50000
  52.         end
  53.     end
  54.    
  55.     local count = 1
  56.     if #args >= 3 then
  57.         count = tonumber(args[3])
  58.     end
  59.    
  60.     local dx = 0
  61.     if #args >= 4 then
  62.         dx = tonumber(args[4])
  63.     end
  64.    
  65.    
  66.     local spawn_attr = MonsterSpawnAttributes:new(entry.ind)
  67.     spawn_attr:setRarity(rarity)
  68.     spawn_attr:setLevel(level)
  69.     local spawn_params = MonsterSpawnParam:new()
  70.    
  71.     for i=0, count do
  72.         pcCreateMonster(ctx, spawn_attr, cursor, spawn_params)
  73.         cursor.x = cursor.x + dx
  74.     end
  75.    
  76.     return 0
  77. end
Advertisement
Add Comment
Please, Sign In to add comment