Advertisement
poxipox

Untitled

Oct 24th, 2023
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.84 KB | None | 0 0
  1. local breakChance = 60
  2. local rustyItemsTemp = {
  3.     -- [fromItemId] = toItemId,
  4.     [diamondItemId] = {armorId_1, armorId_2},
  5.  
  6.  
  7. }
  8. local rustyItems = {}
  9. for diamoondId, data in pairs(rustyItemsTemp) do
  10.     for i = 1, #data do
  11.         rustyItems[data[i]] = diamoondId
  12.     end
  13. end
  14.  
  15.  
  16. function onUse(cid, item, fromPosition, itemEx, toPosition)
  17.     local newId = rustyItems[itemEx.itemid]
  18.     if newId then
  19.         if math.random(100) <= breakChance then
  20.             doRemoveItem(itemEx.uid)
  21.             doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You broke it.")
  22.         else
  23.             doTransformItem(itemEx.uid, newId)
  24.             doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You removed the rust, revealing a "..getItemNameById(newId))
  25.         end
  26.         doRemoveItem(item.uid,1)
  27.         return TRUE
  28.     end
  29.     return FALSE
  30. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement