I started to create a tiny Mod for GTA V, but I haven't found many Tutorials. The Mod is supposed to spawn a stretch-limo with a driver. When the limo is near me, I can enter the backseat with F-key and the driver will drive me to a waypoint.
At the moment, the vehicle and a driver are spawning when I press Num1. The Driver gets into the car and drives towards me. I tried to get into the backseat by doing
if (Game.Player.Character.GetVehicleIsTryingToEnter() == stretch && isEnteringCar == false)
{
isEnteringCar = true;
Game.Player.Character.Task.EnterVehicle(stretch, VehicleSeat.RightRear);
isEnteringCar = false;
}
stretch is the object name for the limo I am spawning. "isEnteringCar" is a bool I've added, so the if, statement will only get executed once while entering the car. This if-statement is located in my onTick()-Method which gets executed every tick (obviously). But when I press F near my limo, my character gets stuck in some kind of infinite loop, even tho I tried to prevent that with my bool "isEnteringCar". The "Open Door"-Animation gets resetted every tick, therefore my character just wiggles around until I despawn the limo again.
So long story short:
When I press "F" to enter a spawned Limousine, a bool "IsEnteringCar" is set to true, so that the method Game.Player.Character.Task.EnterVehicle(stretch, VehicleSeat.RightRear);
won't get executed multiple times. When I have successfully entered the vehicle, the bool gets set back to false, so I can enter the car again after getting out. But when I try to enter the car my character is stuck in the EnterVehicle()-Method, probably cause it interferes with the GTA-Code that makes me enter the vehicle at the driver seat. How can I disable the "Enter car at driver seat"-Part?