Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.79 KB | None | 0 0
  1. function getItemSlots(uid, findslot) -- return all slots in table, even if its empty, findslot is option and return only slot by number.
  2.     local mytable = {}
  3.     for i = 1, 5 do
  4.         local slot = getItemAttribute(uid, "slot" .. i)
  5.         local empty = "[] - Empty" 
  6.         if not slot or slot == empty then
  7.             slot = empty
  8.         else
  9.             slot = "[slot #" .. i .. "] - " .. slot
  10.         end
  11.         if findslot and findslot == i then
  12.             return slot
  13.         end    
  14.         table.insert(mytable, slot)
  15.     end
  16.     return mytable
  17. end
  18.  
  19. function findSlotWith(uid, value) -- return the number of a free slot
  20.     local slots = getItemSlots(uid)
  21.     local slotNumber = 0
  22.     for i = 1, #slots do
  23.         if string.find(slots[i], value) then
  24.             print("found" .. value)
  25.             slotNumber = i
  26.             break
  27.         end
  28.     end
  29.     return slotNumber
  30. end
  31.  
  32. function onLogin(cid)
  33.     local rate = 1.20 -- 30%
  34.     local config = {
  35.         vip = "Você tem "..((rate - 1)*100).."% de exp a mais agora!",
  36.         notvip = "Tornesse vip e ganhe "..((rate - 1)*100).."% a mais de experiencia!",
  37.     }
  38.  
  39.     if vip.hasVip(cid) == FALSE then
  40.         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, config.notvip)
  41.     else
  42.         doPlayerSetExperienceRate(cid, rate)
  43.         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, config.vip)
  44.     end
  45.  
  46.     local config = {
  47.         {"bonusexp"},
  48.         {"bonusaxe"},
  49.         {"bonussword"},
  50.         {"bonusclub"},
  51.         {"bonusml"}
  52.     }
  53.    
  54.     local newTable = {}
  55.     for i = 1, 9 do
  56.         addItem = getPlayerSlotItem(cid, i)
  57.         if addItem then
  58.             if not getItemWeaponType(addItem.uid) or getItemWeaponType(addItem.uid) > 5
  59.                 or getItemWeaponType(addItem.uid) == 0 and not isArmor(addItem)
  60.                 or addItem.itemid == 0 or addItem.type > 1 or isItemStackable(addItem.uid) then
  61.                 return true
  62.             end
  63.             table.insert(newTable, addItem)
  64.         end
  65.     end
  66.    
  67.     for i = 1, #newTable do
  68.         local itemUid = newTable[i].uid
  69.         local findBonus = getItemSlots(itemUid)
  70.         if string.find(findBonus, "bonusexp") then
  71.             doPlayerSetExperienceRate(cid, 2.0)
  72.             doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "more exp.")
  73.             return true
  74.         elseif string.find(findBonus, "bonusaxe") then
  75.             doItemSetAttribute(itemUid, "skillAxe", 20)
  76.             doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "more axe.")
  77.             return true
  78.         elseif string.find(findBonus, "bonussword") then       
  79.             doItemSetAttribute(itemUid, "skillSword", 20)
  80.             doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "more sword.")
  81.             return true
  82.         elseif string.find(findBonus, "bonusclub") then
  83.             doItemSetAttribute(itemUid, "skillClub", 20)
  84.             doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "more club.")
  85.             return true
  86.         elseif string.find(findBonus, "bonusml") then  
  87.             doItemSetAttribute(itemUid, "magicPoints", 20)
  88.             doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "more ml.")
  89.             return true
  90.         end
  91.     end
  92.    
  93.     return true
  94. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement