dewu Posted February 15, 2015 Share Posted February 15, 2015 Hi guys. I want to delete some vehicles from different positions. So i make that script: skasuj = { ["usun"] = { {-1185.9775390625,26.4111328125,14.1484375}, {-1724.5830078125,2559.3544921875,104.09127807617}, {615.744140625,850.1572265625,-43.009014129639}, }, } function zaznacz () for i,veh in ipairs(skasuj) do local x,y,z = veh[1],veh[2],veh[3] destroyElement(veh) end end addCommandHandler("zaznacz",zaznacz) but it's not working. What's wrong with it? Link to comment
Castillo Posted February 15, 2015 Share Posted February 15, 2015 Well, because that makes no sense, you are trying to destroy numbers... If what you want is to remove the values from the table, then use table.remove. Link to comment
Gallardo9944 Posted February 15, 2015 Share Posted February 15, 2015 If you want to remove vehicles standing on the exact point (they never do, though), you should find all vehicles and check their positions. getElementsByType("vehicle") and getElementPosition should help. Link to comment
Ryancit2 Posted February 16, 2015 Share Posted February 16, 2015 You'll barely find vehicles at those exact pos, if you want, i can provide a small tweak to remove vehicles from specific locations (real small ones though). I made one: function destroyVehicles() local x, y, z = getElementPosition(localPlayer) local tempCol = createColRectangle(x, y, 100, 100) local vehs = getElementsWithinColShape(tempCol, "vehicle") local count = 0 for k, v in pairs(vehs) do destroyElement(v) count = count+1 end outputChatBox("Destroyed "..count.." vehicles near you.") count = 0 destroyElement(tempCol) end addCommandHandler("dvehs", destroyVehicles) Link to comment
Dimmitry007 Posted February 17, 2015 Share Posted February 17, 2015 function dAllC(thePlayer) accountname = getAccountName(getPlayerAccount(thePlayer)) if isObjectInACLGroup("user." .. accountname, aclGetGroup("Admin")) then vehicles = getElementsByType("vehicle") for i,v in ipairs(vehicles) do destroyElement(getElementData(v, "parent")) destroyElement(v) outputChatBox("Cars have been deleted !",thePlayer, 255, 0, 0, false) end end end addCommandHandler("dallvehs", dAllC) Try this Link to comment
JR10 Posted February 17, 2015 Share Posted February 17, 2015 Try this Why would this help? He wants to destroy vehicles that are near a certain world position, you're just destroying all the vehicles. Link to comment
Ab-47 Posted February 17, 2015 Share Posted February 17, 2015 Create a col-shape, get objects under the vehicles class and remove the vehicles if they're within the col-shape. Simple, I guess. 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