Skip to content

ABUGIZA/F4-Rental

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš— F4-Rental - Professional Car Rental System

A modern, fully-featured car rental system for FiveM servers with a beautiful UI, contract system, and automatic expiry management.

Main Interface

โœจ Features

  • ๐ŸŽจ Modern Dark UI - Beautiful, responsive interface with smooth animations
  • ๐Ÿ“‹ Digital Contracts - Usable rental contract items with all rental details
  • โฐ Automatic Expiry System - Warnings before expiry and late fee management
  • ๐Ÿš™ My Rentals Tab - Track all your active rentals in one place
  • ๐Ÿ’ฐ Flexible Pricing - Hourly-based pricing with customizable durations
  • ๐Ÿ”‘ Vehicle Keys Integration - Automatic key assignment (qb-vehiclekeys/qbx_vehiclekeys)
  • ๐Ÿ’พ Vehicle Persistence - Rented vehicles persist across reconnects
  • ๐Ÿ—บ๏ธ Return Location GPS - Automatic waypoint to return location on expiry

๐Ÿ“ธ Screenshots

Click to view screenshots

Main Rental Interface

Main Interface

My Rentals

My Rentals

Rental Contract

Contract

Expiry Warning

Warning

Return Location GPS

GPS

๐Ÿ“ฆ Dependencies

Optional

  • ox_target / qb-target / interact
  • ox_inventory / qb-inventory
  • qb-vehiclekeys / qbx_vehiclekeys

๐Ÿ› ๏ธ Installation

  1. Download the resource and place it in your resources folder

  2. Import the SQL - Run the SQL file in your database:

    -- Located in: sql/rental_history.sql
  3. Add to server.cfg:

    ensure ox_lib
    ensure oxmysql
    ensure F4-Rental
  4. Configure - Edit config.lua to customize:

    • Rental locations
    • Available vehicles
    • Rental durations
    • Pricing
    • And more...
  5. Add required item (rental_contract)

ox_inventory

Add this item to your ox_inventory items file (for example ox_inventory/data/items.lua):

['rental_contract'] = {
    label = 'Rental Contract',
    weight = 0,
    stack = false,
    consume = 0,
    close = true,
    description = 'Vehicle rental contract',
    server = {
        export = 'F4-Rental.rental_contract'
    }
},

If you renamed this resource folder, replace F4-Rental with your actual resource name.

qb-inventory / qb-core shared items

Add this item to qb-core/shared/items.lua:

['rental_contract'] = {
    ['name'] = 'rental_contract',
    ['label'] = 'Rental Contract',
    ['weight'] = 0,
    ['type'] = 'item',
    ['image'] = 'rental_contract.png',
    ['unique'] = true,
    ['useable'] = true,
    ['shouldClose'] = true,
    ['description'] = 'Vehicle rental contract'
},

โš™๏ธ Configuration

Rental Locations

Config.Locations = {
    {
        name = "Premium Rentals",
        coords = vector3(-50.0, -1090.0, 26.5),
        spawnPoint = vector4(-47.0, -1095.0, 26.5, 160.0),
        blip = { sprite = 56, color = 5, scale = 0.8 },
    },
}

Rental Durations

Config.RentalDurations = {
    { days = 1, label = "1 Hour", multiplier = 0.5, minutes = 60 },
    { days = 1, label = "3 Hours", multiplier = 0.5, minutes = 180 },
    { days = 1, label = "6 Hours", multiplier = 0.8, minutes = 360 },
    { days = 1, label = "12 Hours", multiplier = 1.0, minutes = 720 },
    { days = 1, label = "1 Day", multiplier = 1.5, minutes = 1440 },
}

Vehicles

Config.Vehicles = {
    {
        model = "sultan",
        label = "Sultan",
        manufacturer = "Karin",
        category = "Sports",
        price = 500,
        image = "https://docs.fivem.net/vehicles/sultan.webp",
        stats = { speed = 75, acceleration = 70, braking = 65, handling = 72 },
    },
}

๐Ÿ”ง Framework Support

Framework Status
QBox (qbx_core) โœ… Full Support
QBCore โœ… Full Support
ESX Legacy โœ… Full Support

๐Ÿ“ License

This resource is free to use and redistribute. Resale is not permitted.

๐Ÿ’ฌ Support

For support, please open an issue on GitHub or contact the author

๐Ÿ”ง Fixed Issues

Issue Status
Vehicle duplication after server restart โœ… Fixed
Multiple rentals bypass after disconnect โœ… Fixed
Retrieve spawning duplicate vehicles โœ… Fixed
Return not updating database โœ… Fixed

๐Ÿ†• Latest Updates (v1.1.0)

๐ŸŽฅ Update Showcase

Watch Update

โœ… Major Fixes & Improvements

Customer Reported Issues - RESOLVED

  1. DoesEntityExist Script Error (interact/sleepless_interact)

    • โœ… Fixed entity parameter validation in return vehicle event
    • โœ… Added comprehensive type checking and conversion
    • โœ… No more script errors when using target systems
  2. Rental Data Not Deleting After Return

    • โœ… Changed database operation from UPDATE to DELETE
    • โœ… Rentals now properly removed from database on return
    • โœ… Clean database without leftover rental records
  3. QBCore Callback Data Handling

    • โœ… Fixed callback bridge for QBCore framework
    • โœ… Proper data passing between client and server
    • โœ… DELETE operations now work correctly in QBCore

Late Fee System Enhancements

  • Accurate Accounting - Late fees are added only when charge succeeds
  • Retry Logic - If charge fails (insufficient funds), system retries next interval
  • ๐ŸŽฏ Smart Detection - Only charges online players
  • ๐Ÿ—‘๏ธ Auto-Cleanup - Offline expired rentals are deleted without fees

Database Management

  • ๐Ÿ—„๏ธ Clean Records - All returns now DELETE instead of UPDATE status
  • ๐Ÿš€ Better Performance - Fewer database records to query
  • ๐Ÿ“Š Accurate Tracking - Only active rentals in database

Code Quality Improvements

  • ๐Ÿ› Enhanced Debugging - Comprehensive debug logging for troubleshooting
  • โœ… Better Validation - Improved entity and data validation
  • ๐Ÿ”’ Safer Operations - Proper error handling and fallbacks

๐Ÿ“‹ Technical Changes

// Before (Old Code)
UPDATE rental_history SET status = 'returned' WHERE id = ?

// After (New Code)
DELETE FROM rental_history WHERE id = ? AND citizenid = ?

๐ŸŽฎ Player Experience

  • โœ… Smoother return process without errors
  • โœ… Clear balance warnings when going negative
  • โœ… Fair system: only online players pay late fees
  • โœ… Offline players don't accumulate charges

Demo Videos

Original Demo Latest Update


New Update (Post v1.1.0)

Core Fixes

  • Fixed proximity fallback when TargetSystem = auto and no target script is running.
  • Added return interaction registration for ox_target and qb-target.
  • Synced initial vehicle spawn to server memory/database (vehicleSpawned flow).
  • Added stale vehicle_spawned recovery to prevent blocked retrieval states.
  • Added retrieve lock/pending flow to prevent duplicate vehicle spawn race conditions.
  • Plate is now generated and saved immediately on rental creation.

Security & Validation

  • Return callbacks now validate rental vehicle proof (netId + rental state checks).
  • Auto-return event now validates player ownership, vehicle state, and return proximity.
  • QBX key grant now verifies rental ownership before giving keys.
  • Added stronger return-location enforcement when Config.ReturnAtAnyLocation = false.

Data Integrity

  • Improved spawned vehicle lifecycle sync on disconnect and reconnect.
  • Added configurable reconnect behavior via Config.RespawnOnReconnect.
  • Position save now validates ownership from database and updates reliably.
  • Rental contract item is removed on successful return/cancel cleanup paths.

Inventory & UI

  • rental_contract in ox_inventory is now handled as non-consumable on use.
  • Added per-character favorites storage in NUI (localStorage scoping).
  • Fixed contract duration display to correctly use minutes/hours.
  • Updated price rounding consistency for rental total display.

Late Fee Policy

  • Late fee total now increases only when actual money removal succeeds.
  • If charge fails, player is warned and the system retries on next interval.

Defaults / Config

  • Config.Debug default changed to false for production.

RespawnOnReconnect Demo (Enabled)

  • This demo shows the behavior when Config.RespawnOnReconnect = true.
  • If the player disconnects and reconnects, the rented vehicle respawns where it was left.

Watch RespawnOnReconnect Demo

About

Modern car rental system for FiveM with beautiful UI and contract system

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors