roaddog Posted March 16, 2015 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. You gone learn today. I work my ass off, but I still can't pay tho.
TAPL Posted March 16, 2015 Posted March 16, 2015 At the second code put an outputChatBox before and after line 4 and see if it has passed.
roaddog Posted March 16, 2015 Author 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. You gone learn today. I work my ass off, but I still can't pay tho.
TAPL Posted March 16, 2015 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, :~)
roaddog Posted March 16, 2015 Author Posted March 16, 2015 Yay! That could work. Thanks TAPL. You gone learn today. I work my ass off, but I still can't pay tho.
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