Nokturno
Not a human
- Joined
- Aug 7, 2009
- Messages
- 569
- Solutions
- 2
- Reaction score
- 402
i manage to create this script by myself by reading some tutorials and sample scripts.
and its working, im using this on 4 diferent places
it removes some barrels when i click on any of those items, and it works fine, the problem comes when sone click when the barrels are havent respawned yet i a get a console error , its a way to bypass all the function while the barrels are still mising from their position?
Code:
local timeToReset = 15 -- Time to reset the quest in seconds
local objectId = 5620 -- Id of the item Blocking the pathlocal
local barrel1 = 31992
local barrel2 = 31992
p = {
Position(4614, 5421, 3), -- Position of the item blocking the path
Position(4614, 5422, 3), -- barrel 1
Position(4615, 5422, 3), -- barrel 2
}
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
local stone = Tile(p[1])
local br1 = Tile(p[2])
local br2 = Tile(p[3])
if item.itemid == 5598 or item.itemid == 5599 or item.itemid == 5600 or item.itemid == 5601 and player:getStorageValue(storage) == 0 then
if timeToReset > 1 then
cid:sendTextMessage(MESSAGE_EVENT_ORANGE, 'The object in your path has been removed for ' .. timeToReset .. ' seconds.')
else
cid:sendTextMessage(MESSAGE_EVENT_ORANGE, 'The object in your path has been removed for ' .. timeToReset .. ' second.')
return false
end
stone:getItemById(objectId):remove()
br1:getItemById(barrel1):remove()
br2:getItemById(barrel2):remove()
p[1]:sendMagicEffect(CONST_ME_EXLODEONE)
p[2]:sendMagicEffect(CONST_ME_EXPLODECLOUD)
p[3]:sendMagicEffect(CONST_ME_EXPLODECLOUD)
addEvent(function(stonePos)
Game.createItem(objectId, 1, stonePos)
stonePos:sendMagicEffect(CONST_ME_TELEPORT)
end, timeToReset * 1000, stone:getPosition())
addEvent(function(br1Pos)
Game.createItem(barrel1, 1, br1Pos)
br1Pos:sendMagicEffect(CONST_ME_TELEPORT)
end, timeToReset * 1000, br1:getPosition())
addEvent(function(br2Pos)
Game.createItem(barrel1, 1, br2Pos)
br2Pos:sendMagicEffect(CONST_ME_TELEPORT)
end, timeToReset * 1000, br2:getPosition())
else
cid:sendTextMessage(MESSAGE_EVENT_ORANGE, 'The object in your path is already removed')
return false
end
return true
end
it removes some barrels when i click on any of those items, and it works fine, the problem comes when sone click when the barrels are havent respawned yet i a get a console error , its a way to bypass all the function while the barrels are still mising from their position?