Aeronx
Intermediate OT User
- Joined
- Dec 17, 2015
- Messages
- 746
- Solutions
- 9
- Reaction score
- 125
Hello guys! Im trying to do a script that does the next:
Use tool only on X tile, and when you do so, an item is created.
After ,say, 24h another item is spawned and the previous item is deleted. (So they dont overlap)
I've got it working fine so far.. but i'm having problems deleting the item that is already there since there
isnt any game.removeItem or something like that.
Here's the code:
Thanks for your time guys!
Use tool only on X tile, and when you do so, an item is created.
After ,say, 24h another item is spawned and the previous item is deleted. (So they dont overlap)
I've got it working fine so far.. but i'm having problems deleting the item that is already there since there
isnt any game.removeItem or something like that.
Here's the code:
Code:
local seconds = 1
local seconds2 = 10
function doCreateStone(pos, itemid)
local tile = Tile(pos)
if tile:getTopCreature() then
pos:sendMagicEffect(CONST_ME_POFF)
return addEvent(doCreateStone, seconds * 1000, pos, 8640)
else
Game.createItem(8640, 1, pos)
pos:sendMagicEffect(CONST_ME_MAGIC_RED)
end
end
function doCreateStone2(pos, itemid)
local tile = Tile(pos)
if tile:getTopCreature() then
pos:sendMagicEffect(CONST_ME_POFF)
return addEvent(doCreateStone2, seconds2 * 1000, pos, 8636)
else
Game.createItem(8636, 1, pos)
pos:sendMagicEffect(CONST_ME_MAGIC_RED)
end
end
local shards = {
[804] = {
itemid = 8640,
itemid2 = 8636
}
}
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
local player = type(cid) == 'number' and Player(cid) or cid
if shards[target.itemid] then
toPosition:sendMagicEffect(CONST_ME_MAGIC_GREEN)
addEvent(doCreateStone, seconds * 1000, toPosition, target.itemid)
addEvent(doCreateStone2, seconds2 * 1000, toPosition, target.itemid)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_RED, "XXXXXXX")
return true
end
end
Thanks for your time guys!