-- This example checks if the player is in a boat and if the boat is capsized.
-- Retrieve the LocalPlayer.
local playerPed = PlayerPedId()
-- Retrieve the vehicle the player is in
local vehicle = GetVehiclePedIsIn(playerPed, false)
-- Retrieve the model of the vehicle
local vehicleModel = GetEntityModel(vehicle)
-- Check if the vehicle exists in the game world.
if not DoesEntityExist(vehicle) then
-- If the vehicle does not exist, end the execution of the code here.
return
end
-- Check if the vehicle is a boat.
if not IsThisModelABoat(vehicleModel) then
-- If the vehicle is not a boat, end the execution of the code here.
return
end
-- Check if the boat is capsized.
if GetIsBoatCapsized(vehicle) then
print("The boat is capsized!")
else
print("The boat is not capsized!")
end