How do I spawn cars in NativeUI.dll and CitizenFX.Core.dll

I am trying to make custom cars spawn in this menu I am making. I have got the menu loaded and able to go through submenus and such. The issue is that none of the cars will spawn.

I have tried to troubleshoot this by adding a ‘GetUserInput’ and making an if and else statement for if it exists. I added a subtitle in the else that tells me if it does not exist at all. The thing is that when I go to test it, the subtitle doesn’t come up at all, but the car does not spawn at all. May be a terrible way of troubleshooting, but it seems like I have done something wrong for spawning the custom vehicles.

EDIT: The “i8” and the “yzfr6” are the model names and how are spawned in other similar menus

EDIT#2: Nevermind, im an idiot and I missed v = new Vehicle() and also mixed stuff around…

Important Code Below:

using System;
using System.Threading.Tasks;
using NativeUI;
using CitizenFX.Core;

public class CarsMenu : BaseScript
    {
        //Fields
        MenuPool menuPool;
        UIMenu mainMenu;
        UIMenu civ1;
        Vehicle v;
        Ped gamePed = Game.Player.Character;

        public CarsMenu()
        {
            Setup();
            C1Vehicles();
        }

       void Setup()
        {
            menuPool = new MenuPool();
            mainMenu = new UIMenu("INSPRP Cars", "SELECT AN OPTION");
            menuPool.Add(mainMenu);

            //Civilian 1 Vehicles
            civ1 = menuPool.AddSubMenu(mainMenu, "Civilian 1");

            Tick += new Func<Task>(async delegate
            {
                menuPool.ProcessMenus();
            if (Game.IsControlJustReleased(1, CitizenFX.Core.Control.MultiplayerInfo) && 
            !menuPool.IsAnyMenuOpen())
                {
                    mainMenu.Visible = !mainMenu.Visible;
                }
            });
        }

        void C1Vehicles()
        {
            UIMenuItem i8 = new UIMenuItem("2015 BMW I8");
            UIMenuItem yzfr6 = new UIMenuItem("2015 Yamaha YZF R6");
            civ1.AddItem(i8);
            civ1.AddItem(yzfr6);

            civ1.OnItemSelect += async (sender, item, index) =>
            {
                if (item == i8)
                {
                        v = await World.CreateVehicle("i8", gamePed.Position, gamePed.Heading);
                        v.PlaceOnGround();
                        gamePed.Task.WarpIntoVehicle(v, VehicleSeat.Driver);
                    }
                else if (item == yzfr6)
                {
                        v = await World.CreateVehicle("yzfr6", gamePed.Position, gamePed.Heading);
                        v.PlaceOnGround();
                        gamePed.Task.WarpIntoVehicle(v, VehicleSeat.Driver);
                    }
                }
            };
        }

Is this still an issue?

Please keep in mind that the player’s PED can change at any time. It’s safer to use it whenever needed (and use Game.PlayerPed instead). For example:

var playerPed = Game.PlayerPed;
v = await World.CreateVehicle("i8", playerPed.Position, playerPed.Heading);
v.PlaceOnGround();
playerPed.Task.WarpIntoVehicle(v, VehicleSeat.Driver);