• 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!

Remove Item after 20 seconds without addEvent()

WarOfTheTitans

Active Member
Joined
Feb 3, 2012
Messages
430
Reaction score
37
[SOLVED][SOLVED][SOLVED][SOLVED]

Solved, because I used this:
XML:
<item id="6542" article="an" name="colored egg" plural="colored eggs">
		<attribute key="decayTo" value="0" />
		<attribute key="duration" value="20" />
		<attribute key="moveable" value="0" />
	</item>
in items.xml.
Then to make it disappear, I used:
Lua:
egg = doCreateItem(6542, 1, getCreaturePosition)
doDecayItem(egg)
I removed ".uid" after "doDecayItem(egg". It worked perfectly without the "addEvent" function. I can even reload without any cancels aswell.

Thanks to Far Carder for helping me :)

[SOLVED][SOLVED][SOLVED][SOLVED]
My script:
Lua:
doCreateItem(6542, 1, getCreaturePosition(cid))

I want to disappear after 20 seconds. I've edited in items.xml:
XML:
<item id="6542" article="an" name="colored egg" plural="colored eggs">
		<attribute key="decayTo" value="0" />
		<attribute key="duration" value="20" />
		<attribute key="moveable" value="0" />
	</item>
But it doesn't disappear. I don't want any addEvents including because if i for example reload actions the addEvent will be canceled. So if you create the item, addEvent then if i reload actions the egg will lay on the ground forever.

Thanks in advance :)
 
Last edited:
You could do an onThink(interval) probably.
Set a globalstroage on spawning with os.time() then check via onThink if time.diff(os.time(),globalstorage) > 20 then remove.
Could work.
 
Tricky to track down the egg from the whole map xD
let's try this:
at creating the egg, add:
Lua:
local egg = doCreateItem(6542, 1, getCreaturePosition(cid))
doItemSetAttribute(egg.uid, "uid", 7000)
setGlobalStorageValue(7000,os.time())

then an onThink event with:
Lua:
function onThink()
if os.difftime(os.time(), getGlobalStorageValue(7000)) > 20 then
	doRemoveItem(7000, 1)
end
return true
end

I'm positive that this onThink won't work right on, but let's fix it ;)

Edit: A MOD could make it work. You use the same config for creating and checking.
Easiest.
 
Last edited:
Code:
doCreateItem(6542, 1, getCreaturePosition(cid))

disappeartime = 20 -- Time in seconds.
time = os.clock()
 
function onThink()
  if (time + disappeartime) < os.clock() then
    time = os.clock()
    doRemoveItem(7000, 1)
  end
  return 1
end
 
[SOLVED]
Nah, It looks like this will crash the server after some moments.
I want it like magicwall. I could source edit if its required.
 
Last edited:
Im pretty sure it's like this:
Lua:
egg = doCreateItem(6542, 1, getCreaturePosition(cid))
doDecayItem(egg.uid)
its the normal way to do it normally but I'm not sure if that will be cancelled if you reload actions or not
 
[SOLVED]
@Far Carder:
Take a look at the script:
Lua:
X

Not workin
Code:
[22/02/2012 22:57:33] data/actions/scripts/custom/plasticbomb.lua:onUse
[22/02/2012 22:57:33] Description: 
[22/02/2012 22:57:33] data/actions/scripts/custom/plasticbomb.lua:15: attempt to index local 'bomb1' (a number value)
[22/02/2012 22:57:33] stack traceback:
[22/02/2012 22:57:33] 	data/actions/scripts/custom/plasticbomb.lua:15: in function <data/actions/scripts/custom/plasticbomb.lua:1>
 
Last edited:
Was the bomb created? Also it looks like you are creating the bombs twice are you ment to be doing that? Try this:
Lua:
                    local bomb1 = doCreateItem(plasticBombs[1], 1, getCreaturePosition(cid))
                    doDecayItem(bomb1.uid
 
Last edited:
[SOLVED]
The bomb is created, it don't dissapear. The same error occours:
[22/02/2012 22:57:33] data/actions/scripts/custom/plasticbomb.lua:eek:nUse
[22/02/2012 22:57:33] Description:
[22/02/2012 22:57:33] data/actions/scripts/custom/plasticbomb.lua:15: attempt to index local 'bomb1' (a number value)
[22/02/2012 22:57:33] stack traceback:
[22/02/2012 22:57:33] data/actions/scripts/custom/plasticbomb.lua:15: in function <data/actions/scripts/custom/plasticbomb.lua:1>
 
Last edited:
@Nothxbye: Listen up... To call other scripts/storages from other scripts(creaturescipt/globalevent/and so on..) is more chance to crash. The storages values are sometimes suddenly appears "NIL".
I had a script that changed players storage, it worked very long time and then the storage suddenly appeared as "NIL" and everything looked fine in the script. So thats why I am ain't using called scripts.

[SOLVED]
@Far Carder, thanks alot it worked, even when i reloaded the sscript :) Rep+ ofcourse :)
 
Last edited:
u using that stupid script but you are scared of simply working script with os.clock() that i gave you before.. funny
I'm not sure if you are calling my script stupid but this is how you are ment to remove/change items after a certain time it is much MUCH simpler and alot less things to go wrong. I would say using globalevents and os.clock() is stupid since you can just use doDecayItem().
 
Back
Top