Advertisement
Guest User

Use in a table(item)

a guest
Jan 21st, 2013
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.09 KB | None | 0 0
  1. local items = {
  2. [0] = {id = 2472, count = 1, chance = 2},
  3. [1] = {id = 2466, count = 1, chance = 5},
  4. [2] = {id = 8930, count = 1, chance = 10},
  5. [3] = {id = 8858, count = 1, chance = 15},
  6. [4] = {id = 2160, count = 10, chance = 30},
  7. [5] = {id = 6569, count = 50, chance = 100}
  8. }
  9.  
  10. local table_pos = {x = 1012, y = 992, y = 7}
  11.  
  12. function onUse(cid, item, fromPosition, itemEx, toPosition)
  13.  
  14. if itemEx.itemid == 2450 then
  15.    if getTileItemById(table_pos, 2450).uid > 0 then
  16.       for _ = 1, #items do
  17.           if items[i].chance > math.random(1, 100) then
  18.              doPlayerAddItem(cid, items[i].id, items[i].count)
  19.                 doPlayerSendTextMessage(cid, 26, "You make a: " .. getItemNameById(items[i].id) .. ".")
  20.                    break
  21.                         else
  22.                             doPlayerSendCancel(cid, "You make anything.")
  23.                         end                  
  24.                   else
  25.                       end
  26.                           else
  27.                   doPlayerSendCancel(cid, "Use in a table.")
  28.                end
  29.                end
  30.     return true
  31. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement