Improve scuba gear function

I created the following snipped to enable the scuba diving animation and enhance the
underwater time limit.
The script works fine and equips the player as soon as he enters a submersible or a dinghy.
I bet the script is not effective though because it loops every 500ms and won’t ever end.
Any idea to make the loop more effective and maybe stop after entering a boat?
Does it have any effect on the server/client performance to do shitty scripting like that?

Citizen.CreateThread(function()
while true do
Citizen.Wait(500)
local ped = PlayerPedId()
local vehid = GetVehiclePedIsUsing(ped)
local vehmodel = GetEntityModel(vehid)
if vehmodel == -1066334226 or vehmodel == 771711535 or vehmodel == 1033245328 or vehmodel == 276773164 or vehmodel == 509498602 or vehmodel == 867467158 then
SetEnableScuba(ped, true)
SetPedMaxTimeUnderwater(ped, 400.00)

  end

end
end)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.