- Joined
- Feb 14, 2015
- Messages
- 5,643
- Solutions
- 559
- Reaction score
- 3,949
I'm having a problem with this script, there's no errors in console, but when I use the crystal on the item to upgrade to the next tier, it won't remove it if it fails (or say it failed), I can just continue using it until it successfully upgrades
can anyone help?
can anyone help?
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local rand = math.random(1,100)
local tiers = {
{tier1 = 2501, tier2 = 2457}, -- Helmets
{tier1 = 3968, tier2 = 2463}, -- Armors
{tier1 = 2504, tier2 = 2647}, -- Legs
{tier1 = 2641, tier2 = 2645}, -- Boots
{tier1 = 6433, tier2 = 2509}, -- Shields
{tier1 = 8752, tier2 = 2214}, -- Rings
{tier1 = 2451, tier2 = 7449}, -- Swords
{tier1 = 2429, tier2 = 8601}, -- Axes
{tier1 = 7387, tier2 = 2422}, -- Clubs
{tier1 = 2185, tier2 = 8910}, -- Wands
{tier1 = 2456, tier2 = 8853}, -- Bows
{tier1 = 2403, tier2 = 2402}, -- Daggers
}
-- T1/T2 --
if getPlayerItemCount(cid, itemEx.itemid) < 3 then
doSendMagicEffect(toPosition, CONST_ME_POFF)
doPlayerSendCancel(cid, "You must have 3 of the same item to upgrade it to the next item!")
else
if rand <= 25 then
for i = 1, #tiers do
local tier1 = tiers[i].tier1
local tier2 = tiers[i].tier2
if itemEx.itemid == tier1 then
doTransformItem(itemEx.uid, tier2)
doSendAnimatedText(getPlayerPosition(cid), "Upgrade!", 210)
doSendMagicEffect(getThingPosition(itemEx.uid), CONST_ME_FIREWORK_RED)
doRemoveItem(item.uid)
doPlayerRemoveItem(cid, itemEx.uid, 2)
else
if rand > 25 then
doSendAnimatedText(getPlayerPosition(cid), "Failed.", 145)
doRemoveItem(item.uid)
end
end
end
end
end
return true
end