Помогите Ограничение вагонов

Soller

26 Сен 2021
70
1
8
10
На юмоде 8 месяцев назад предлагали такой вариант, как я понял на сервере должны были спауниться только те вагоны префабы которых указаны в плагине, и в том количестве сколько строк с префабами. Но этот плагин больше не работает.
Error while compiling: TrainWagonPopulationSettings.cs(26,49): error CS0584: Internal compiler error: Object reference not set to an instance of an object
Кто-то может его поправить, или может уже есть другой вариант ограничения вагонов?

[CODE lang="cpp" title="Код плагина"]using System.Collections.Generic;
using System.Linq;

namespace Oxide.Plugins
{
[Info("Train Wagon Population Settings", "WhiteThunder", "1.0.0")]
[Description("Allows customizing which Train Wagon prefabs spawn on the aboveground rail.")]
public class TrainWagonPopulationSettings : CovalencePlugin
{
private string[] AllowedWagonPrefabs = new string[]
{
// Instructions: Prefix each of the following lines with "//" to disable that prefab.
// Note: You will have to manually remove existing train cars that have already spawned.
"assets/content/vehicles/train/trainwagona.entity.prefab",
"assets/content/vehicles/train/trainwagonb.entity.prefab",
"assets/content/vehicles/train/trainwagonc.entity.prefab",
"assets/content/vehicles/train/trainwagond.entity.prefab",
};

private void OnServerInitialized()
{
foreach (var population in SingletonComponent<SpawnHandler>.Instance.ConvarSpawnPopulations)
{
var railPopulation = population as ConvarControlledSpawnPopulationRailRing;
if (railPopulation == null || !railPopulation.IsWagon)
continue;

var prefabList = new List<Prefab<Spawnable>>();

foreach (var prefabPath in AllowedWagonPrefabs)
{
var gameObject = GameManager.server.FindPrefab(prefabPath);
if (gameObject == null)
{
LogWarning($"Invalid prefab: {prefabPath}");
continue;
}

var spawnable = gameObject.GetComponent<Spawnable>();
if (spawnable == null)
{
LogWarning($"Prefab has no Spawnable component: {prefabPath}");
continue;
}

prefabList.Add(new Prefab<Spawnable>(prefabPath, gameObject, spawnable, GameManager.server, PrefabAttribute.server));
}

population.Prefabs = prefabList.ToArray();
population.numToSpawn = new int[population.Prefabs.Length];
}
}
}
}[/CODE]
 
Активность
Пока никто не печатает сообщение