zocken212 Posted July 30, 2013 Share Posted July 30, 2013 Hey, again a problem from my side (._.). This time I have a problem with checking if there is an object in the colshape. When I move the object to the marker (where the colshape is as well) nothing happends. Here is the code of checking if there is an object: setTimer(function() local shape1 = getElementsWithinColShape(moneyShape1) for index, p in ipairs(shape1) do if getElementModel(p) == 2935 or 2934 then destroyElement(p) end end end,50,0) Link to comment
Moderators IIYAMA Posted July 30, 2013 Moderators Share Posted July 30, 2013 as far I know this script would remove every object within the colshape setTimer(function() local shape1 = getElementsWithinColShape(moneyShape1) for index, p in ipairs(shape1) do if getElementModel(p) == 2935 or 2934 then destroyElement(p) end end end,50,0) remains always true, so if colshape did exist, then all elements would be destroyed. You also would have an error/warning for trying to destroy player elements. This can be written like this: local model = getElementModel(p) if model == 2935 or model == 2934 then But I will recommend this: local trueModels = {[2935]=true,[2934]=true} setTimer(function() local shape1 = getElementsWithinColShape(moneyShape1) for index, p in pairs(shape1) do if trueModels[getElementModel(p)] then destroyElement(p) end end end,50,0) Link to comment
zocken212 Posted July 30, 2013 Author Share Posted July 30, 2013 Ehm lol. First time I tried it worked, but then I tried it again and it stopped working?? The object seems deleted, but is still visible? Link to comment
Moderators IIYAMA Posted July 30, 2013 Moderators Share Posted July 30, 2013 Is the colshape still intact? and what does debugscript 3 say? Link to comment
zocken212 Posted July 30, 2013 Author Share Posted July 30, 2013 Debugscript 3 says nothing, colshape is still intact. Maybe the error is because the object it attached to another object? Link to comment
zocken212 Posted August 1, 2013 Author Share Posted August 1, 2013 I don't know if this is allowed,but: When I create the object in the colshape directly, it gets destroyed. If I move it attached into the colshape and detach it there or above it, nothing happends?? Link to comment
Moderators IIYAMA Posted August 1, 2013 Moderators Share Posted August 1, 2013 attached at serverside? Link to comment
Moderators IIYAMA Posted August 1, 2013 Moderators Share Posted August 1, 2013 You can try to use: setElementPosition(element,getElementPosition(element)) after you detach it. Link to comment
zocken212 Posted August 1, 2013 Author Share Posted August 1, 2013 I tried it several times and it worked everytime. Thank you very much Link to comment
Moderators IIYAMA Posted August 1, 2013 Moderators Share Posted August 1, 2013 np. Good luck with your script. 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