xKrazyx
Old School
- Joined
- Oct 23, 2012
- Messages
- 904
- Solutions
- 6
- Reaction score
- 683
So heres my problem..
AddEvent removeItem ......................
Because of the way you have to write RemoveItem in a function in an AddEvent to fking get it to work over time... Its created a problem for me where the AddEvents will Store the tree ID to Create it even tho I run the script again....
But the stumpID does not separately save when trying to remove... Im guessing its overwriting the stumpID variable the 2nd time I run it.
I've tried for a minute. changing code around. can't get it still.. AddEvent and removeItem do not like each other...
Maybe you might have better luck, or have done this before. The for loops are there because im adding more info to the array eventually.
I don't want to have to put a delay
.. I wanna be a lumberjack on HGH
AddEvent removeItem ......................
Because of the way you have to write RemoveItem in a function in an AddEvent to fking get it to work over time... Its created a problem for me where the AddEvents will Store the tree ID to Create it even tho I run the script again....
But the stumpID does not separately save when trying to remove... Im guessing its overwriting the stumpID variable the 2nd time I run it.
I've tried for a minute. changing code around. can't get it still.. AddEvent and removeItem do not like each other...
Maybe you might have better luck, or have done this before. The for loops are there because im adding more info to the array eventually.
I don't want to have to put a delay
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
--Time the tree re-appears
local backTime=5*1000
local thisTreePos=toPosition
local trees = {
[2700] = {12669},
[2701] = {12674},
[2702] = {12670},
[2703] = {12669},
[2704] = {12671},
[2705] = {12670},
[2706] = {12671},
[2707] = {12669},
[2708] = {12669},
[2712] = {12669}
}
--Loop to find tree in array Trees
for tree, stump in pairs(trees) do
--doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, ""..tree.."")
local itemOnGround = getTileItemById(toPosition, tree)
if itemOnGround.itemid==tree then
doSendMagicEffect(toPosition, 12)
if(itemOnGround.actionid < 8000 or itemOnGround.actionid > 8002) then
doSetItemActionId(itemOnGround.uid, 8000)
elseif(itemOnGround.actionid == 8000) then
doPlayerAddItem(cid, 5901, 1)
doSetItemActionId(itemOnGround.uid, 8001)
elseif(itemOnGround.actionid == 8001) then
doSetItemActionId(itemOnGround.uid, 8002)
elseif(itemOnGround.actionid == 8002) then
doPlayerAddItem(cid, 5901, 1)
doRemoveItem(getTileItemById(toPosition, tree).uid, 1)
for indx, positionCoords in ipairs(stump) do
-- doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, ""..positionCoords.."")
stumpID=positionCoords
end
doCreateItem(stumpID, toPosition)
--remove the stump before next tree is placed
addEvent (
function ()
local tree1 = getTileItemById(toPosition, stumpID)
doRemoveItem(tree1.uid, 1)
end, (backTime-10)
)
--respawn the tree
addEvent(doCreateItem, backTime, tree, toPosition)
end
break
else
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
end
end
return true
end
Last edited: