roaddog Posted March 16, 2015 Share Posted March 16, 2015 This is how I created the trees trees = {} treesblip = {} function createTrees(p) if p == getLocalPlayer() then for i, index in pairs(treesPositions) do for i, v in ipairs(index) do local x, y, z = unpack(v) trees[i] = createObject(idList[math.random(1, 3)], x, y, z) treesblip[i] = createBlipAttachedTo(trees[i], 0, 1, 255, 255, 0, 255, 0, 500) end end end end This is how I destroy. this is the problem, it didnt get destroyed ._. how do I destroy dem? addEvent("onClientPlayerQuitJob", true) function destroyShitsAll(p, job) if p == getLocalPlayer() and job == "Lumberjack" then treeloaded = false for i, index in ipairs(trees) do destroyElement(trees[i]) end for i, v in ipairs(treesblip) do destroyElement(treesblip[i]) end end end addEventHandler("onClientPlayerQuitJob", root, destroyShitsAll) I also tried for i, index in ipairs(trees) do destroyElement(index) end it does nothing. Link to comment
TAPL Posted March 16, 2015 Share Posted March 16, 2015 At the second code put an outputChatBox before and after line 4 and see if it has passed. Link to comment
roaddog Posted March 16, 2015 Author Share Posted March 16, 2015 Yes it did. function destroyShitsAll(p, job) if p == getLocalPlayer() and job == "Lumberjack" then treeloaded = false outputChatBox("Passed!") for i, index in ipairs(trees) do destroyElement(trees[i]) outputChatBox("how about this spam?") end for i, v in ipairs(treesblip) do outputChatBox("Spam this server man") destroyElement(treesblip[i]) end end end addEventHandler("onClientPlayerQuitJob", root, destroyShitsAll) all outputs got passed. Link to comment
TAPL Posted March 16, 2015 Share Posted March 16, 2015 Try this: trees = {} treesblip = {} function createTrees(p) if p == getLocalPlayer() then for i, index in pairs(treesPositions) do for i, v in ipairs(index) do local x, y, z = unpack(v) local treeObj = createObject(idList[math.random(1, 3)], x, y, z) table.insert(trees, treeObj) treesblip[treeObj] = createBlipAttachedTo(treeObj, 0, 1, 255, 255, 0, 255, 0, 500) end end end end addEvent("onClientPlayerQuitJob", true) function :~(p, job) if p == getLocalPlayer() and job == "Lumberjack" then treeloaded = false for i, index in ipairs(trees) do destroyElement(index) destroyElement(treesblip[index]) treesblip[index] = nil end trees = {} end end addEventHandler("onClientPlayerQuitJob", root, :~) Link to comment
roaddog Posted March 16, 2015 Author Share Posted March 16, 2015 Yay! That could work. Thanks TAPL. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now