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 |
7 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
you have missed Config.VehicleClasses in line no 57
Is it just for Qb-Core or can i Use it for ESX?
I dont understand how you could add a new class…