Перейти к публикации
Поиск в
  • Дополнительно...
Искать результаты, содержащие...
Искать результаты в...
  • Нужна помощь?

    Создайте тему в соответствующем разделе
    Не нужно писать всё в чат!
  • Загляните на торговую площадку

    Там вы можете купить
    всё что касается игровых серверов
  • Не хотите бан?

    Пожалуйста, ознакомьтесь с нашими правилами
    Не нарушайте порядок!
  • Продаёте или покупаете?

    Пользуйтесь услугами гаранта
    Мы сделаем вашу сделку безопасной
  • 0
paranoyk

Карта Ростов-спавн обьектов.

Имеем карту ростов...
Хочется спавнить объекты через подключаемый файл
Оригинальный инит
 

void main()
{
	//INIT WEATHER BEFORE ECONOMY INIT------------------------
	Weather weather = g_Game.GetWeather();

	weather.MissionWeather(false);    // false = use weather controller from Weather.c

	weather.GetOvercast().Set( Math.RandomFloatInclusive(0.02, 0.1), 1, 0);
	weather.GetRain().Set( 0, 1, 0);
	weather.GetFog().Set( 0, 1, 0);

	//INIT ECONOMY--------------------------------------
	Hive ce = CreateHive();
	if ( ce )
		ce.InitOffline();

	//DATE RESET AFTER ECONOMY INIT-------------------------
	int year, month, day, hour, minute;
	int reset_month = 8, reset_day = 10;
	GetGame().GetWorld().GetDate(year, month, day, hour, minute);

	if ((month == reset_month) && (day < reset_day))
	{
		GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
	}
	else
	{
		if ((month == reset_month + 1) && (day > reset_day))
		{
			GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
		}
		else
		{
			if ((month < reset_month) || (month > reset_month + 1))
			{
				GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
			}
		}
	}
}

class CustomMission: MissionServer
{
	void SetRandomHealth(EntityAI itemEnt)
	{
		if ( itemEnt )
		{
			float rndHlt = Math.RandomFloat( 0.25, 0.65 );
			itemEnt.SetHealth01( "", "", rndHlt );
		}
	}

	override PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)
	{
		Entity playerEnt;
		playerEnt = GetGame().CreatePlayer( identity, characterName, pos, 0, "NONE" );
		Class.CastTo( m_player, playerEnt );

		GetGame().SelectPlayer( identity, m_player );

		return m_player;
	}

	override void StartingEquipSetup(PlayerBase player, bool clothesChosen)
	{
		EntityAI itemClothing;
		EntityAI itemEnt;
		ItemBase itemBs;
		float rand;

		itemClothing = player.FindAttachmentBySlotName( "Body" );
		{
			itemEnt = player.GetInventory().CreateInInventory("Compass");

            itemEnt = player.GetInventory().CreateInInventory("SodaCan_Pipsi");
			
			itemEnt = player.GetInventory().CreateInInventory("SodaCan_Pipsi");

            itemEnt = player.GetInventory().CreateInInventory("BandageDressing");

            itemEnt = player.GetInventory().CreateInInventory("TunaCan");

            itemEnt = player.GetInventory().CreateInInventory("TunaCan");

            itemEnt = player.GetInventory().CreateInInventory("Apple");

            itemEnt = player.GetInventory().CreateInInventory("Pear");

            itemEnt = player.GetInventory().CreateInInventory("Plum");
			
			itemEnt = player.GetInventory().CreateInInventory("Chemlight_White");
			
			
		};
		if ( itemClothing )
		{
			SetRandomHealth( itemClothing );
			
			itemEnt = itemClothing.GetInventory().CreateInInventory( "TunaCan" );
						if ( Class.CastTo( itemBs, itemEnt ) )
				itemBs.SetQuantity( 4 );

			SetRandomHealth( itemEnt );

			string chemlightArray[] = { "Chemlight_White", "Chemlight_Yellow", "Chemlight_Green", "Chemlight_Red" };
			int rndIndex = Math.RandomInt( 0, 4 );
			itemEnt = itemClothing.GetInventory().CreateInInventory( chemlightArray[rndIndex] );
			SetRandomHealth( itemEnt );
		}
		
		itemClothing = player.FindAttachmentBySlotName( "Legs" );
		if ( itemClothing )
			SetRandomHealth( itemClothing );
		
		itemClothing = player.FindAttachmentBySlotName( "Feet" );
		if ( itemClothing )
			SetRandomHealth( itemClothing );
	}
};

Mission CreateCustomMission(string path)
{
	return new CustomMission();
}

Вставляю...
 

#include "$CurrentDir:\\mpmissions\\dayzoffline.chernarusplus\\@Mod\\SpawnBuilding\\Billding.c"
void main()
{
	//INIT WEATHER BEFORE ECONOMY INIT------------------------
	Weather weather = g_Game.GetWeather();

	weather.MissionWeather(false);    // false = use weather controller from Weather.c

	weather.GetOvercast().Set( Math.RandomFloatInclusive(0.02, 0.1), 1, 0);
	weather.GetRain().Set( 0, 1, 0);
	weather.GetFog().Set( 0, 1, 0);

	//INIT ECONOMY--------------------------------------
	Hive ce = CreateHive();
	if ( ce )
		ce.InitOffline();

	//DATE RESET AFTER ECONOMY INIT-------------------------
	int year, month, day, hour, minute;
	int reset_month = 8, reset_day = 10;
	GetGame().GetWorld().GetDate(year, month, day, hour, minute);

	if ((month == reset_month) && (day < reset_day))
	{
		GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
	}
	else
	{
		
		if ((month == reset_month + 1) && (day > reset_day))
		{
			GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
		}
		else
		{
			if ((month < reset_month) || (month > reset_month + 1))
			{
				GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
			}
		}
	}	
SpawnBillding();
}

class CustomMission: MissionServer
{
	void SetRandomHealth(EntityAI itemEnt)
	{
		if ( itemEnt )
		{
			float rndHlt = Math.RandomFloat( 0.25, 0.65 );
			itemEnt.SetHealth01( "", "", rndHlt );
		}
	}

	override PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)
	{
		Entity playerEnt;
		playerEnt = GetGame().CreatePlayer( identity, characterName, pos, 0, "NONE" );
		Class.CastTo( m_player, playerEnt );

		GetGame().SelectPlayer( identity, m_player );

		m_player.SetHealth("GlobalHealth", "Health", 100);
		m_player.SetHealth("GlobalHealth", "Blood", 5000);
		m_player.GetStatEnergy().Set(2500);
		m_player.GetStatWater().Set(2500);
		
		return m_player;
	}

	override void StartingEquipSetup(PlayerBase player, bool clothesChosen)
	{
		EntityAI itemClothing;
		EntityAI itemEnt;
		ItemBase itemBs;
		float rand;

		itemClothing = player.FindAttachmentBySlotName( "Body" );
		{
			itemEnt = player.GetInventory().CreateInInventory("Compass");

            itemEnt = player.GetInventory().CreateInInventory("SodaCan_Pipsi");
			
			itemEnt = player.GetInventory().CreateInInventory("SodaCan_Pipsi");

            itemEnt = player.GetInventory().CreateInInventory("BandageDressing");

            itemEnt = player.GetInventory().CreateInInventory("TunaCan");

            itemEnt = player.GetInventory().CreateInInventory("TunaCan");

            itemEnt = player.GetInventory().CreateInInventory("Apple");

            itemEnt = player.GetInventory().CreateInInventory("Pear");

            itemEnt = player.GetInventory().CreateInInventory("Plum");
			
			itemEnt = player.GetInventory().CreateInInventory("Chemlight_White");
			
			itemEnt = player.GetInventory().CreateInInventory("ChernarusMap");
			
			
		};
		if ( itemClothing )
		{
			SetRandomHealth( itemClothing );
			
			itemEnt = itemClothing.GetInventory().CreateInInventory( "TunaCan" );
						if ( Class.CastTo( itemBs, itemEnt ) )
				itemBs.SetQuantity( 4 );

			SetRandomHealth( itemEnt );

			string chemlightArray[] = { "Chemlight_White", "Chemlight_Yellow", "Chemlight_Green", "Chemlight_Red" };
			int rndIndex = Math.RandomInt( 0, 4 );
			itemEnt = itemClothing.GetInventory().CreateInInventory( chemlightArray[rndIndex] );
			SetRandomHealth( itemEnt );
		}
		
		itemClothing = player.FindAttachmentBySlotName( "Legs" );
		if ( itemClothing )
			SetRandomHealth( itemClothing );
		
		itemClothing = player.FindAttachmentBySlotName( "Feet" );
		if ( itemClothing )
			SetRandomHealth( itemClothing );
	}
};

Mission CreateCustomMission(string path)
{
	return new CustomMission();
}

В файле по стандарту
 

void SpawnObject( string type, vector position, vector orientation )
{
    auto obj = GetGame().CreateObject( type, position );
    obj.SetPosition( position );
    obj.SetOrientation( orientation );
    obj.SetOrientation( obj.GetOrientation() ); //Collision fix
    obj.Update();
    obj.SetAffectPathgraph( true, false );
    if( obj.CanAffectPathgraph() ) GetGame().GetCallQueue( CALL_CATEGORY_SYSTEM ).CallLater( GetGame().UpdatePathgraphRegionByObject, 100, false, obj );
}
void SpawnBillding()
{
//Южная военка
SpawnObject( "Land_cype_rls_chp75b_up", "7307.250000 107.082001 670.230835", "-102.000137 0.000000 0.000000" );
SpawnObject( "Land_cype_rls_chp75b", "7306.899902 103.290344 671.881775", "0.000000 0.000000 0.000000" );
SpawnObject( "Land_cype_rls_chp75b", "7076.377930 97.449661 304.293518", "-3.000004 0.000000 0.000000" );
SpawnObject( "Land_cype_rls_chp75b_up", "7076.793457 101.237999 305.878448", "109.999985 0.000000 0.000000" );
//Водяные колонки
SpawnObject( "Land_Misc_Well_Pump_Yellow", "1148.006958 163.584290 12802.907227", "0.000000 0.000000 0.000000" );
SpawnObject( "Land_Misc_Well_Pump_Blue", "1095.430298 151.472595 12697.146484", "0.000000 0.000000 0.000000" );
SpawnObject( "Land_Misc_Well_Pump_Yellow", "1281.207031 161.120956 12690.176758", "0.000000 0.000000 0.000000" );
SpawnObject( "Land_Misc_Well_Pump_Yellow", "1252.983154 154.313049 12325.052734", "0.000000 0.000000 0.000000" );
SpawnObject( "Land_Misc_Well_Pump_Yellow", "1161.082397 147.922531 12561.540039", "0.000000 0.000000 0.000000" );
}

Запуск.....и сервер вроде запускается,но...доходит до спавна и всё, ресет.
Самое интресно,если прописать в сам инит-всё работает.

Поделиться сообщением


Ссылка на сообщение
Поделиться на других сайтах

Рекомендованные сообщения

  • 0
4 минуты назад, FreddyCruger сказал:

почему же, я искренне благодарен, но ничего не правил, сразу так и закинул для поверки. В любом случае спасибо, буду разбираться

значит в кодировках дело

Поделиться сообщением


Ссылка на сообщение
Поделиться на других сайтах
MagicByte MagicByte MagicByte
  • 0

Рабочий init


 

void SpawnObject(string objectName, vector position,vector orientation)
{
    Object obj;
    obj=Object.Cast(GetGame().CreateObject(objectName, "0 0 0 "));
    obj.SetPosition(position);
    obj.SetOrientation(orientation);
    
    //Принудительное обновление колизий
    if (obj.CanAffectPathgraph())
    {
        obj.SetAffectPathgraph(true, false);
        GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(GetGame().UpdatePathgraphRegionByObject, 100, false, obj);
    }
}
#include "$CurrentDir:\\mpmissions\\Offline.rostow\\objekts\\building.c"  

void main()
{
    //INIT WEATHER BEFORE ECONOMY INIT------------------------
    Weather weather = g_Game.GetWeather();

    weather.MissionWeather(false);    // false = use weather controller from Weather.c

    weather.GetOvercast().Set( Math.RandomFloatInclusive(0.02, 0.1), 1, 0);
    weather.GetRain().Set( 0, 1, 0);
    weather.GetFog().Set( 0, 1, 0);

    //INIT ECONOMY--------------------------------------
    Hive ce = CreateHive();
    if ( ce )
        ce.InitOffline();

    //DATE RESET AFTER ECONOMY INIT-------------------------
    int year, month, day, hour, minute;
    int reset_month = 8, reset_day = 10;
    GetGame().GetWorld().GetDate(year, month, day, hour, minute);

    if ((month == reset_month) && (day < reset_day))
    {
        GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
    }
    else
    {
        if ((month == reset_month + 1) && (day > reset_day))
        {
            GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
        }
        else
        {
            if ((month < reset_month) || (month > reset_month + 1))
            {
                GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
            }
        }
    }
    
    trader();
    //keys();
}

class CustomMission: MissionServer
{
    void SetRandomHealth(EntityAI itemEnt)
    {
        if ( itemEnt )
        {
            float rndHlt = Math.RandomFloat( 0.25, 0.65 );
            itemEnt.SetHealth01( "", "", rndHlt );
        }
    }

    override PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)
    {
        Entity playerEnt;
        playerEnt = GetGame().CreatePlayer( identity, characterName, pos, 0, "NONE" );
        Class.CastTo( m_player, playerEnt );

        GetGame().SelectPlayer( identity, m_player );

        return m_player;
    }

    override void StartingEquipSetup(PlayerBase player, bool clothesChosen)
    {
        EntityAI itemClothing;
        EntityAI itemEnt;
        ItemBase itemBs;
        float rand;

        itemClothing = player.FindAttachmentBySlotName( "Body" );
        {
            itemEnt = player.GetInventory().CreateInInventory("Compass");

            itemEnt = player.GetInventory().CreateInInventory("SodaCan_Pipsi");
            
            itemEnt = player.GetInventory().CreateInInventory("SodaCan_Pipsi");

            itemEnt = player.GetInventory().CreateInInventory("BandageDressing");

            itemEnt = player.GetInventory().CreateInInventory("TunaCan");

            itemEnt = player.GetInventory().CreateInInventory("TunaCan");

            itemEnt = player.GetInventory().CreateInInventory("Apple");

            itemEnt = player.GetInventory().CreateInInventory("Pear");

            itemEnt = player.GetInventory().CreateInInventory("Plum");
            
            itemEnt = player.GetInventory().CreateInInventory("Chemlight_White");
            
            
        };
        if ( itemClothing )
        {
            SetRandomHealth( itemClothing );
            
            itemEnt = itemClothing.GetInventory().CreateInInventory( "TunaCan" );
                        if ( Class.CastTo( itemBs, itemEnt ) )
                itemBs.SetQuantity( 4 );

            SetRandomHealth( itemEnt );

            string chemlightArray[] = { "Chemlight_White", "Chemlight_Yellow", "Chemlight_Green", "Chemlight_Red" };
            int rndIndex = Math.RandomInt( 0, 4 );
            itemEnt = itemClothing.GetInventory().CreateInInventory( chemlightArray[rndIndex] );
            SetRandomHealth( itemEnt );
        }
        
        itemClothing = player.FindAttachmentBySlotName( "Legs" );
        if ( itemClothing )
            SetRandomHealth( itemClothing );
        
        itemClothing = player.FindAttachmentBySlotName( "Feet" );
        if ( itemClothing )
            SetRandomHealth( itemClothing );
    }
};

Mission CreateCustomMission(string path)
{
    return new CustomMission();
}

 

По пути Offline.rostow\\objekts\\building.c   в миссии  создаёшь папку с объектами и туда файл с объектами  building.c . 

 

может тож пригодится пример файл building.c 

 

void trader()
{
//building
SpawnObject("Land_FuelStation_Feed", "1979.135132 259.723846 10642.924805", "27.000008 -0.000000 -0.000000");
SpawnObject("Land_FuelStation_Feed_Enoch", "1975.918701 259.665009 10636.813477", "27.000008 -0.000000 -0.000000");
SpawnObject("Land_Misc_Well_Pump_Blue", "1962.483643 257.957916 10661.826172", "0.000000 -0.000000 -0.000000");
SpawnObject("Land_Power_Pole_Conc4_Lamp_Amp", "1961.715088 262.942230 10661.272461", "178.617081 0.000000 -0.000000");
SpawnObject("Land_Power_Pole_Conc4_Lamp_Amp", "1930.017334 261.782684 10674.166992", "-144.867569 0.000000 -0.000000");
SpawnObject("Land_Power_Pole_Conc4_Lamp_Amp", "1946.391113 265.448334 10622.047852", "116.999947 0.000000 -0.000000");
SpawnObject("Land_Misc_TrailRoof_Big", "1962.333496 259.580634 10657.457031", "-62.611099 0.000000 0.000000");
}

 

Изменено пользователем 123new
вставка кода в обязательный тег для его вставки (история изменений)

Поделиться сообщением


Ссылка на сообщение
Поделиться на других сайтах
  • 0

Немного дополню Eduard!
1. Строим здания в Офлайне.
2. Размещаем файл на сервере. Я размещаю в отдельной папке
2. В начале файла init прописываем так
 

void SpawnObject(string objectName, vector position,vector orientation)
{
	Object obj;
	obj=Object.Cast(GetGame().CreateObject(objectName, "0 0 0 "));
	obj.SetPosition(position);
	obj.SetOrientation(orientation);
	
	//Принудительное обновление колизий
	if (obj.CanAffectPathgraph())
	{
		obj.SetAffectPathgraph(true, false);
		GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(GetGame().UpdatePathgraphRegionByObject, 100, false, obj);
	}
}

3. Ниже прописываем путь до файла
#include "$CurrentDir:\\mpmissions\\dayzOffline.chernarusplus\\custom\\ВАШ ФАЙЛ.c"    
4. Также указываем в данном месте ПОСТРОЙКУ 
 

void main()
{
	new US_PreHive();
	//INIT WEATHER BEFORE ECONOMY INIT------------------------
	Weather weather = g_Game.GetWeather();

	weather.MissionWeather(false);    // false = use weather controller from Weather.c

	weather.GetOvercast().Set( Math.RandomFloatInclusive(0.4, 0.6), 1, 0);
	weather.GetRain().Set( 0, 0, 1);
	weather.GetFog().Set( Math.RandomFloatInclusive(0.05, 0.1), 1, 0);

	//INIT ECONOMY--------------------------------------
	Hive ce = CreateHive();
	if ( ce )
		ce.InitOffline();

	//DATE RESET AFTER ECONOMY INIT-------------------------
	int year, month, day, hour, minute;
	int reset_month = 9, reset_day = 20;
	GetGame().GetWorld().GetDate(year, month, day, hour, minute);

	if ((month == reset_month) && (day < reset_day))
	{
		GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
	}
	else
	{
		if ((month == reset_month + 1) && (day > reset_day))
		{
			GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
		}
		else
		{
			if ((month < reset_month) || (month > reset_month + 1))
			{
				GetGame().GetWorld().SetDate(year, reset_month, reset_day, hour, minute);
			}
		}
	}
	ВАША ПОСТРОЙКА();
}

И все!!))
Если это ванильная постройка и необходимо разместить в ней лут то смотрим это 

 

Поделиться сообщением


Ссылка на сообщение
Поделиться на других сайтах

Создайте аккаунт или войдите в него для комментирования

Вы должны быть пользователем, чтобы оставить комментарий

Создать аккаунт

Зарегистрируйтесь для получения аккаунта. Это просто!

Зарегистрировать аккаунт

Войти

Уже зарегистрированы? Войдите здесь.

Войти сейчас

×
×
  • Создать...

Важная информация

Используя этот сайт, вы автоматически обязуетесь соблюдать наши Правила и Политика конфиденциальности.
Чтобы сделать этот веб-сайт лучше, мы разместили cookies на вашем устройстве. Вы можете изменить свои настройки cookies, в противном случае мы будем считать, что вы согласны с этим.

Поддержка