RegisterNetEvent("CGC:rappel")

AddEventHandler("CGC:rappel", function()
    Citizen.CreateThread(function()
        if not IsPedInAnyHeli(GetPlayerPed(-1)) then
            TriggerEvent("chatMessage", "Error", {255, 0, 0}, "Vous n'êtes pas dans un Maverick..")
            return
        end
        
        heli = GetVehiclePedIsIn(GetPlayerPed(-1), false)
        
        if not IsVehicleModel(heli, GetHashKey("maverick")) and not IsVehicleModel(heli, GetHashKey("polmav")) then
            TriggerEvent("chatMessage", "Error", {255, 0, 0}, "Vous n'etes pas dans un Maverick.")
            return
        end
        
        if GetPedInVehicleSeat(heli, -1) == GetPlayerPed(-1) or GetPedInVehicleSeat(heli, 0) == GetPlayerPed(-1) then
            TriggerEvent("chatMessage", "Error", {255, 0, 0}, "Vous devez vous asseoir sur le coter pour le rappel.")
            return
        end
        
        TaskRappelFromHeli(GetPlayerPed(-1), 0)
    end)
end)