ESX/QBCore Speedlimiter

Buy
Preview
Speedlimiter

Description: The LV_Speedlimiter script is designed to enforce speed limits for all vehicles within the game, ensuring a controlled and safe driving experience. This script is highly configurable and supports both ESX and QBCore frameworks, making it versatile and adaptable for various server setups.

Version 1.4.0

Features:

  • Framework Compatibility: Supports both ESX and QBCore frameworks, allowing seamless integration with your server’s existing setup.
  • Global Maximum Speed Setting: Added an option to enable or disable a global maximum speed (Config.EnableMaxSpeed). When enabled, all vehicles are limited to Config.MaxSpeed. When disabled, vehicles are limited based on their category (Config.CategorySpeeds).
  • Category Speed Limits: Added configuration for speed limits by vehicle category (Config.CategorySpeeds). This is used when Config.EnableMaxSpeed is set to false.
  • Exceptions: Vehicles listed in Config.Exceptions have their specific maximum speeds regardless of the global or category limits.
  • Unit Selection: Added the ability to choose between kilometers per hour (kmh) and miles per hour (mph) for speed limits (Config.SpeedUnit).
  • Player Group Ignorance: Added configuration to ignore speed limits for certain player groups, such as admins (Config.IgnoredGroups).
  • Speed Reduction Rate: Replaced Config.ReductionRate with Config.ReductionTime to set how quickly the speed should be reduced if a vehicle exceeds the speed limit.
  • Notification System:
    • Enable/Disable Notifications: Added the option to enable or disable notifications when a player enters a vehicle (Config.EnableNotification).
    • Custom Notification Event: The entire notification event can be customized in the config (Config.NotificationEvent), allowing server owners to integrate their preferred notification system.
    • Notification Message: Customizable notification text that informs players of the speed limit of the vehicle they entered (Config.NotificationText).
  • Text Display Settings: Added on-screen text display for speed limits with configurable message, duration, and color (Config.EnableTextDisplay, Config.TextDisplayMessage, Config.TextDisplayDuration, Config.TextDisplayColor).
  • Zone Configuration: Introduced zone-based speed limit management, including:
    • Enable/Disable Zones: Toggle the functionality of zones (Config.Zones.enabled).
    • Display Blips: Show or hide zone blips on the map (Config.Zones.displayBlips).
    • Blip Customization: Customize blip appearance with sprite, color, scale, and visibility settings (Config.Zones.blip).
    • Zone List: Define multiple zones with specific properties such as name, coordinates, radius, speed limit, enter/leave messages, reduction time, check interval, and display color (Config.Zones.zoneList).

Improvements:

  • Configurable Speed Units: Speed limits can now be configured in either km/h or mph, based on the server’s preference.
  • Notification Flexibility: Enhanced flexibility for notifications by allowing full customization of the notification event, message category, title, and length.
  • Performance Optimizations: Improved performance by optimizing the main thread and reducing unnecessary computations.

With these updates, the LV_Speedlimiter script provides a robust and flexible solution for managing vehicle speeds on your server, enhancing both control and realism for the players.



enter_zone

Config = {}

-- Framework: 'esx' or 'qbcore'
Config.Framework = 'esx'

-- Units for speed measurement: "kmh" or "mph"
Config.SpeedUnit = 'kmh'

-- Enable or disable the global maximum speed.
-- If true, Config.MaxSpeed is used, and Config.CategorySpeeds is ignored unless overridden by zones.
-- If false, Config.CategorySpeeds are used to define speed limits based on vehicle categories.
Config.EnableMaxSpeed = true

-- Maximum speed in km/h or mph to which vehicles are limited when Config.EnableMaxSpeed is true
Config.MaxSpeed = 200

-- Interval in milliseconds for speed checks
Config.CheckInterval = 100

-- Global reduction time in milliseconds (time to reduce speed to the limit)
Config.ReductionTime = 2000  -- 2 seconds

-- Groups to be ignored (e.g., admins)
Config.IgnoredGroups = {
    enabled = false,
    groups = {
        "admin",
        "superadmin"
    },
    -- Display a message when an ignored player enters a vehicle
    enterMessage = "No speed limit for you! XD"
}

-- Exceptions for specific vehicles (model name -> maximum speed in km/h or mph)
-- These exceptions always apply regardless of Config.EnableMaxSpeed or Config.CategorySpeeds
Config.Exceptions = {
    ["POLICE"] = 150,
    ["AMBULANCE"] = 140,
    ["ITALIRSX"] = 320
}

-- Speed limits by vehicle category (category -> maximum speed in km/h or mph)
-- Used only when Config.EnableMaxSpeed is false or when not in a zone
Config.CategorySpeeds = {
    ["compacts"] = 150,
    ["sedans"] = 160,
    ["suvs"] = 140,
    ["coupes"] = 180,
    ["muscle"] = 170,
    ["sportsclassics"] = 200,
    ["sports"] = 220,
    ["super"] = 250,
    ["motorcycles"] = 200,
    ["offroad"] = 180,
    ["industrial"] = 110,
    ["utility"] = 120,
    ["vans"] = 100,
    ["cycles"] = 50,
    ["boats"] = 80,
    ["helicopters"] = 160,
    ["planes"] = 200,
    ["service"] = 130,
    ["emergency"] = 150,
    ["military"] = 140,
    ["commercial"] = 120,
    ["trains"] = 100
}

-- Notification settings
Config.EnableNotification = true
Config.NotificationEvent = function(message)
    --TriggerEvent("SService:Client:MakeInfoNotify", 'info', 'Speed Limit', message, 5000)
    TriggerEvent('esx:showNotification', 'Speed Limit: ' .. message)
end
Config.NotificationText = 'The speed limit for this vehicle is: '

-- Text display settings for on-screen messages
Config.EnableTextDisplay = true
Config.TextDisplayMessage = 'Speed Limit: '
Config.TextDisplayDuration = 5000  -- Duration in milliseconds
Config.TextDisplayColor = { r = 255, g = 255, b = 255, a = 255 }  -- Text color (RGBA)

-- Zone configuration
Config.Zones = {
    enabled = true,  -- Enable or disable zone functionality
    displayBlips = true,  -- Display blips for zones on the map
    blip = {
        sprite = 161,      -- Blip sprite (adjust as needed)
        color = 2,         -- Blip color
        scale = 0.8,       -- Blip scaling
        shortRange = true  -- Blip visibility in short range
    },
    zoneList = {
        {
            name = "Residential Area",
            coords = vector3(197.1024, -932.1866, 30.6867),
            radius = 150.0,
            speedLimit = 120,
            enterMessage = "You have entered {name}. Speed limit: {speedLimit} km/h..",
            leaveMessage = "You have left the residential area.",
            reductionTime = 2000,
            checkInterval = 100,
            displayColor = { r = 0, g = 255, b = 0, a = 100 }
        },
        -- Add more zones as needed
    }
}

my discord
my Discord

my other works
FiveM Discord Booster
fishing
gas station
pocketbike

|-------------------------------------|----------------------------|
| Code is accessible | No only config
| Subscription-based | No
| Lines (approximately) | >340 lines
| Requirements | ESX/QBCore
| Support | Yes

What’s the difference between your script and this script?

hi,
my script offers more advanced features, including framework integration (ESX/QBCore), flexible speed configurations (global, category-based, or exceptions), customizable notifications and text displays, ignored groups, adjustable reduction rates, and specific vehicle overrides. The other script is simpler, with basic category-based speed limits and no advanced options.

I hope this answers your question well, if not please let me know.

I’m currently working on an update, then you’ll be able to adjust even more, such as certain zones with speed restrictions

Update v1.3 is out!

Update Summary: New Configuration Options

Global Reduction Time:
Added: Config.ReductionTime
Description: Specifies the time (in milliseconds) to reduce the vehicle’s speed to the limit.
Example: Config.ReductionTime = 2000 (2 seconds)

Ignored Groups Enhancements:
Added: enterMessage within Config.IgnoredGroups
Description: Displays a custom message when an ignored group member (e.g., admin) enters a vehicle.
Example:

		Config.IgnoredGroups = {
			enabled = false,
			groups = {
				"admin",
				"superadmin"
			},
			enterMessage = "No speed limit for you! XD"
		}

Zone Configuration:

Added: Comprehensive zone management with customizable speed limits and messages.
Configuration Options:
Config.Zones.enabled: Toggle zone functionality.
Config.Zones.displayBlips: Show or hide zone blips on the map.
Config.Zones.blip: Customize blip appearance (sprite, color, scale, visibility).
Config.Zones.zoneList: Define multiple zones with specific properties.
Example:

		Config.Zones = {
			enabled = true,
			displayBlips = true,
			blip = {
				sprite = 161,
				color = 2,
				scale = 0.8,
				shortRange = true
			},
			zoneList = {
				{
					name = "Residential Area",
					coords = vector3(197.1024, -932.1866, 30.6867),
					radius = 150.0,
					speedLimit = 120,
					enterMessage = "You have entered a residential area. Speed limit: 50 km/h.",
					leaveMessage = "You have left the residential area.",
					reductionTime = 2000,
					checkInterval = 100,
					displayColor = { r = 0, g = 255, b = 0, a = 100 }
				},
				-- Add more zones as needed
			}
		}

Replacement of Reduction Rate:

Changed: Replaced Config.ReductionRate with Config.ReductionTime
Description: Moves from a rate-based speed reduction to a time-based approach for smoother control.

Key Enhancements:

Enhanced Speed Management: Introduction of Config.ReductionTime and zone-specific speed limits for more precise control.
Improved User Feedback: Added on-screen text displays and enhanced notification mechanisms.
Flexible Zone Handling: Comprehensive zone configuration allows for customized speed regulations in different areas.
Administrative Controls: Ability to display custom messages for ignored groups enhances administrative flexibility.

LV_Speedlimiter 1.4 – Update

What’s new since 1.3:

Smooth decel – now uses only SetVehicleMaxSpeed; no more steering stutter.

Clean HUD – compact overlay shows the active speed limit; position/size editable in Config.HUD.

Auto-hide – vehicle-limit popup fades after x seconds (vehicleInfoDuration).

Admin bypass – server checks ACE speedlimiter.bypass or ESX group and instantly lifts the cap.

Better performance – logic ticks run only while you’re driving; CPU footprint way down.

Code tidy-up – legacy text functions & config keys removed; new utils.lua and server.lua added.

Install: drop the new files into the resource, add
add_ace group.admin speedlimiter.bypass allow
to your server.cfg – done. Enjoy the cruise!

Hands down best script out been looking for 1 for a min now finally got it​:bangbang::pray:t5::pray:t5::pray:t5::pray:t5:

1 Like