Need help?
Create a topic in the appropriate section
Don't write everything in the chat!Take a look at the marketplace
There you can buy
everything related to game serversDon't want a ban?
Please read our rules
Don't disturb the order!Sell or buy?
Use services of the guarantor
We will make your deal safe



- 0
-
Our picks
Имеем карту ростов...
Хочется спавнить объекты через подключаемый файл
Оригинальный инит
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" ); }
Запуск.....и сервер вроде запускается,но...доходит до спавна и всё, ресет.
Самое интресно,если прописать в сам инит-всё работает.
Share this post
Link to post
Share on other sites