[Release] Vehicle Clean Up (UPDATED v2)


This was requested here, so I made it quickly. This script cleans up all unused vehicles automatically

Download is here

Thanks to @MarkViolla, I could improve this script alot, both in functionality and size. Now instead of having to enter a command in the console, the cars will automatically dissapear when the game thinks it doesn’t need it anymore. Also players can noclip into spawned cars to remove them too.

Installation is as usual, put it into the resources folder, then edit the AutoStartResources in your server-config.


    while true do
        car = GetVehiclePedIsIn(GetPlayerPed(-1), false)
        if car then

[Release] Scammer's Script Collection (09/03/17)
Vehicle Cleanup
[Release] Vehicle shop by Arturs
Cleaning the dusts on the cars

removing vehicles “works”, see my recent post here.

A fix for this that doesnt require modification of the natives.lua, is calling the function by its hash.

instead of



Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(vehicleID))


Oh, I’ll try it out soon. Thanks!


np gl :slight_smile:


This does actually not work


except… it does?

it’s kind of pathetic that a project ‘administrator’ claims things that do work ‘do not work’ if someone posts it as a solution.

if the client the code runs on owns said entity, this function will work fine.


It does work :stuck_out_tongue: its the same call that it makes in natives.lua


Also, chill out, no need to get spiteful


We’ve come to a semi-conclusion it only works if the vehicle you are trying to delete was created in the same resource instance.


The way he’s doing it adds any vehicle the player is in to a list and stores the vehicle ID, so it should work. The only issue as your talking about is keeping track of the vehicle IDs that have been spawned. The only issue that could arrise here is if two players get in the same vehicle, itll try to delete the vehicle from both clients and may cause errors


why are you not using SetEntityAsNoLongerNeeded after car spawn?
It is easy and simple instead this long script…Look at my Taxi Work script in release section for example.


Is it implemented in 5R? I read that this wasn’t implemented so I wasn’t sure if I could just do it that way.

Edit: Well if it’s apparently implemented I’ll do it that way then lol. Thanks!


Are you talking about SetEntityAsNoLongerNeeded?


Yeah I was talking about the SetEntityAsNoLongerNeeded


find in my taxi script line with hash of this native, to see how it works. Hash is : 0xB736A491E64A32CF


Alright, I’ll take a look at it once I’m on my PC again. Thanks!


Doesn’t want to seem to work when I add it to some of my servers get a error about a recourse or something when attempting to join the server.


Could you PM me the error you’re getting and your console log?


Script updated. Thanks to @MarkViolla for pointing out a nice native that already does this job. :smiley:


This works perfectly on cars spawned by my scripts, but when I do it on cars spawned from a trainer it don’t work.