Hello, I can’t figure out how to fix this issue, I have written a script, but it has one small issue…
Citizen.CreateThread(function()
while true do
local sleep = 1000
local ped = PlayerPedId()
local vehicle = GetVehiclePedIsIn(ped)
if IsPedInVehicle(ped, vehicle, true) then
exports['okokNotify']:Alert("", "Norint prisisegti saugos diržą, spausk [K]!", 5000, 'info')
end
Citizen.Wait(sleep)
end
end)
This is client sided script
And it spams the notification every 1000ms, but I need it to only send it once per get in vechile…
Hello, haven’t tested it, but this should do the trick
Citizen.CreateThread(function()
local inVehicle = false
while true do
local sleep = 1000
local ped = PlayerPedId()
local vehicle = GetVehiclePedIsIn(ped)
if not inVehicle and IsPedInVehicle(ped, vehicle, true) then
inVehicle = true
exports['okokNotify']:Alert("", "Norint prisisegti saugos diržą, spausk [K]!", 5000, 'info')
elseif inVehicle then
inVehicle = false
end
Citizen.Wait(sleep)
end
end)
Citizen.CreateThread(function()
local wasInVehicle = false
while true do
local inVehicle = IsPedInAnyVehicle(PlayerPedId(), false)
if inVehicle and not wasInVehicle then
wasInVehicle = true -- Entered vehicle
exports['okokNotify']:Alert("", "Norint prisisegti saugos diržą, spausk [K]!", 5000, 'info')
elseif wasInVehicle and not inVehicle then
wasInVehicle = false -- Left vehicle
end
Citizen.Wait(1000)
end
end)
I helped someone with this in another post here → Native related too cars - #2 by DrAceMisanthrope
But the code above I tweaked to serve your needs. If it works for you, please mark this response as a solution so that others can benefit from it too. Thanks!