Jump to content

[Help Request] Vehicle Deletion Command


BLonwei

Recommended Posts

Hey everyone, I am trying to figure out a what to create a command that will delete all player vehicles in my server. However, I do NOT want to delete any faction vehicles. Only the vehicles that are owned by players. Would anyone have any ideals. If it helps, my server using SQL.

Link to comment

You could either store them in a table or assign a element data value upon spawn in order to identify them when looping through all vehicles to remove the player owned vehicles. If you create them using a map file you can identify them by which resource that owns them.

-- Spawn part 
local veh = createVehicle(...) 
  
-- Table 
veh_table = { } 
veh_table[veh] = true 
  
-- Element Data 
setElementData(veh, "isPlayerOwnedVehicle", true) 
  
-- To remove 
for k,v in pairs(getElementsByType("vehicle")) do 
    if getElementData(v, "isPlayerOwnedVehicle") or veh_table[v] then 
        destroyElement(v) 
    end 
end 

Link to comment

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