• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

addEvent Breaks Whenever I reload It

Mooosie

- Lua Scripter -
Joined
Aug 2, 2008
Messages
702
Reaction score
27
Location
Sweden
This is the script:
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
 
when you make reload it will stop all script and start them again
to fix it don't reload while the event running :p

if you have other scripts that use reload
you can make something in global event
 
Hmm... The script i've made is not in an event.
It's like a mining quest. You have to pick them and get gems. You are giving the gems to the quest giver.

When you have right-clicked on the crystal (the mining rock), it will disappear and if i accedently reload actions when the rock is gone, it will never come back. thats why ;(
 
Back
Top