DayZ
FurryKeidran Sep 26, 2019 @ 4:16pm
Init.c editing: changing spawn items
Basically on my private server I've added a crap ton of stuff I spawn with, just to kind of give me a good foot up when starting (canteen, gun, more food, etc). I first added clothes, backpacks, a vest, and I thought that by spawning them in first I could add more stuff, but it seems after the first few items fill up the pants inventory nothing else spawns. Is there another command I should be using instead to put items in a specific location? Like have some items in pants, some in jacket, some in backpack, etc?
Thanks,
Mark
< >
Showing 16-30 of 31 comments
surviv0r1969 Oct 28, 2020 @ 6:26am 
hi m8 so how would i start with a silenced ak, mags, scope and bullets and some food and water, vitamin tab and antibiotics, and purification tabs

with just normal clothing though

for each player that joins my server

many thanks for any help as not too clever at this stuff

doesnt have to be ak but something similar



Originally posted by Smokey:
So i've taken a more in depth look at your init.c file and this is what i'm spotting.



Originally posted by FurryKedrian:
I first added clothes, backpacks, a vest

you have the right idea with player.RemoveAllItems(); just in the wrong place ( at least i see it as being in the wrong place as you was adding items just to remove them with that ).

If you use it here instead:
EntityAI itemTop; EntityAI itemEnt; ItemBase itemBs; float rand; player.RemoveAllItems();

That will remove the random generated ones / chosen clothing.

On to the clothing you want, create a line space after removing the clothes and create your outfit in the same way as you are inventory items ( if you want the option of putting specific items into a backpack or something you will need to alter the way you create / add the items ).

Just adding clothing without the option of adding loot to a specific piece of clothing do:
player.RemoveAllItems(); itemEnt = player.GetInventory().CreateInInventory(""); itemEnt = player.GetInventory().CreateInInventory(""); itemEnt = player.GetInventory().CreateInInventory(""); itemEnt = player.GetInventory().CreateInInventory(""); itemEnt = player.GetInventory().CreateInInventory("");

To have the ability to set loot into a specific piece of clothing you will need to do:
EntityAI DEFINECLOTHINGHERE = player.GetInventory().CreateInInventory("");

so you can spawn the loot item to that location later by doing:
itemEnt = DEFINECLOTHINGHERE.GetInventory().CreateInInventory("");


Edit: I can help further if you would like just add me.
Egobyte83 Nov 17, 2020 @ 5:33pm 
Originally posted by Smokey:

Edit: I can help further if you would like just add me.


Smokey, if you want you can help me. I have never programmed in my life, but having my own DayZ server I felt I wanted to be able to adjust fresh spawn loadouts at the very least.

What I want is something that randomizes the clothes on the character from a pool of preset items that I have determined in advance. I googled a little and found commands that I believe would do the trick:

TStringArray tops = {"POSSIBLE-TOP-1","POSSIBLE-TOP-2"};
TStringArray pants = {"POSSIBLE-PANTS-1","POSSIBLE-PANTS-2"};
TStringArray shoes = {"POSSIBLE-SHOES-1","POSSIBLE-SHOES-2"};
TStringArray backpacks = {"POSSIBLE-BP-1","POSSIBLE-BP-2"};
TStringArray vests = {"POSSIBLE-VEST-1","POSSIBLE-VEST-2"};

And

EntityAI item = player.GetInventory().CreateInInventory(tops.GetRandomElement());
EntityAI item2 = player.GetInventory().CreateInInventory(pants.GetRandomElement());
EntityAI item3 = player.GetInventory().CreateInInventory(shoes.GetRandomElement());
EntityAI item4 = player.GetInventory().CreateInInventory(backpacks.GetRandomElement());
EntityAI item6 = player.GetInventory().CreateInInventory(vests.GetRandomElement());

Now, I get that the lower lines of text most likely will pull values from the upper ones; randomizing the outcome so that when a new player spawns in, he will either have whatever I put in "POSSIBLE-TOP-1 or in "POSSIBLE-TOP-2" on his chest and the same applies to the other categories.

However, I have absolutely no idea where to input these lines of text. This is my code, and as you can see, I haven't edited it much from the original one, just removed a few entries and added a couple more.



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.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);
}
}
}
}

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" );
if ( itemClothing )
{
SetRandomHealth( itemClothing );

itemEnt = itemClothing.GetInventory().CreateInInventory( "Rag" );
if ( Class.CastTo( itemBs, itemEnt ) )
itemBs.SetQuantity( 4 );

itemEnt = player.GetInventory().CreateInInventory("StoneKnife");
player.SetQuickBarEntityShortcut(itemEnt, 0);

itemEnt = player.GetInventory().CreateInInventory("Spear");
player.SetQuickBarEntityShortcut(itemEnt, 1);

itemEnt = player.GetInventory().CreateInInventory("Izh18");
SetRandomHealth(itemEnt);
player.SetQuickBarEntityShortcut(itemEnt, 2);

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

itemEnt = itemEnt.GetInventory().CreateAttachment("HandDrillKit");

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

itemEnt = player.GetInventory().CreateInInventory("Ammo_762x39");
if ( Class.CastTo( itemBs, itemEnt ) )
itemBs.SetQuantity( 10 );

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

itemEnt = player.GetInventory().CreateInInventory("Compass");
SetRandomHealth(itemEnt);

itemEnt = player.GetInventory().CreateInInventory("FurCourierBag");
}

itemClothing = player.FindAttachmentBySlotName( "Legs" );
if ( itemClothing )
SetRandomHealth( itemClothing );

itemClothing = player.FindAttachmentBySlotName( "Feet" );
if ( itemClothing )
SetRandomHealth( itemClothing );
}
};

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


Now, I don't really know what all the brackets and paragraphs and squiggly lines do. I basically just throw ♥♥♥♥ into the mix and see what sticks. ^^ I just want to know how I should build up the code so it will do what I described. Could you tell me? :)


Smokey Joe Oct 18, 2023 @ 3:04am 
bit late to the party but i hope this template can help.....



void main()
{
//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);
}
}
}
}

class CustomMission: MissionServer
{
void SetRandomHealth(EntityAI itemEnt)
{
if ( itemEnt )
{
float rndHlt = Math.RandomFloat( 0.45, 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;

player.RemoveAllItems();

ref TStringArray topsArray = {"MMG_tactical_shirt_multicamblack"};
ref TStringArray pantsArray = {"mmg_tactical_pants_multicamblack"};
ref TStringArray shoesArray = {"MMG_boots_multicamblack"};
ref TStringArray backpackArray = {"DryBag_Black"};
ref TStringArray helmArray = {"mmg_boonie_multicamblack"};
ref TStringArray handsArray = {"mmg_tactical_gloves_multicamblack"};


EntityAI item1 = player.GetInventory().CreateInInventory(topsArray.GetRandomElement());
EntityAI item2 = player.GetInventory().CreateInInventory(pantsArray.GetRandomElement());
EntityAI item3 = player.GetInventory().CreateInInventory(shoesArray.GetRandomElement());
EntityAI item4 = player.GetInventory().CreateInInventory(backpackArray.GetRandomElement());
EntityAI item5 = player.GetInventory().CreateInInventory(helmArray.GetRandomElement());
EntityAI item6 = player.GetInventory().CreateInInventory(handsArray.GetRandomElement());

itemClothing = player.FindAttachmentBySlotName( "Body" );
if ( itemClothing )
{
SetRandomHealth( itemClothing );

itemEnt = player.GetInventory().CreateInInventory("Longhorn");
player.SetQuickBarEntityShortcut(itemEnt, 1);


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

itemEnt = player.GetInventory().CreateInInventory("BandageDressing");
player.SetQuickBarEntityShortcut(itemEnt, 2);

itemEnt = player.GetInventory().CreateInInventory("Combatknife");
player.SetQuickBarEntityShortcut(itemEnt, 4);

itemEnt = player.GetInventory().CreateInInventory("RGD5Grenade");
player.SetQuickBarEntityShortcut(itemEnt, 3);


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

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









}

itemClothing = player.FindAttachmentBySlotName( "Legs" );
if ( itemClothing )
SetRandomHealth( itemClothing );

itemClothing = player.FindAttachmentBySlotName( "Feet" );
}
};

Mission CreateCustomMission(string path)
{
return new CustomMission();
}
Sebi1106 Oct 18, 2023 @ 4:43am 
Those necromancers are gaining more power by the minute!


you are soo late to the party, that the server has already closed.

I always wonder.... what the duck made you dig up a 4 year old post, and then comment this?

whats going on here?
Last edited by Sebi1106; Oct 18, 2023 @ 4:43am
baddoggs Oct 18, 2023 @ 5:40am 
Originally posted by Smokey Joe:
bit late to the party but i hope this template can help.....



void main()
{
//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);
}
}
}
}

class CustomMission: MissionServer
{
void SetRandomHealth(EntityAI itemEnt)
{
if ( itemEnt )
{
float rndHlt = Math.RandomFloat( 0.45, 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;

player.RemoveAllItems();

ref TStringArray topsArray = {"MMG_tactical_shirt_multicamblack"};
ref TStringArray pantsArray = {"mmg_tactical_pants_multicamblack"};
ref TStringArray shoesArray = {"MMG_boots_multicamblack"};
ref TStringArray backpackArray = {"DryBag_Black"};
ref TStringArray helmArray = {"mmg_boonie_multicamblack"};
ref TStringArray handsArray = {"mmg_tactical_gloves_multicamblack"};


EntityAI item1 = player.GetInventory().CreateInInventory(topsArray.GetRandomElement());
EntityAI item2 = player.GetInventory().CreateInInventory(pantsArray.GetRandomElement());
EntityAI item3 = player.GetInventory().CreateInInventory(shoesArray.GetRandomElement());
EntityAI item4 = player.GetInventory().CreateInInventory(backpackArray.GetRandomElement());
EntityAI item5 = player.GetInventory().CreateInInventory(helmArray.GetRandomElement());
EntityAI item6 = player.GetInventory().CreateInInventory(handsArray.GetRandomElement());

itemClothing = player.FindAttachmentBySlotName( "Body" );
if ( itemClothing )
{
SetRandomHealth( itemClothing );

itemEnt = player.GetInventory().CreateInInventory("Longhorn");
player.SetQuickBarEntityShortcut(itemEnt, 1);


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

itemEnt = player.GetInventory().CreateInInventory("BandageDressing");
player.SetQuickBarEntityShortcut(itemEnt, 2);

itemEnt = player.GetInventory().CreateInInventory("Combatknife");
player.SetQuickBarEntityShortcut(itemEnt, 4);

itemEnt = player.GetInventory().CreateInInventory("RGD5Grenade");
player.SetQuickBarEntityShortcut(itemEnt, 3);


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

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









}

itemClothing = player.FindAttachmentBySlotName( "Legs" );
if ( itemClothing )
SetRandomHealth( itemClothing );

itemClothing = player.FindAttachmentBySlotName( "Feet" );
}
};

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

Finally, I have waited 3 years for this.
:lunar2019deadpanpig:
Bobbles Jan 14, 2024 @ 6:22am 
@smokey, you seem to be a guru :-) il add you if ok and maybe you can assist me on custom loadout INIT.c?
Hipocrates Feb 12, 2024 @ 10:23am 
anybody knows the item code for the drummag and akm suppressor?
Hipocrates Feb 12, 2024 @ 10:23am 
and possibly the small tent?
Sim Feb 12, 2024 @ 12:56pm 
Originally posted by Hipocrates:
anybody knows the item code for the drummag and akm suppressor?

Think it's these -

"Mag_AKM_Drum75Rnd"
"AK_Suppressor"
"MediumTent"
Echoz Feb 12, 2024 @ 1:16pm 
im just here to wallow in the pain of reading non-programmers' code
<ACR> Rambo Mar 21, 2024 @ 6:46pm 
Hi just wondering if anyone can help me please? I have a deathmatch server with a few loadouts. I have them all spawning in with guns clothes etc. I have the mags spawning in the guns but you still need to reload your gun. I have seen on another deathmatch server the gun is already loaded ready to shoot without reloading the chamber. Anyone know the script that needs to be added on init.c ? Thanks in advance if anyone knows the answer to this as it has been driving me mad looking for the script. Also I don't mind sharing my init.c if anyone is looking for a PVP loadout.
_KC76_ Mar 21, 2024 @ 6:58pm 
Originally posted by <ACR> Rambo:
Hi just wondering if anyone can help me please? I have a deathmatch server with a few loadouts. I have them all spawning in with guns clothes etc. I have the mags spawning in the guns but you still need to reload your gun. I have seen on another deathmatch server the gun is already loaded ready to shoot without reloading the chamber. Anyone know the script that needs to be added on init.c ? Thanks in advance if anyone knows the answer to this as it has been driving me mad looking for the script. Also I don't mind sharing my init.c if anyone is looking for a PVP loadout.

init.c editing for Loadouts is the outdated method. With the latest game updates, you can now just write a .json file, placed in a folder called "custom" in your mission folder, and add a pointer to the folder in your cfggameplay.json, as below:

"PlayerData":
{
"disablePersonalLight": true,
"spawnGearPresetFiles": [add loadouts here],
<ACR> Rambo Mar 21, 2024 @ 8:53pm 
Ok thanks I know a little about .json, but will this then allow me to have guns fully loaded with mags and ready to shoot with a loaded chamber? i.e not pressing reload to start shooting.
Last edited by <ACR> Rambo; Mar 21, 2024 @ 8:55pm
_KC76_ Mar 21, 2024 @ 9:22pm 
Originally posted by <ACR> Rambo:
Ok thanks I know a little about .json, but will this then allow me to have guns fully loaded with mags and ready to shoot with a loaded chamber? i.e not pressing reload to start shooting.

As it is now, after that latest update, Loot weapons have a high chance of having a round chambered, so no modifications is even needed for a "chance" to have loadout weapons "loaded" .. I'd have to look at the latest code to know if they also put in an easily edited parameter, or if it is via the encrypted game code, that would require a light-weight mod.
kOnSkkIU Mar 23, 2024 @ 2:30am 
класс
< >
Showing 16-30 of 31 comments
Per page: 1530 50

Date Posted: Sep 26, 2019 @ 4:16pm
Posts: 31