DayZ
Custom Player Load outs
would like to start a server with different roles for different players. How do I make custom load out for each individual player?
< >
Showing 1-3 of 3 comments
Terd Oct 24, 2022 @ 10:14am 
After attempting this myself several times there are only 2 ways I have gotten this to work consistently: (sorry for my attempt at being brief, this explaination I may make a video for) -- 1st way uses vanilla init.c file, 2nd way uses DayZ Expansion AI Loadouts (more complicated but unlimited options) -

1st way is easiest but only randomizes starting Kits for Weapons or gear you want to list specific (tripwire, frags, mags) which the gear is auto dropped into whatever base character gear your server has set. If you go to -- " Your drive letter here :\Steam\steamapps\common\DayZServer\mpmissions\dayzOffline.chernarusplus" You will see the Init.C file, this is where you set the random loadouts.
Here's mine for an example, these are random at fresh spawn -
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

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

return m_player;
}

void addMags(PlayerBase player, string mag_type, int count)
{
if (count < 1)
return;

EntityAI mag;

for (int i = 0; i < count; i++) {
mag = player.GetInventory().CreateInInventory(mag_type);
}

}

EntityAI assaultClass(PlayerBase player)
{
EntityAI gun = player.GetHumanInventory().CreateInHands("M4A1_Green");
gun.GetInventory().CreateAttachment("GhillieAtt_Woodland");
gun.GetInventory().CreateAttachment("M4_RISHndgrd_Black");
gun.GetInventory().CreateAttachment("M4_MPBttstck_Black");
gun.GetInventory().CreateAttachment("M68Optic");
gun.GetInventory().CreateAttachment("M4_Suppressor");
gun.GetInventory().CreateAttachment("UniversalLight");
gun.GetInventory().CreateAttachment("Mag_STANAG_30Rnd");
addMags(player, "Mag_STANAG_30Rnd", 6);

EntityAI backup = player.GetInventory().CreateInInventory("Mp133Shotgun");
backup.GetInventory().CreateAttachment("FNP45_MRDSOptic");

player.GetInventory().CreateInInventory("Roadflare");
player.GetInventory().CreateInInventory("Roadflare");
player.GetInventory().CreateInInventory("Roadflare");
player.GetInventory().CreateInInventory("Roadflare");
player.GetInventory().CreateInInventory("Roadflare");
player.GetInventory().CreateInInventory("M18SmokeGrenade_Purple");
player.GetInventory().CreateInInventory("M18SmokeGrenade_Yellow");
player.GetInventory().CreateInInventory("M67Grenade");
player.GetInventory().CreateInInventory("M67Grenade");
player.GetInventory().CreateInInventory("M67Grenade");
player.GetInventory().CreateInInventory("M67Grenade");
player.GetInventory().CreateInInventory("TripwireTrap");
player.GetInventory().CreateInInventory("TripwireTrap");
player.GetInventory().CreateInInventory("TripwireTrap");
player.GetInventory().CreateInInventory("TripwireTrap");
player.GetInventory().CreateInInventory("AmmoBox_00buck_10rnd");
player.GetInventory().CreateInInventory("AmmoBox_00buck_10rnd");
player.GetInventory().CreateInInventory("Ammo_12gaSlug");
player.GetInventory().CreateInInventory("Ammo_12gaSlug");

return gun;

}

EntityAI sniperClass(PlayerBase player)
{
EntityAI gun = player.GetHumanInventory().CreateInHands("ussr_m200");
gun.GetInventory().CreateAttachment("M200Optic");
gun.GetInventory().CreateAttachment("M200Suppressor");
gun.GetInventory().CreateAttachment("Mag_ussrm200_7Rnd");
gun.GetInventory().CreateAttachment("GhillieAtt_Mossy");
addMags(player, "Mag_ussrm200_7Rnd", 2);

EntityAI backup = player.GetInventory().CreateInInventory("CZ61");
backup.GetInventory().CreateAttachment("PistolSuppressor");
backup.GetInventory().CreateAttachment("Mag_CZ61_20Rnd");
addMags(player, "Mag_CZ61_20Rnd", 2);

player.GetInventory().CreateInInventory("Flaregun");
player.GetInventory().CreateInInventory("GhillieHood_Mossy");
player.GetInventory().CreateInInventory("GhillieSuit_Mossy");
player.GetInventory().CreateInInventory("ChernarusMap");
player.GetInventory().CreateInInventory("TripwireTrap");
player.GetInventory().CreateInInventory("TripwireTrap");
player.GetInventory().CreateInInventory("Ammo_408cheytac");
player.GetInventory().CreateInInventory("Ammo_FlareRed");
player.GetInventory().CreateInInventory("Ammo_FlareRed");
player.GetInventory().CreateInInventory("Ammo_FlareRed");

return gun;

}

EntityAI smgClass(PlayerBase player)
{
EntityAI gun = player.GetHumanInventory().CreateInHands("UMP45");
gun.GetInventory().CreateAttachment("PistolSuppressor");
gun.GetInventory().CreateAttachment("ReflexOptic");
gun.GetInventory().CreateAttachment("UniversalLight");
gun.GetInventory().CreateAttachment("Mag_UMP_25Rnd");
addMags(player, "Mag_UMP_25Rnd", 6);

EntityAI backup = player.GetInventory().CreateInInventory("M79");
backup.GetInventory().CreateAttachment("Ammo_40mm_Explosive");
addMags(player, "Ammo_40mm_Explosive", 6);

player.GetInventory().CreateInInventory("Ammo_40mm_Smoke_Green");
player.GetInventory().CreateInInventory("Ammo_40mm_Smoke_White");
player.GetInventory().CreateInInventory("Ammo_40mm_Smoke_Black");
player.GetInventory().CreateInInventory("Ammo_40mm_Explosive");
player.GetInventory().CreateInInventory("Ammo_40mm_Explosive");
player.GetInventory().CreateInInventory("Ammo_40mm_Explosive");
player.GetInventory().CreateInInventory("Ammo_40mm_Explosive");
player.GetInventory().CreateInInventory("Ammo_40mm_Chemgas");
player.GetInventory().CreateInInventory("Ammo_40mm_Chemgas");
player.GetInventory().CreateInInventory("Ammo_40mm_Chemgas");


return gun;

}

EntityAI shotgnClass(PlayerBase player)
{
EntityAI gun = player.GetHumanInventory().CreateInHands("Saiga");
gun.GetInventory().CreateAttachment("KobraOptic");
gun.GetInventory().CreateAttachment("Saiga_Bttstck");
gun.GetInventory().CreateAttachment("UniversalLight");
gun.GetInventory().CreateAttachment("GhillieAtt_Tan");
gun.GetInventory().CreateAttachment("Mag_Saiga_Drum20Rnd");
addMags(player, "Mag_Saiga_Drum20Rnd", 4);

EntityAI backup = player.GetInventory().CreateInInventory("SawedoffMosin9130_Camo");
backup.GetInventory().CreateAttachment("PUScopeOptic");
addMags(player, "Ammo_762x54", 3);


player.GetInventory().CreateInInventory("RemoteDetonator");
player.GetInventory().CreateInInventory("Plastic_Explosive");
player.GetInventory().CreateInInventory("RemoteDetonator");
player.GetInventory().CreateInInventory("Plastic_Explosive");
player.GetInventory().CreateInInventory("RemoteDetonator");
player.GetInventory().CreateInInventory("Plastic_Explosive");
player.GetInventory().CreateInInventory("RemoteDetonator");
player.GetInventory().CreateInInventory("Plastic_Explosive");

return gun;

}

EntityAI mgClass(PlayerBase player)
{
EntityAI gun = player.GetHumanInventory().CreateInHands("FAL");
gun.GetInventory().CreateAttachment("Fal_FoldingBttstck");
gun.GetInventory().CreateAttachment("GhillieAtt_Mossy");
gun.GetInventory().CreateAttachment("Mag_FAL_20Rnd");
gun.GetInventory().CreateAttachment("ACOGOptic");
gun.GetInventory().CreateAttachment("UniversalLight");
addMags(player, "Mag_FAL_20Rnd", 6);

EntityAI backup = player.GetInventory().CreateInInventory("SawedoffIzh43Shotgun");

player.GetInventory().CreateInInventory("LandMineTrap");
player.GetInventory().CreateInInventory("LandMineTrap");
player.GetInventory().CreateInInventory("LandMineTrap");
player.GetInventory().CreateInInventory("AmmoBox_00buck_10rnd");
player.GetInventory().CreateInInventory("AmmoBox_00buck_10rnd");
player.GetInventory().CreateInInventory("AmmoBox_00buck_10rnd");

return gun;


}


EntityAI scoutClass(PlayerBase player)
{
EntityAI gun = player.GetHumanInventory().CreateInHands("Winchester70");
gun.GetInventory().CreateAttachment("HuntingOptic");
gun.GetInventory().CreateAttachment("GhillieAtt_Woodland");
gun.GetInventory().CreateAttachment("ImprovisedSuppressor");
addMags(player, "Ammo_308Win", 6);

EntityAI backup = player.GetInventory().CreateInInventory("MP5K");
backup.GetInventory().CreateAttachment("ReflexOptic");
backup.GetInventory().CreateAttachment("MP5_Compensator");
backup.GetInventory().CreateAttachment("MP5_RailHndgrd");
backup.GetInventory().CreateAttachment("UniversalLight");
backup.GetInventory().CreateAttachment("Mag_MP5_30Rnd");
addMags(player, "Mag_MP5_30Rnd", 3);

player.GetInventory().CreateInInventory("M18SmokeGrenade_Green");
player.GetInventory().CreateInInventory("Flaregun");
player.GetInventory().CreateInInventory("GhillieSuit_Woodland");
player.GetInventory().CreateInInventory("GhillieHood_Woodland");
player.GetInventory().CreateInInventory("ChernarusMap");
player.GetInventory().CreateInInventory("ImprovisedSuppressor");

player.GetInventory().CreateInInventory("Ammo_308WinTracer");
player.GetInventory().CreateInInventory("Ammo_308WinTracer");
player.GetInventory().CreateInInventory("Ammo_308Win");
player.GetInventory().CreateInInventory("Ammo_FlareBlue");
player.GetInventory().CreateInInventory("Ammo_FlareGreen");
player.GetInventory().CreateInInventory("Ammo_FlareRed");
player.GetInventory().CreateInInventory("Ammo_FlareBlue");
player.GetInventory().CreateInInventory("Ammo_FlareGreen");
player.GetInventory().CreateInInventory("Ammo_FlareRed");
player.GetInventory().CreateInInventory("TripwireTrap");
player.GetInventory().CreateInInventory("TripwireTrap");
return gun;

}



override void StartingEquipSetup(PlayerBase player, bool clothesChosen)
{
player.RemoveAllItems();

player.GetInventory().CreateInInventory("MilitaryBelt");
player.GetInventory().CreateInInventory("NylonKnifeSheath");
player.GetInventory().CreateInInventory("PlateCarrierHolster");
player.GetInventory().CreateInInventory("Canteen");
player.GetInventory().CreateInInventory("CombatKnife");
player.GetInventory().CreateInInventory("UKAssVest_Camo");
player.GetInventory().CreateInInventory("M67Grenade");
player.GetInventory().CreateInInventory("M67Grenade");
player.GetInventory().CreateInInventory("FlashGrenade");
player.GetInventory().CreateInInventory("M18SmokeGrenade_Red");
player.GetInventory().CreateInInventory("BandageDressing");
player.GetInventory().CreateInInventory("OrienteeringCompass");
player.GetInventory().CreateInInventory("Rangefinder");
player.GetInventory().CreateInInventory("Battery9V");
player.GetInventory().CreateInInventory("Battery9V");
player.GetInventory().CreateInInventory("Battery9V");
player.GetInventory().CreateInInventory("Battery9V");
player.GetInventory().CreateInInventory("Battery9V");
player.GetInventory().CreateInInventory("AssaultBag_Green");
player.GetInventory().CreateInInventory("NVGHeadstrap");

player.GetInventory().CreateInInventory("NVGoggles");
player.GetInventory().CreateInInventory("TTSKOPants");
player.GetInventory().CreateInInventory("TTsKOJacket_Camo");
player.GetInventory().CreateInInventory("CombatBoots_Black");
player.GetInventory().CreateInInventory("BoonieHat_Flecktran");
player.GetInventory().CreateInInventory("TacticalGloves_Green");
player.GetInventory().CreateInInventory("TacticalBaconCan");
player.GetInventory().CreateInInventory("PersonalRadio");
player.GetInventory().CreateInInventory("CanOpener");
player.GetInventory().CreateInInventory("BalaclavaMask_Beige");
player.GetInventory().CreateInInventory("Chemlight_Red");
player.GetInventory().CreateInInventory("Chemlight_Blue");
player.GetInventory().CreateInInventory("Chemlight_Green");
player.GetInventory().CreateInInventory("Mich2001Helmet");
player.GetInventory().CreateInInventory("UniversalLight");


EntityAI secondary;
EntityAI pistol = player.GetInventory().CreateInInventory("CZ75");
pistol.GetInventory().CreateAttachment("PistolSuppressor");
pistol.GetInventory().CreateAttachment("Mag_CZ75_15Rnd");
pistol.GetInventory().CreateAttachment("TLRLight");
addMags(player, "Mag_CZ75_15Rnd", 2);

EntityAI primary;

switch (Math.RandomInt(0, 6)) {
case 0: primary = assaultClass(player); break;
case 1: primary = sniperClass(player); break;
case 2: primary = smgClass(player); break;
case 3: primary = shotgnClass(player); break;
case 4: primary = mgClass(player); break;
case 5: primary = scoutClass(player); break;
}

player.LocalTakeEntityToHands(primary);
player.SetQuickBarEntityShortcut(primary, 0, true);
player.SetQuickBarEntityShortcut(pistol, 2, true);

}
};

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

----- Now the other issue with this is the batteries are not auto-equipped and if you add clothing it ends up in inventory not being equipped but instead uses server base character clothing in another file(limits starting clothes). For example, the NVG's have to be equipped with a battery by hand and installed on the strap then on your head.

2nd way using DayZ Expansion AI Loadouts allows you to randomize All starting gear including the clothing, using ' Sets ' For example on my LAN server, you randomly spawn in as Army Recon, British SAS, OREL Special Police, or SWAT Officer and each of those Options has 4 different weapon class Loadouts so they have unique legit weapons (NATO vs East Europe vs Urban Police) and Everything is Auto-Equipped With Batteries and Ammo - Only thing you have to do is load a mag into your weapon when you spawn.

Unfortunately this requires so much screen typing space I either need to open a github or make a tutorial video to post. Heres a quick hint - usig DayZ Expansion AI - go to -- "D:\Steam\steamapps\common\DayZServer\mpmissions\dayzOffline.chernarusplus\expansion\settings SpawnSettings.JSON

- scroll to bottom - put a " 1 " in ' useloadouts[1]' - use loadout name and chance just as the example, then -->
go to Server Config Folder = " D:\Steam\steamapps\common\DayZServer\config\ExpansionMod\Loadouts "

Steal a template, put your gear in it, and name it your own such as "ArmyReconLoaout.JSON" then add that name to the loadouts options in the SpawnSettings.JSON file mentioned above.

Modding at this level Requires ALOT of trial and error But it DOES WORK and can be Very Very Awesome!!

Good Luck and Have Fun! I will make a tutorial video =D ~ Terd
Last edited by Terd; Oct 24, 2022 @ 10:36am
Terd Oct 24, 2022 @ 10:24am 
Oh and BTW Im in no way a programmer or did this from scratch, I literally used an init.c file that already existed and just started messing with the line items until it worked. When you are hijacking files copy/pasting, use on online JSON and XML validator tool - will save your ass and Sanity because its always a missed comma or bracket. And for DayZ Expansion AI I quite literally started messing with files and grinded through it (there is no tutorial yet)

So in the End my message is: DO NOT GIVE UP ! Persistence Pays Off Big Dividends in Modding
thanx Ill give it a try...
< >
Showing 1-3 of 3 comments
Per page: 1530 50

Date Posted: Oct 22, 2022 @ 4:38am
Posts: 3