Подскажите, как правильно привязать сеты для дефолтных игроков к конкретным точкам спавна? Раздавать шмот по ID или дефолт всем остальным выдать я понял как. Хотелось бы что бы игрок спавнился в милицейской форме возле полиции или охотником но возле вышки, например. Вот такой код у меня, и игрок появляется на берегу в ванильном наряде. Что я делаю не так?
class StartSetsPlayersConfig
{
void StartSetsPlayer(PlayerBase player,int use_set_id)
{
EntityAI itemCreated = NULL;
EntityAI itemCreated1 = NULL;
ItemBase itemCasted = NULL;
switch( use_set_id ) //Раздаем лут (можно использовать значения от 1 и выше, только не 0 и не -1)
{
case 1: //AKSU-74 set
{
My_Custom_Spawn_Parameters.RemoveAllItems(player); // Чтобы удалить с персонажа уже имеющиеся стандартные стартовые шмотки раскомментировать строку
itemCreated = player.GetInventory().CreateInInventory("SmershVest"); // Выдаем рюкзак и записываем в переменную itemCreated
if (itemCreated) // Проверяем, создался ли рюкзак. Если он создался, переменная itemCreated будет не пуста и проверка пройдет
{
SetRandomHealthItem(itemCreated); // Выдаем рюкзаку рандомное качество
itemCreated1 = itemCreated.GetInventory().CreateInInventory("SlicedPumpkin"); // Добавляем в инвентарь созданного рюкзака яблоко и записываем в переменную itemCreated1
if (itemCreated1) // Проверяем, создалось ли яблоко в рюкзаке, яблоко у нас с переменной itemCreated1
{
SetRandomHealthItem(itemCreated1); // Выдаем яблоку рандомное качество
}
itemCreated1 = NULL; // Обнуляем значение переменной после работы с ней, чтобы следующая проверка прошла корректно
itemCreated1 = itemCreated.GetInventory().CreateInInventory("BandageDressing"); // Выдаем игроку бинты в рюкзак и записываем в переменную itemCreated1
if (itemCreated1) // Проверяем, создались ли бинты в рюкзаке, они у нас с переменной itemCreated1
{
itemCasted = ItemBase.Cast(itemCreated1); // Выполняем преобразование в другой класс для работы с нужной нам функцией, поскольку в классе EntityAI нет нужной нам функции SetQuantity, а в подклассе ItemBase она есть. Предмет при этом так и остается один и тот же!
itemCasted.SetQuantity(2); // Определяем количество для созданных бинтов как 2 штуки
SetRandomHealthItem(itemCreated); // Выдаем бинтам рандомное качество, функция работает с классом EntityAI (см. в конфе файла)
}
}
// переменную itemCreated не обнуляем далее, поскольку мы ее не используем в проверке ниже.
itemCreated = player.GetInventory().CreateInInventory("CargoPants_Green"); // Выдаем игроку штаны
itemCreated = player.GetInventory().CreateInInventory("M65Jacket_VivalaRevolution"); // Выдаем игроку куртку
itemCreated = player.GetInventory().CreateInInventory("JungleBoots_Green"); // Выдаем игроку обувь
itemCreated = player.GetInventory().CreateInInventory("TacticalGloves_Green"); // Выдаем игроку перчатки
itemCreated = player.GetInventory().CreateInInventory("Mich2001Helmet"); // Выдаем игроку шляпу
//itemCasted = ItemBase.Cast(itemCreated); // Строка не нужна, закоментирована. используется для изменения класса EntityAI в ItemBase (чтобы нужные операции были доступны)
itemCreated = player.GetInventory().CreateInInventory("HuntingKnife"); // Выдаем игроку ножик в любой свободный слот в инвентаре
itemCreated = player.GetInventory().CreateInInventory("WaterBottle"); // Выдаем игроку в любой свободный слот в инвентаре
itemCreated = player.GetInventory().CreateInInventory("TacticalBaconCan"); // Выдаем игроку в любой свободный слот в инвентаре
itemCreated = player.GetInventory().CreateInInventory("ChernarusMap"); // Выдаем игроку в любой свободный слот в инвентаре
itemCreated = player.GetInventory().CreateInInventory("Matchbox"); // Выдаем игроку в любой свободный слот в инвентаре
itemCreated = player.GetInventory().CreateInInventory("Mag_AK74_30Rnd_Green"); // Выдаем игроку магазины
itemCreated = player.GetInventory().CreateInInventory("AmmoBox_545x39_20Rnd"); // Выдаем игроку
itemCreated = NULL; // Обнуляем значение переменной после работы с ней, нужно если мы будем использовать ее далее
itemCreated = player.GetHumanInventory().CreateInHands("AKS74U"); // Выдаем игроку в руки
if (itemCreated) // Проверяем, создался ли
{
itemCreated.GetInventory().CreateAttachment( "AKS74U_Bttstck" ); // Выдаем игроку оптику и крепим
}
break;
}
case 2: //Set with number 2 (Сет с номером 2)
{
break;
}
case 3: //Set with number 3 (Сет с номером 3)
{
break;
}
case 4: //Set with number 4 (Сет с номером 4)
{
break;
}
case 5: //Set with number 5 (Сет с номером 5)
{
break;
}
case 6: //Set with number 6 (Сет с номером 6)
{
break;
}
default: //Default starting spawn set (Сет поумолчанию для всех игроков, если хотите назначить - добавляйте здесь!)
{
break;
}
}
}
void DefaultSets(PlayerBase player) // Функция выдает сеты игрокам, не прописанным в конфигурации скрипта!!!
{
EntityAI itemCreated = NULL;
EntityAI itemCreated1 = NULL;
ItemBase itemCasted = NULL;
private int random_set_number = Math.RandomIntInclusive(1,2);
switch( random_set_number )
{
case 1: //Police Man
{
private array <vector> spawnpoints = {"3559.69 0 2443.59"};
private vector selected_spawnpoint = spawnpoints.GetRandomElement();
player.SetPosition(selected_spawnpoint);
My_Custom_Spawn_Parameters.RemoveAllItems(player);
DefaultSets(player);
itemCreated = player.GetInventory().CreateInInventory("ChildBag_Blue");
if (itemCreated)
{
SetRandomHealthItem(itemCreated);
itemCreated1 = itemCreated.GetInventory().CreateInInventory("Pear");
if (itemCreated1)
{
SetRandomHealthItem(itemCreated1);
}
itemCreated1 = NULL;
itemCreated1 = itemCreated.GetInventory().CreateInInventory("Rag");
if (itemCreated1)
{
itemCasted = ItemBase.Cast(itemCreated1);
itemCasted.SetQuantity(4);
SetRandomHealthItem(itemCreated);
}
}
itemCreated = player.GetInventory().CreateInInventory("PolicePants");
itemCreated = player.GetInventory().CreateInInventory("PoliceJacket");
itemCreated = player.GetInventory().CreateInInventory("WorkingBoots_Black");
itemCreated = player.GetInventory().CreateInInventory("OMNOGloves_Gray");
itemCreated = player.GetInventory().CreateInInventory("PoliceCap");
//itemCasted = ItemBase.Cast(itemCreated);
itemCreated = player.GetInventory().CreateInInventory("CombatKnife");
itemCreated = player.GetInventory().CreateInInventory("WaterBottle");
itemCreated = player.GetInventory().CreateInInventory("SpaghettiCan");
itemCreated = player.GetInventory().CreateInInventory("ChernarusMap");
itemCreated = player.GetInventory().CreateInInventory("Matchbox");
itemCreated = player.GetInventory().CreateInInventory("AmmoBox_12gaSlug_10Rnd");
itemCreated = player.GetInventory().CreateInInventory("AmmoBox_12gaSlug_10Rnd");
itemCreated = player.GetInventory().CreateInInventory("AmmoBox_00buck_10rnd");
itemCreated = NULL;
itemCreated = player.GetHumanInventory().CreateInHands("Izh43Shotgun");
if (itemCreated)
{
//itemCreated.GetInventory().CreateAttachment( "HuntingOptic" );
}
break;
}
case 2: // Hunter
{
break;
}
default: //Default starting spawn set (Сет поумолчанию для всех игроков, в случае если ни один из сетов выше не выпал.
{
//My_Custom_Spawn_Parameters.RemoveAllItems(player); // Чтобы удалить с персонажа уже имеющиеся стандартные стартовые шмотки раскомментировать строку
break;
}
}
}
}