Advertisement
Guest User

Untitled

a guest
Mar 7th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.70 KB | None | 0 0
  1.  local  rewards = {
  2.             premios = {
  3.                 [1] = {
  4.                         items = {
  5.                                     {itemID = 2160, count = 1},
  6.                                     {itemID = 2170, count = 1},
  7.                                     {itemID = 2155, count = 1},
  8.                                 },
  9.                         chance = 80,
  10.                         nome = "items",
  11.                       },
  12.  
  13.                 [2] = {
  14.                         items = {
  15.                                     {itemID = 2160, count = 50},
  16.                                     {itemID = 2160, count = 50},
  17.                                     {itemID = 2160, count = 50},
  18.                                 },
  19.                         chance = 20,
  20.                         nome = "addons",
  21.                       },
  22.               }
  23.             }
  24.            
  25.  
  26. function onUse(player, item, fromPosition, target, toPosition, isHotkey)   
  27.     local random = math.random(100)
  28.  
  29.         local i = 1
  30.  
  31.         while (i <= #rewards.premios) do    
  32.             local v = rewards.premios[i]  
  33.                    for i =1, #v.items do
  34.                     local spot = v.items[i]
  35.                        if (random <= v.chance) then
  36.                           if (v.nome == "items") then  
  37.                             local new_item = player:addItem(spot.itemID, spot.count)
  38.  
  39.                             if (type(new_item) == "table") then
  40.                                 new_item = new_item[1]
  41.                             end
  42.  
  43.                            
  44.  
  45.                             i = 999
  46.                             break
  47.                           elseif (v.nome == "addons") then
  48.                             local new_item = player:addItem(spot.itemID, spot.count)
  49.  
  50.                             if (type(new_item) == "table") then
  51.                                 new_item = new_item[1]
  52.                             end
  53.  
  54.                        
  55.  
  56.                             i = 999
  57.                             break                            
  58.                           end                          
  59.                         end                                        
  60.                     end
  61.                     i = i + 1    
  62.                     random = math.random(100)  
  63.                 end
  64.    
  65.  
  66.     player:sendTextMessage(22,"Clicou")
  67.     return true
  68. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement