@Sata said in Can't spawn car using ScriptHookV.:
Also, Addon Spawner lists vehicles class names in portuguese, like my system and game are set to. The way you do it in Nuclei only returns english names, just something I noticed.
Yes - you can represent the vehicles as your language if GTA V supports it. You could update the AddVehicles() method inside your VehicleClassMenu.cs to use localized strings instead. This would support any language the game engine supports:
private void AddVehicles()
{
foreach (var vehicleHash in GTA.Vehicle.GetAllModelsOfClass(_vehicleClass).OrderBy(v => v.ToPrettyString()))
{
var localizedString = Game.GetLocalizedString((int)vehicleHash);
if (string.IsNullOrEmpty(localizedString))
{
localizedString = vehicleHash.ToPrettyString();
}
var itemSpawnVehicle = AddItem(localizedString, $"Spawn {localizedString}", () => { _vehicleSpawnerService.SpawnVehicle(vehicleHash); });
}
}
Since we've already defined a method called AddItem(string title, string description); in our MenuBase we can ofcourse use that implementation rather than the enum version
if (string.IsNullOrEmpty(localizedString))
{
localizedString = vehicleHash.ToPrettyString();
}
This line of code just reverts to the vehicleHash default if no LocalizedString exists for that particular Vehicle

Localization will be covered later in Nuclei