[Release] Delete Vehicle Script [v1.1.0] (Updated 2020)

Hey @Im_Kawiz I don’t understand what you mean by that, can you explain? I’m also having the issue. “Insufficient Permissions”

It worked thanks!

1 Like

@RPPerry3 But you shouldn’t. You don’t want trolls on your server running around deleting vehicles to annoy people. You need to give your self permissions as an Admin to remove that message.

problem. I have a server hosted on a VPS (downloaded server files) and i have my friends server running on ZAP

heres the issue:

On my VPS hosted fivem server, the script works as expected, standalone and all that
on my friends zap server it says :

Could not find dependency vrp for resource deleteveh.
e[93mCouldn’t start resource deleteveh.e[0m

ive downloaded it a second time (version 1.0.5) just to be sure, and it wont work on the zap hoster. why is that?

^^ same thing as @xKyranStormx

Delete Vehicle Script W/ Ace Perms

About
This is just an updated version of @WolfKnight179 Delete vehicle script.
None of this would be possible without his code so all credit goes to him.
This update could be good for any servers who do not want everyone being able to delete vehicles.
I will post it here unless he allows me to release it.

Source

__resource.lua

open me
Name 'Delete Vehicle Script w/ Ace Perms'
Auther 'WolfKnight'
Description 'adds ace perms to delete vehicle script'
EXECUTE_CFG_INFO 'exec jeremys.admin.cfg'
ADD_ACE_INFO 'add_ace admin.delete jeremys.admin allow'
ADD_PRINCIPLE_INFO 'add_principal identifier.steam:STEAM_HEX_HERE admin.delete'
-- Delete Vehicle script written by WolfKnight
-- With credit to Mr.Scammer, thers, Zanax and Konijima!
-- Version 1.0.5
-- Set the resource manifest 
resource_manifest_version '77731fab-63ca-442c-a67b-abc70f28dfa5'
-- Add a client script 
client_script "client.lua"
-- Add a server script
server_script "server.lua"

Client.lua

Open me
-- Register a network event 
RegisterNetEvent( 'wk:deleteVehicle' )

-- The distance to check in front of the player for a vehicle
-- Distance is in GTA units, which are quite big  
local distanceToCheck = 5.0

-- Add an event handler for the deleteVehicle event. 
-- Gets called when a user types in /dv in chat (see server.lua)
AddEventHandler( 'wk:deleteVehicle', function()
    local ped = GetPlayerPed( -1 )

    if ( DoesEntityExist( ped ) and not IsEntityDead( ped ) ) then 
        local pos = GetEntityCoords( ped )

        if ( IsPedSittingInAnyVehicle( ped ) ) then 
            local vehicle = GetVehiclePedIsIn( ped, false )

            if ( GetPedInVehicleSeat( vehicle, -1 ) == ped ) then 
                SetEntityAsMissionEntity( vehicle, true, true )
                deleteCar( vehicle )

                if ( DoesEntityExist( vehicle ) ) then 
                	ShowNotification( "~r~Unable to delete vehicle, try again." )
                else 
                	ShowNotification( "Vehicle deleted." )
                end 
            else 
                ShowNotification( "You must be in the driver's seat!" )
            end 
        else
            local playerPos = GetEntityCoords( ped, 1 )
            local inFrontOfPlayer = GetOffsetFromEntityInWorldCoords( ped, 0.0, distanceToCheck, 0.0 )
            local vehicle = GetVehicleInDirection( playerPos, inFrontOfPlayer )

            if ( DoesEntityExist( vehicle ) ) then 
                SetEntityAsMissionEntity( vehicle, true, true )
                deleteCar( vehicle )

                if ( DoesEntityExist( vehicle ) ) then 
                	ShowNotification( "~r~Unable to delete vehicle, try again." )
                else 
                	ShowNotification( "Vehicle deleted." )
                end 
            else 
                ShowNotification( "You must be in or near a vehicle to delete it." )
            end 
        end 
    end 
end )

-- Delete car function borrowed frtom Mr.Scammer's model blacklist, thanks to him!
function deleteCar( entity )
    Citizen.InvokeNative( 0xEA386986E786A54F, Citizen.PointerValueIntInitialized( entity ) )
end

-- Gets a vehicle in a certain direction
-- Credit to Konijima
function GetVehicleInDirection( coordFrom, coordTo )
    local rayHandle = CastRayPointToPoint( coordFrom.x, coordFrom.y, coordFrom.z, coordTo.x, coordTo.y, coordTo.z, 10, GetPlayerPed( -1 ), 0 )
    local _, _, _, _, vehicle = GetRaycastResult( rayHandle )
    return vehicle
end

-- Shows a notification on the player's screen 
function ShowNotification( text )
    SetNotificationTextEntry( "STRING" )
    AddTextComponentString( text )
    DrawNotification( false, false )
end

Server.lua

Open me
-- Add an event handler for the 'chatMessage' event
AddEventHandler( 'chatMessage', function( source, n, msg )  
    msg = string.lower( msg )    
    -- Check to see if player has perms
    if IsPlayerAceAllowed(source, "jeremys.admin") then
    -- Check to see if a client typed in /dv
    if ( msg == "/dv" or msg == "/delveh" ) then 
    
        -- Cancel the chat message event (stop the server from posting the message)
        CancelEvent() 

        -- Trigger the client event 
        TriggerClientEvent( 'wk:deleteVehicle', source )
    end
end )

download (2.8 KB)

Ace Setup
add_ace delete jeremys.admin allow

add_principal identifier.steam:11000011d1621fe delete

1 Like

how can use for only ems, ?

(Fixed the script not working)

Can someone help me with this?How can I remove NPCs in specific place?

nice work

1 Like

Is there any (admin) script that deletes a number of vehicles?

Update 1.1.0

  • Converted __resource.lua to fxmanifest.lua
  • Removed chat message command, it nows uses RegisterCommand which triggers the wk:deleteVehicle event
  • Added a chat suggestion for the /dv command
  • Revised some of the deletion system to reduce redundant code
  • Added a timeout so if the vehicle can’t be deleted, it keeps trying until a it hits the limit or the vehicle has been deleted
  • Updated the ray trace natives, as well as using a capsule so now you don’t have to be facing a vehicle to delete it
1 Like

The issue of deleting solo sessioned cars is still being an issue. It fails after 5 attempts

What do you mean? I didn’t have any issues when I was testing it. Can you give me specifics?

I’m not sure if there’s any useful logs i can get you, we are running with onesync_distanceCullVehicles turned to true, and some vehicles are undeletable, it does say it tried 5 times but doesn’t work out.
However i have tried it with Vmenu’s delete vehicle option in the vehicle spawner and that seems to go through.

To me it feels like a onesync related issue with migration, i could be wrong.

Thanks for the info, I’ll have a look tomorrow.

Does this only work for admins or all ?

I’m looking for a script that a admin/owner/staff can do a mass dv, that deletes all vehicles? any help?

5 Likes

Everyone, but you can use ACE permissions to change it.

So for some reason we cant delet AI cars that are empty. It says failure to delete vehicle and it doesnt let us get in the vehicles to delete it.