-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.lua
27 lines (24 loc) · 894 Bytes
/
client.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
local QBCore = exports['qb-core']:GetCoreObject()
local speedLimit = nil
RegisterNetEvent('qb-speedlimit:setSpeedLimit', function(speed)
speedLimit = speed
end)
RegisterNetEvent('qb-speedlimit:enforceSpeedLimit', function(speed)
speedLimit = speed
end)
CreateThread(function()
while true do
Wait(0)
local player = PlayerPedId()
if IsPedInAnyVehicle(player, false) then
local vehicle = GetVehiclePedIsIn(player, false)
if GetPedInVehicleSeat(vehicle, -1) == player and speedLimit then
local speed = GetEntitySpeed(vehicle) * 3.6 -- Convert to km/h
if speed > speedLimit then
local newSpeed = speedLimit / 3.6 -- Convert back to m/s
SetVehicleForwardSpeed(vehicle, newSpeed)
end
end
end
end
end)