function exhaust(cid, storevalue, exhausttime)
newExhaust = os.time()
oldExhaust = getPlayerStorageValue(cid, storevalue)
if (oldExhaust == nil or oldExhaust < 0) then
oldExhaust = 0
end
if (exhausttime == nil or exhausttime < 0) then
exhausttime = 1
end
diffTime = os.difftime(newExhaust, oldExhaust)
if (diffTime >= exhausttime or diffTime < 0) then
setPlayerStorageValue(cid, storevalue, newExhaust)
return 1
else
return 0
end
end
function onUse(cid, item, frompos, item2, topos)
local config = {
storevalue = 0,
exhausttime = 1,
newnPosition = {x=1484, y=1450, z=7},
}
local monster = {
["Hero"] = {x=5479, y=1449, z=7}
}
for name, pos in pairs(monster) do
if (exhaust(cid, config.storevalue, config.exhausttime) == TRUE) then
if item.itemid == 1945 then
doSummonCreature(name, pos)
doTransformItem(item.uid,item.itemid+1)
break
elseif item.itemid == 1946 then
doSummonCreature(name, pos)
doTransformItem(item.uid,item.itemid-1)
break
else
doPlayerSendCancel(cid,"Sorry,not possible.")
end
break
else
doPlayerSendCancel(cid,"You Need Wait 2 Second.")
doSendMagicEffect(getCreaturePosition(cid),CONST_ME_POFF)
end
end
return TRUE
end