This is the script:
When I have used on one of these items (Ex. 8636) and then reload before it has gone 10 seconds. The item wont come back. Thus, addEvent is not looping anymore. It stops take the time and create the item again.
Can someone help me, I am using 0.3.6
Thanks
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local again = 10
local quest = getPlayerStorageValue(cid, 319)
local itemPos = getThingPos(itemEx.uid)
local rand = math.random(5)
local diamonds = {
[1] = 2149,
[2] = 2146,
[3] = 10454,
[4] = 2147
}
if(getPlayerItemCount(cid, 4874) >= 1) then
if quest == 1 then
if isInRange(getCreaturePosition(cid), {x=546, y=864, z=8}, {x=649, y=926, z=8}) then
if(item.itemid == 8636 or item.itemid == 8640) then
doPlayerAddItem(cid, diamonds[1], rand)
doPlayerSendTextMessage(cid, 19, "You collected ".. rand .." small emerald(s) from the green large crystal.")
doRemoveItem(itemEx.uid, 1)
addEvent(doCreateItem, again*1000, itemEx.itemid, 1, itemPos)
addEvent(doSendMagicEffect, 0, itemPos, 3)
addEvent(doSendMagicEffect, again*1000, itemPos, 20)
end
if(item.itemid == 8637 or item.itemid == 8633) then
doPlayerAddItem(cid, diamonds[2], rand)
doPlayerSendTextMessage(cid, 19, "You collected ".. rand .." small sapphire(s) from the blue large crystal.")
doRemoveItem(itemEx.uid, 1)
addEvent(doCreateItem, again*1000, itemEx.itemid, 1, itemPos)
addEvent(doSendMagicEffect, 0, itemPos, 3)
addEvent(doSendMagicEffect, again*1000, itemPos, CONST_ME_ENERGYAREA)
end
if(item.itemid == 8634 or item.itemid == 8638) then
doPlayerAddItem(cid, diamonds[3], rand)
doPlayerSendTextMessage(cid, 19, "You collected ".. rand .." cyan sapphire(s) diamonds from the cyan large crystal.")
doRemoveItem(itemEx.uid, 1)
addEvent(doCreateItem, again*1000, itemEx.itemid, 1, itemPos)
addEvent(doSendMagicEffect, 0, itemPos, 3)
addEvent(doSendMagicEffect, again*1000, itemPos, CONST_ME_GIANTICE)
end
if(item.itemid == 8635 or item.itemid == 8639) then
doPlayerAddItem(cid, diamonds[4], rand)
doPlayerSendTextMessage(cid, 19, "You collected ".. rand .." small rubie(s) from the red large crystal.")
doRemoveItem(itemEx.uid, 1)
addEvent(doCreateItem, again*1000, itemEx.itemid, 1, itemPos)
addEvent(doSendMagicEffect, 0, itemPos, 3)
addEvent(doSendMagicEffect, again*1000, itemPos, 0)
end
else
doPlayerSendCancel(cid, "You cannot use this object.")
end
else
doPlayerSendCancel(cid, "You cannot use this object.")
end
else
doPlayerSendCancel(cid, "Sorry, you cannot collect gems if you don't have any dwarven pickaxe. You can get it by killing the workers here.")
end
return true
end
When I have used on one of these items (Ex. 8636) and then reload before it has gone 10 seconds. The item wont come back. Thus, addEvent is not looping anymore. It stops take the time and create the item again.
Can someone help me, I am using 0.3.6
Thanks