[Release] Automatic CarWipe

Hi šŸ‘‹, I'm LucaNL

  • :mailbox: How to reach me? Send me a message on here or LucaNL#2230 on discord.

I myself was always looking for a good working script for a carwipe every hour for example.

But I could never really find anything good, and something that actually did it well so that’s why I made this Automatic Carwipe Script.

CarWipe FiveM

A script that allows you to run a carwipe every so often (hours/minutes), this will remove all cars that no one is in to prevent lag.

Features:

  • Change time for carwipe with cron:runAt in the server.lua
  • Notifications when a carwipe is upcoming and done in config
  • Config the 10ms delay x vehicle to delete
  • Multiple delete functions so the vehicle always goes away
  • A command to manually start a carwipe if you like
  • A option to only carwipe broken vehicles
  • Delete Normal and destroyed vehicle’s
  • A option to use ESX or not
  • Not deleting if someone is driving the vehicle

Requirements

  • cron.zip (14.1 KB) - For the automatic carwipe’s every hour

Preview, Download And Install

PREVIEW
PREVIEW v1.1.1 Update

DOWNLOAD

How to install

  1. Download the recource

  2. Change the config in config.lua and take a look at the server.lua for adjustments

  3. Add this to your server.cfg:

ensure CarWipe-FiveM
  1. Restart Server.

Changelog

Changelog v1.1.1 PREVIEW v1.1.1

  A option to only carwipe broken vehicles

Changelog v1.1.0 PREVIEW v1.1.0

  Fixed some delay
  Made the config better
  Esx and not working (need to change the config)
  Can alerts set on/off
9 Likes

Preview? Screenshots?

1 Like

Today i wil post a video to preview, and get a new version out.

It would be nice if it only removes ā€œdamagedā€ vehicles and that they don’t get deleted if they are sitting on them, and also a whitelist of vehicles per job.

2 Likes

Nice idea, i wil make a damaged thing in the config so you can deside, this wil be in the next release

3 Likes

Script is awesome thank you :grin:, but I can’t get it to automatically delete vehicles not sure why, I did edit some of the script, but I just tried installing the script fresh with no changes and nothing happens once the time is reached for an automatic wipe. Hope you can help cheers!

Edit: I’ve written my own loop as workaround (works as a loop rather than specific times) which has been working fine in the meantime.

1 Like

Is forgot to mention that you need the script ā€œcronā€, you can download it now in the post above.

1 Like

@LD_Scripts Is there any way to set it, so cars with players in like a 100 m radius don’t get deleted? So, only vehicles which are not near players get deleted?

Hey, just started using your script, it’s awesome!
But is it possible to make an exception for the cars that are in the vehicles for sale table in my database?
I also use the Qalle-Sellvehicles script… what happens now is that when there is a wipe the cars that are standing for sale are also getting deleted.

Hey, Yes that is possible, just replace the client.lua with this:

ESX = nil

local blacklistedveh = {}

if Config.UseESX then
    Citizen.CreateThread(function()
        while ESX == nil do
            TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
            Citizen.Wait(10)
        end
    end)
end

exports('blacklistVeh', function(veh, bool)
    if bool then
        blacklistedveh[veh] = {
            ['veh'] = veh
        }
    else
        blacklistedveh[veh] = nil
    end
end)

RegisterNetEvent("delall")
AddEventHandler("delall", function ()
    if Config.alerts then
        TriggerEvent('chat:addMessage', {
            template = '<div style="padding: 0.5vw; margin: 0.5vw; background-color: rgba(202, 45, 45, 1); border-radius: 3px;"><i class="fas fa-car-crash"></i> {0}:<br> {1}</div>',
            args = { 'CarWipe', 'A car wipe is coming in 5 minutes. If you don\'t want your car to disappear, sit in it' }
        })
        Citizen.Wait(60000)
        TriggerEvent('chat:addMessage', {
            template = '<div style="padding: 0.5vw; margin: 0.5vw; background-color: rgba(202, 45, 45, 1); border-radius: 3px;"><i class="fas fa-car-crash"></i> {0}:<br> {1}</div>',
            args = { 'CarWipe', 'A car wipe is coming in 4 minutes. If you don\'t want your car to disappear, sit in it' }
        })
        Citizen.Wait(60000)
        TriggerEvent('chat:addMessage', {
            template = '<div style="padding: 0.5vw; margin: 0.5vw; background-color: rgba(202, 45, 45, 1); border-radius: 3px;"><i class="fas fa-car-crash"></i> {0}:<br> {1}</div>',
            args = { 'CarWipe', 'A car wipe is coming in 3 minutes. If you don\'t want your car to disappear, sit in it' }
        })
        Citizen.Wait(60000)
        TriggerEvent('chat:addMessage', {
            template = '<div style="padding: 0.5vw; margin: 0.5vw; background-color: rgba(202, 45, 45, 1); border-radius: 3px;"><i class="fas fa-car-crash"></i> {0}:<br> {1}</div>',
            args = { 'CarWipe', 'A car wipe is coming in 2 minutes. If you don\'t want your car to disappear, sit in it' }
        })
        Citizen.Wait(60000)
        TriggerEvent('chat:addMessage', {
            template = '<div style="padding: 0.5vw; margin: 0.5vw; background-color: rgba(202, 45, 45, 1); border-radius: 3px;"><i class="fas fa-car-crash"></i> {0}:<br> {1}</div>',
            args = { 'CarWipe', 'A car wipe is coming in 1 minute. If you don\'t want your car to disappear, sit in it' }
        })
        Citizen.Wait(15000)
        TriggerEvent('chat:addMessage', {
            template = '<div style="padding: 0.5vw; margin: 0.5vw; background-color: rgba(202, 45, 45, 1); border-radius: 3px;"><i class="fas fa-car-crash"></i> {0}:<br> {1}</div>',
            args = { 'CarWipe', 'A car wipe is coming in 45 seconds. If you don\'t want your car to disappear, sit in it' }
        })
        Citizen.Wait(15000)
        TriggerEvent('chat:addMessage', {
            template = '<div style="padding: 0.5vw; margin: 0.5vw; background-color: rgba(202, 45, 45, 1); border-radius: 3px;"><i class="fas fa-car-crash"></i> {0}:<br> {1}</div>',
            args = { 'CarWipe', 'A car wipe is coming in 30 seconds. If you don\'t want your car to disappear, sit in it' }
        })
        Citizen.Wait(15000)
        TriggerEvent('chat:addMessage', {
            template = '<div style="padding: 0.5vw; margin: 0.5vw; background-color: rgba(202, 45, 45, 1); border-radius: 3px;"><i class="fas fa-car-crash"></i> {0}:<br> {1}</div>',
            args = { 'CarWipe', 'A car wipe is coming in 15 seconds. If you don\'t want your car to disappear, sit in it' }
        })
        Citizen.Wait(5000)
        TriggerEvent('chat:addMessage', {
            template = '<div style="padding: 0.5vw; margin: 0.5vw; background-color: rgba(202, 45, 45, 1); border-radius: 3px;"><i class="fas fa-car-crash"></i> {0}:<br> {1}</div>',
            args = { 'CarWipe', 'A car wipe is coming in 10 seconds. If you don\'t want your car to disappear, sit in it' }
        })
        Citizen.Wait(1000)
        TriggerEvent('chat:addMessage', {
            template = '<div style="padding: 0.5vw; margin: 0.5vw; background-color: rgba(202, 45, 45, 1); border-radius: 3px;"><i class="fas fa-car-crash"></i> {0}:<br> {1}</div>',
            args = { 'CarWipe', 'A car wipe is coming in 9 seconds. If you don\'t want your car to disappear, sit in it' }
        })
        Citizen.Wait(1000)
        TriggerEvent('chat:addMessage', {
            template = '<div style="padding: 0.5vw; margin: 0.5vw; background-color: rgba(202, 45, 45, 1); border-radius: 3px;"><i class="fas fa-car-crash"></i> {0}:<br> {1}</div>',
            args = { 'CarWipe', 'A car wipe is coming in 8 seconds. If you don\'t want your car to disappear, sit in it' }
        })
        Citizen.Wait(1000) 
        TriggerEvent('chat:addMessage', {
            template = '<div style="padding: 0.5vw; margin: 0.5vw; background-color: rgba(202, 45, 45, 1); border-radius: 3px;"><i class="fas fa-car-crash"></i> {0}:<br> {1}</div>',
            args = { 'CarWipe', 'A car wipe is coming in 7 seconds. If you don\'t want your car to disappear, sit in it' }
        })
        Citizen.Wait(1000)
        TriggerEvent('chat:addMessage', {
            template = '<div style="padding: 0.5vw; margin: 0.5vw; background-color: rgba(202, 45, 45, 1); border-radius: 3px;"><i class="fas fa-car-crash"></i> {0}:<br> {1}</div>',
            args = { 'CarWipe', 'A car wipe is coming in 6 seconds. If you don\'t want your car to disappear, sit in it' }
        })
        Citizen.Wait(1000)
        TriggerEvent('chat:addMessage', {
            template = '<div style="padding: 0.5vw; margin: 0.5vw; background-color: rgba(202, 45, 45, 1); border-radius: 3px;"><i class="fas fa-car-crash"></i> {0}:<br> {1}</div>',
            args = { 'CarWipe', 'A car wipe is coming in 5 seconds. If you don\'t want your car to disappear, sit in it' }
        })
        Citizen.Wait(1000)
        TriggerEvent('chat:addMessage', {
            template = '<div style="padding: 0.5vw; margin: 0.5vw; background-color: rgba(202, 45, 45, 1); border-radius: 3px;"><i class="fas fa-car-crash"></i> {0}:<br> {1}</div>',
            args = { 'CarWipe', 'A car wipe is coming in 4 seconds. If you don\'t want your car to disappear, sit in it' }
        })
        Citizen.Wait(1000)
        TriggerEvent('chat:addMessage', {
            template = '<div style="padding: 0.5vw; margin: 0.5vw; background-color: rgba(202, 45, 45, 1); border-radius: 3px;"><i class="fas fa-car-crash"></i> {0}:<br> {1}</div>',
            args = { 'CarWipe', 'A car wipe is coming in 3 seconds. If you don\'t want your car to disappear, sit in it' }
        })
        Citizen.Wait(1000)
        TriggerEvent('chat:addMessage', {
            template = '<div style="padding: 0.5vw; margin: 0.5vw; background-color: rgba(202, 45, 45, 1); border-radius: 3px;"><i class="fas fa-car-crash"></i> {0}:<br> {1}</div>',
            args = { 'CarWipe', 'A car wipe is coming in 2 seconds. If you don\'t want your car to disappear, sit in it' }
        })
        Citizen.Wait(1000)
        TriggerEvent('chat:addMessage', {
            template = '<div style="padding: 0.5vw; margin: 0.5vw; background-color: rgba(202, 45, 45, 1); border-radius: 3px;"><i class="fas fa-car-crash"></i> {0}:<br> {1}</div>',
            args = { 'CarWipe', 'A car wipe is coming in 1 second. If you don\'t want your car to disappear, sit in it' }
        })
    end
    Citizen.Wait(1000) 
    for vehicle in EnumerateVehicles() do            
        if (not IsPedAPlayer(GetPedInVehicleSeat(vehicle, -1))) then 
            if not blacklistedveh[vehicle] then
                if Config.OnlyWipeBroken == true then
                    if GetVehicleEngineHealth(vehicle) <= 100.0 then
                        SetVehicleHasBeenOwnedByPlayer(vehicle, false) 
                        SetEntityAsMissionEntity(vehicle, false, false) 
                        DeleteVehicle(vehicle)
                        if Config.UseESX then
                            ESX.Game.DeleteVehicle(vehicle)
                        end
                        DeleteEntity(vehicle)
                        DeleteVehicle(vehicle) 
                        if Config.UseESX then
                            ESX.Game.DeleteVehicle(vehicle)
                        end
                        DeleteEntity(vehicle)
                        if (DoesEntityExist(vehicle)) then 
                            DeleteVehicle(vehicle) 
                            if Config.UseESX then
                                ESX.Game.DeleteVehicle(vehicle)
                            end
                            DeleteEntity(vehicle)
                            DeleteVehicle(vehicle)
                            if Config.UseESX then 
                                ESX.Game.DeleteVehicle(vehicle)
                            end
                            DeleteEntity(vehicle)
                        end
                    end
                else
                    SetVehicleHasBeenOwnedByPlayer(vehicle, false) 
                    SetEntityAsMissionEntity(vehicle, false, false) 
                    DeleteVehicle(vehicle)
                    if Config.UseESX then
                        ESX.Game.DeleteVehicle(vehicle)
                    end
                    DeleteEntity(vehicle)
                    DeleteVehicle(vehicle) 
                    if Config.UseESX then
                        ESX.Game.DeleteVehicle(vehicle)
                    end
                    DeleteEntity(vehicle)
                    if (DoesEntityExist(vehicle)) then 
                        DeleteVehicle(vehicle) 
                        if Config.UseESX then
                            ESX.Game.DeleteVehicle(vehicle)
                        end
                        DeleteEntity(vehicle)
                        DeleteVehicle(vehicle)
                        if Config.UseESX then 
                            ESX.Game.DeleteVehicle(vehicle)
                        end
                        DeleteEntity(vehicle)
                    end
                end
            end
            if Config.use10msdelay then
                Citizen.Wait(10)
            end
        end
    end
    if Config.DoneNotify then
        TriggerEvent('chat:addMessage', {
            template = '<div style="padding: 0.5vw; margin: 0.5vw; background-color: rgba(202, 45, 45, 1); border-radius: 3px;"><i class="fas fa-car-crash"></i> {0}:<br> {1}</div>',
            args = { 'CarWipe', 'Carwipe completed. you can leave your vehicle again (if you were in it)!' }
        })
    end
end)

If did so, replace this function in the Qalle Sellvehicles client/main.lua:

function SpawnVehicles()
    local VehPos = Config.VehiclePositions

    ESX.TriggerServerCallback("esx-qalle-sellvehicles:retrieveVehicles", function(vehicles)
        for i = 1, #vehicles, 1 do

            local vehicleProps = vehicles[i]["vehProps"]

            LoadModel(vehicleProps["model"])

            VehPos[i]["entityId"] = CreateVehicle(vehicleProps["model"], VehPos[i]["x"], VehPos[i]["y"], VehPos[i]["z"] - 0.975, VehPos[i]["h"], false)
            VehPos[i]["price"] = vehicles[i]["price"]
            VehPos[i]["owner"] = vehicles[i]["owner"]

            ESX.Game.SetVehicleProperties(VehPos[i]["entityId"], vehicleProps)

            FreezeEntityPosition(VehPos[i]["entityId"], true)

            SetEntityAsMissionEntity(VehPos[i]["entityId"], true, true)
            SetModelAsNoLongerNeeded(vehicleProps["model"])
            exports['CarWipe-FiveM']:blacklistVeh(VehPos[i]["entityId"], true) -- If changed the resource name change to your resource name else it won't work 😢
        end
    end)

end

Anyway, to add a polyzone in so it leaves cars in that zone alone

Is it possible to use okoknotify?

You can certainly do this, in the client.lua there are now the chat:message there you can redeploy the okokNotify triggerserver event with it

Can you tell me how to change the notify, I want to use txAdmin or Esx.ShowNotification

Hi, is it possible for it to not delete player owned or locked ped vehicles?

You can change the code to what you like. So you can change notify

how to auto delete for qbcore, coz im use qbcore and cant use cron script, i always manually delete veh use command

i tried to blacklist a vehicle and carwipe still ate it im trying to put my airplane on carwipe blacklist so that passengers dont fall out the sky lol