[free] Limit max car speeds - category's or car names

Today i give you a simple but very effective script, we found that having 100s of cars would take a stupid amount of time to balance within the gta v speeds of things - so we came up with a very simple but a HUGE time saver of a script

What does it do?

This script allows you to hard limit any category/car within the qbcores vehicle.lua script.

Please note if your vehicle is not in that list it wont be limited, this is why we added a way to limit a car by the name and not the class.

Hope this helps someone

Github download GitHub - jamybboyjd/speedlimithard

|-------------------------------------|----------------------------|
| Code is accessible | Yes |
| Subscription-based | No |
| Lines (approximately) | 65 |
| Requirements | Qbcore |
| Support | Yes |

10 Likes

if you want text to be on screen to say the max speed of the car but this under the scripts code

– below is the text on screen you can move this
local textX = 0.015
local textY = 0.080

Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local playerPed = GetPlayerPed(-1)
if IsPedInAnyVehicle(playerPed, false) then
local vehicle = GetVehiclePedIsIn(playerPed, false)
local speed = GetEntitySpeed(vehicle) * 2.236936
local category = GetVehicleClass(vehicle)
local limit = speedLimits[category]
local name = GetDisplayNameFromVehicleModel(GetEntityModel(vehicle))
local limitByName = speedLimitsByName[name]
if limitByName then
limit = limitByName
end
if limit and speed > limit then
SetEntityMaxSpeed(vehicle, limit * 0.44704) – convert mph to m/s
else
SetEntityMaxSpeed(vehicle, 999.0) – set the default maximum speed of the vehicle here
end
DrawHudText(“~b~Max Car speed: ~w~” … tostring(math.floor(limit)) … " mph", textX, textY, 0.4)
end
end
end)

function DrawHudText(text, x, y, scale)
SetTextFont(4)
SetTextProportional(1)
SetTextScale(scale, scale)
SetTextColour(255, 255, 255, 255)
SetTextDropshadow(0, 0, 0, 0, 255)
SetTextEdge(2, 0, 0, 0, 150)
SetTextDropShadow()
SetTextOutline()
SetTextEntry(“STRING”)
AddTextComponentString(text)
DrawText(x, y)
end

1 Like

Will still have to edit the acceleration in the handling tho…

yes, so this just limits the top speed of vehicles, it does not effect the handling.lua in anyway

Why would you have to do that? The purpose of this script is to LIMIT the speed, not change the handling. Don’t get why you commented that tbh.

would there be a way to convert to KPH for the speed?

i can look into doing a update in the next few days for you

1 Like

you have missed Config.VehicleClasses in line no 57

Is it just for Qb-Core or can i Use it for ESX?

It’s STANDALONE resource you don’t need qbcore or esx to get it working its just using basic fivem api methods to manipulate the client.

I dont understand how you could add a new class…

if i i put in an spawn name of the car i want an limit on in the speedlimitsmyname it wil still get the motorcycles catagory i want all my addon cars on an different limit do you know how i can fix that?

make sure it is in the vehicles meta you are putting the name in, if it is a default, you cant do much about it I don’t think

hey I have been looking for a script to increase all vehicle speed above the capped 120mph is there any?

this one won’t - not sure if there is one, you can find edits of the handling for defaults online

Hey there, i tried to define custom speedlimits to my vanilla cars, but the script grabbed the values from the lines above, where every category is defined. If i blend them out, my custom set speedlimit does not apply to my vehicle. Screenshot is provided. Can you help me out here? Screenshot by Lightshot

try this - replace all the code with this - not tested as I don’t have a server to do so right now

local speedLimitsByName = {
[“fxxk”] = 135.0, – fxxk
}

Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local playerPed = GetPlayerPed(-1)
if IsPedInAnyVehicle(playerPed, false) then
local vehicle = GetVehiclePedIsIn(playerPed, false)
local speed = GetEntitySpeed(vehicle) * 2.236936
local name = GetDisplayNameFromVehicleModel(GetEntityModel(vehicle))
local limit = speedLimitsByName[name]
if limit then
SetEntityMaxSpeed(vehicle, limit * 0.44704)
SetTextComponentFormat(“STRING”)
AddTextComponentString(“Max Speed: " … tostring(limit) … " MPH”)
DisplayHelpTextFromStringLabel(0, 0, 1, -1)
else
SetEntityMaxSpeed(vehicle, 999.0)
end
end
end)

It sadly didn’t work, is there any chance you could try to change it?

not work for me too

you may need to remove the category that the cars are based in so it does not grab it - I will look into the code more later when I have a chance but I don’t have a lot of free time right now to dedicate