public static int SpawnVehicle(string vehName, bool intoVehicle = true) { int vehHash = GAMEPLAY.GET_HASH_KEY(vehName); int newVec = 0; STREAMING.REQUEST_MODEL(vehHash); for (int i = 0; i < 100; i++) { if (STREAMING.HAS_MODEL_LOADED(vehHash)) { int playerPed = PLAYER.PLAYER_PED_ID(); Vector3 myCoords = GetPosition(); newVec = VEHICLE.CREATE_VEHICLE(vehHash, myCoords.X, myCoords.Y, myCoords.Z, ENTITY.GET_ENTITY_HEADING(playerPed), true, true); if (intoVehicle) { PED.SET_PED_INTO_VEHICLE(playerPed, newVec, -1); } STREAMING.SET_MODEL_AS_NO_LONGER_NEEDED(vehHash); break; } } return(newVec); }