Hi Mateys,
Probably one of the simplest - yet most useful script for convoys and or groups of players wanting to move together in sync.
Just two simple commands:
/lockspeed (speed)
/unlockspeed (speed)
Just sets your max vehicle speed to whatever MPH you specify.
I’ve separated the functions out so dead easy to wack your notification system in there.
Super simple & was built in a few minutes. Hope someone else uses it as much as I do!
LockSpeed.zip (1.1 KB)
Accessible: Yes
Subscription: No
Lines: 47
Requirements: None
Support: No
2 Likes
Improved version with press button If you don’t want it, I can delete it
local function notify(message, type)
-- Add your notification system here:
-- TriggerEvent('QBCore:Notify', message, type)
end
local function isVehicleStopped(vehicle)
return GetEntitySpeed(vehicle) == 0
end
local function getVehicle()
return GetVehiclePedIsIn(PlayerPedId(), false)
end
local speedLocked = false -- Variable to track speed status
RegisterCommand('toggleSpeed', function()
local vehicle = getVehicle()
if vehicle ~= 0 then
if isVehicleStopped(vehicle) then
if speedLocked then
SetVehicleMaxSpeed(vehicle, 0.0)
notify('Speed limiter removed.', 'success')
speedLocked = false
else
local speedMPH = 50 -- Set the fixed speed here
local speedMPS = speedMPH * 0.44704
SetVehicleMaxSpeed(vehicle, speedMPS)
notify('speed up ' .. speedMPH .. ' MPH limited', 'success')
speedLocked = true
end
else
notify('Vehicle must be stationary to change the limit.', 'error')
end
else
notify('You are not in a Vehicle.', 'error')
end
end, false)
-- Fold the "K" button to turn the speed limit on/off
RegisterKeyMapping('toggleSpeed', 'Switch speed limit on/off', 'keyboard', 'K')
Yeah - nice little addition!
1 Like