Overview
This script prevents vehicles that have been used by a player from despawning while automatically cleaning up abandoned vehicles after a configurable period of inactivity. It ensures only vehicles that have been driven by players are tracked, preventing random parked AI vehicles from being affected.
This project uses a custom license Do not redistribute or modify without permission. (See Github for details)
Key Features
Smart Vehicle Registration
- Only tracks player-driven vehicles – A vehicle is registered when:
- A player enters it as a driver
- A player spawns it and interacts with it
- Does NOT track:
- AI/parked vehicles
- Vehicles never entered by a player
Automatic Cleanup with Warnings
- Configurable idle timer (default: 30 mins)
- Vehicles untouched for the full duration are removed
- Warning messages (customizable intervals):
- 2 mins, 1 min, and 30 sec warnings before cleanup
- Only the vehicle owner sees warnings (not global spam)
Manual Admin Control
/cleanupvehicles
command- Forces immediate cleanup of all inactive vehicles
- Requires ACE permission (
command.cleanupvehicles
)
Performance Optimised
- Low-impact server checks (every 30 sec by default)
- Distance-based occupancy checks (50m radius)
- No residual memory leaks – Cleanly removes tracked vehicles
How It Works
Vehicle Tracking Logic
- A vehicle is registered only when a player enters it (client-side detection).
- The server tracks:
- Owner (who spawned/used it)
- Last used time (resets if any player enters)
- Warning status (ensures no duplicate warnings)
Cleanup Process
- Checks every 30 seconds for inactive vehicles.
- If a vehicle is unoccupied for 30 mins:
- Sits through warning phases (2m, 1m, 30s).
- Deletes only if still unused after the full timer.
- Active vehicles reset the timer – even brief use extends their life.
Admin Command
/cleanupvehicles
→ Instantly removes all vehicles meeting idle criteria.- Permission-restricted (adjustable in config).
For more FiveM scripts, tutorials, and server tips, visit our website and join our community of server owners and developers. Let’s build the ultimate roleplay experience together!
Reviews
There are no reviews yet.