Jump to content

Delete vehicle from x,y,z


dewu

Recommended Posts

Posted

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?

Posted

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.

Posted

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.

Posted

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) 

Posted
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

Posted
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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...