function onUse(cid, item, fromPosition, itemEx, toPosition)
local storage = 2625 --Storage value of the quest done
local object = 2626 --Itemid of the object
local uni = 1999 --uniqueId of the object
local temple = {x=1000, y=1000, z=7} --Temple position
local success = "Has logrado obtener la reliquia del gran mago!" --Got the item message
local fail = "Al parecer la fortuna no está de tu lado, intenta en otra ocasión!" --fail message
local chance = 5 --Chance percentage, now 5%
local reward = 2625 --Itemid of the reward
local ammount = 1 --Numbers of items to get, in case that is stackable
local done = "Tu ya has obtenido la reliquia del mago" --Message if you try to take again the prize
local doquest = "You need first finish the quest" --Message if you havent finish the preview quest
if getPlayerStorageValue(cid, storage) == 1 and item.uid == uni and itemEx.itemid == object then
local chance1 = math.random(1,100)
if chance1 > chance then
doPlayerSendTextMessage(cid, 22, fail)
doTeleportThing(cid, temple)
doSetPlayerStorageValue(cid, storage, 2)
else
doPlayerSendTextMessage(cid, 22, success)
doTeleportThing(cid, temple)
doSetPlayerStorageValue(cid, storage, 2)
doPlayerAddItem(cid, reward, ammount)
end
else
if getPlayerStorageValue(cid, storage) < 1 then
doPlayerSendCancel(cid, doquest)
end
else
if getPlayerStorageValue(cid, storage) > 1 then
doPlayerSendCancel(cid, done)
end
end
return true
end