I dont know if this is unique to me or if is a common issue (I searched around and couldn’t find much around google nor the fourms)
But basically attempting to store the returned object from World.CreateVehicle method in the Citizen.FX.Core causes the game to crash.
I found that just calling the method World.CreateVehicle does not cause the game to crash, then reverting back to attempting to store the Vehicle in the Vehicle object also does not cause a crash.
But if you quit the game and load again and attempt to spawn the vehicle again it does crash.
I feel like im missing something here in regards to spawning and storing a vehicle but any other tutorial or forum post i found has it either outdated or missing the World.CreateVehicle().result at the end
Below is the method/code im attempting to run, and also. due to the game crashing i’m unable to look at some logs to see if there is a Exception im missing, Any way i may look at the logs after a crash?
private async void VehicalMenuOnItemSelect(UIMenu sender, UIMenuItem item, int index)
{
switch (index)
{
case 0: await SpawnVehicle(); break;
}
}
private async Task SpawnVehicle()
{
if (Vehicle == null)
{
Vehicle = World.CreateVehicle(VehicleHash.Taxi, VehicleSpawnPoint, 0f).Result;
VehicleBlip = Vehicle.AttachBlip();
VehicleBlip.Sprite = BlipSprite.PersonalVehicleCar;
VehicleBlip.Color = BlipColor.White;
VehicleBlip.Name = "Job Vehicle";
VehicleBlip.IsShortRange = false;
}
else
{
Screen.ShowNotification("You already have a vehicle out");
VehicleBlip.IsFlashing = true;
VehicleBlip.ShowRoute = true;
}
}
Cheers in advance