[RELEASE] Complete Random Loadouts

Hello. This is my first time releasing anything. It's nothing much but I have implemented this onto my server.

On my server, I have players respawn with a completely random loadout EVERY time. It's not hard to add this into your server as there isn't too much to add into your init.c file.

Inside your init.c file, look for
Code:
class CustomMission: MissionServer
{
and below the opening {, change your code so it looks like below.

Code:
void SetRandomHealth(EntityAI itemEnt)
    {
        int rndHlt = Math.RandomInt(40,100);
        itemEnt.SetHealth("","",rndHlt);
    }
    
    void SetHealth(EntityAI itemEnt, int health)
    {
        itemEnt.SetHealth("","",health);
    }

    override PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)
    {
        Entity playerEnt;
        playerEnt = GetGame().CreatePlayer(identity, characterName, pos, 0, "NONE");//Creates random player
        Class.CastTo(m_player, playerEnt);
        
        GetGame().SelectPlayer(identity, m_player);
        
        return m_player;
    }
    
    
    
    override void StartingEquipSetup(PlayerBase player, bool clothesChosen)
    {

        TStringArray tops = {"Shirt_BlueCheck","Shirt_RedCheck","Shirt_GreenCheck","Shirt_WhiteCheck","Shirt_PlaneBlack","HikingJacket_Blue","HikingJacket_Green","HikingJacket_Red","Sweater_Blue","Sweater_Gray","Sweater_Green","Sweater_Red","TShirt_Beige","TShirt_Black","TShirt_Blue","TShirt_Green","TShirt_Grey","TShirt_OrangeWhiteStripes","TShirt_Red","TShirt_RedBlackStripes","TShirt_White"};
        TStringArray pants = {"Jeans_Black","Jeans_BlueDark","Jeans_Blue","Jeans_Brown","Jeans_Green","Jeans_Grey"};
        TStringArray shoes = {"AthleticShoes_Black","AthleticShoes_Blue","AthleticShoes_Brown","AthleticShoes_Green","AthleticShoes_Grey","HikingBootsLow_Beige","HikingBootsLow_Black","HikingBootsLow_Blue","HikingBootsLow_Grey","HikingBoots_Black","HikingBoots_Brown","HikingJacket_Black"};
        TStringArray tool = {"OrienteeringCompass","StoneKnife","PurificationTablets","RoadFlare"};
        TStringArray medic = {"Rags","BandageDressing"};
        TStringArray drink = {"SodaCan_Cola","SodaCan_Kvass","SodaCan_Pipsi","SodaCan_Spite"};
        TStringArray food = {"Worm","SmallGuts","PowderedMilk","PeachesCan","Pear"};
    
        player.RemoveAllItems();       
        
        EntityAI itemEnt;
        EntityAI itemIn;
        ItemBase itemBs;

        EntityAI item = player.GetInventory().CreateInInventory(tops.GetRandomElement());
        itemBs = ItemBase.Cast(itemEnt);
        SetHealth(itemEnt, 20);
        
        EntityAI item2 = player.GetInventory().CreateInInventory(pants.GetRandomElement());
        itemBs = ItemBase.Cast(itemEnt);
        SetHealth(itemEnt, 20);
        
        EntityAI item3 = player.GetInventory().CreateInInventory(shoes.GetRandomElement());
        itemBs = ItemBase.Cast(itemEnt);
        SetHealth(itemEnt, 20);
                
        itemEnt = player.GetInventory().CreateInInventory(tool.GetRandomElement());
        itemBs = ItemBase.Cast(itemEnt);
        SetRandomHealth(itemEnt);

        itemEnt = player.GetInventory().CreateInInventory(medic.GetRandomElement());
        itemBs = ItemBase.Cast(itemEnt);
        SetRandomHealth(itemEnt);

        itemEnt = player.GetInventory().CreateInInventory(drink.GetRandomElement());
        itemBs = ItemBase.Cast(itemEnt);
        SetRandomHealth(itemEnt);

        itemEnt = player.GetInventory().CreateInInventory(food.GetRandomElement());
        itemBs = ItemBase.Cast(itemEnt);
        SetRandomHealth(itemEnt);
    }
Adjust your array items to whatever you prefer, just keep in mind inventory space as I have some shirts in there that offer no inventory slots.

License: Feel free to use this however you like, if you adjust it or improve it, please share here for others. Please at least give some credit for this even though this is very basic.
 
Cool script edit. Thanks for sharing.
I edited a little. Commented the drink and water as i dont want this for now anyway and added two more array which is the personal radio and 9v battery.
Code:
        TStringArray radio = {"PersonalRadio"};
        TStringArray battery = {"Battery9V"};
Code:
        itemEnt = player.GetInventory().CreateInInventory(radio.GetRandomElement());
        itemBs = ItemBase.Cast(itemEnt);
        SetRandomHealth(itemEnt);
        
        itemEnt = player.GetInventory().CreateInInventory(battery.GetRandomElement());
        itemBs = ItemBase.Cast(itemEnt);
        SetRandomHealth(itemEnt);
Now i just to test it thoroughly just to make sure everything fit in it. :p
Anyway thanks for this edit. I like it.
 
Cool script edit. Thanks for sharing.
I edited a little. Commented the drink and water as i dont want this for now anyway and added two more array which is the personal radio and 9v battery.
Code:
        TStringArray radio = {"PersonalRadio"};
        TStringArray battery = {"Battery9V"};
Code:
        itemEnt = player.GetInventory().CreateInInventory(radio.GetRandomElement());
        itemBs = ItemBase.Cast(itemEnt);
        SetRandomHealth(itemEnt);
       
        itemEnt = player.GetInventory().CreateInInventory(battery.GetRandomElement());
        itemBs = ItemBase.Cast(itemEnt);
        SetRandomHealth(itemEnt);
Now i just to test it thoroughly just to make sure everything fit in it. :p
Anyway thanks for this edit. I like it.
You're welcome! Thanks for sharing your edits on this.

And I had set it up this way as a base so people can get the feel for adding in more variables/arrays for a more random loadout. :D
 
You're welcome! Thanks for sharing your edits on this.

And I had set it up this way as a base so people can get the feel for adding in more variables/arrays for a more random loadout. :D
I really like this setup as you can make so every spawn feels more different that the previous spawn and not everyone looks the same. This is a big thing specially for Roleplay server. Love it.
 
could either of you 2 shed light on how i can add random backpack and tent? i tried adding more variables as you 2 did maybe i got the names wrong?

never mind figured it out.

Hers is mine with bag vest and a gun added


Code:
class CustomMission: MissionServer
{  
    void SetRandomHealth(EntityAI itemEnt)
    {
        int rndHlt = Math.RandomInt(40,100);
        itemEnt.SetHealth("","",rndHlt);
    }
   
    void SetHealth(EntityAI itemEnt, int health)
    {
        itemEnt.SetHealth("","",health);
    }

    override PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)
    {
        Entity playerEnt;
        playerEnt = GetGame().CreatePlayer(identity, characterName, pos, 0, "NONE");//Creates random player
        Class.CastTo(m_player, playerEnt);
       
        GetGame().SelectPlayer(identity, m_player);
       
        return m_player;
    }
   
   
   
    override void StartingEquipSetup(PlayerBase player, bool clothesChosen)
    {

        TStringArray gun = {"SVD"};
        TStringArray tops = {"HikingJacket_Blue","HikingJacket_Green","HikingJacket_Red"};
        TStringArray pants = {"Jeans_Black","Jeans_BlueDark","Jeans_Blue","Jeans_Brown","Jeans_Green","Jeans_Grey"};
        TStringArray shoes = {"AthleticShoes_Black","AthleticShoes_Blue","AthleticShoes_Brown","AthleticShoes_Green","AthleticShoes_Grey","HikingBootsLow_Beige","HikingBootsLow_Black","HikingBootsLow_Blue","HikingBootsLow_Grey","HikingBoots_Black","HikingBoots_Brown","HikingJacket_Black"};
        TStringArray tool = {"OrienteeringCompass","Knife","PurificationTablets","Matchbox"};
        TStringArray medic = {"Rags","BandageDressing"};
        TStringArray drink = {"SodaCan_Cola","SodaCan_Kvass","SodaCan_Pipsi","SodaCan_Spite"};
        TStringArray food = {"Worm","SmallGuts","PowderedMilk","PeachesCan","Pear"};
        TStringArray backpack = {"TortillaBag","HuntingBag","SmershBag","AssaultBag_Ttsko","AssaultBag_Black","AssaultBag_Green","CoyoteBag_Brown","CoyoteBag_Green","AliceBag_Green","AliceBag_Black","AliceBag_Camo"};
        TStringArray vest = {"PlateCarrierComplete","HighCapacityVest_Olive","HighCapacityVest_Black"};
        TStringArray ammo = {"Mag_SVD_10Rnd"};
       
        player.RemoveAllItems();      
       
        EntityAI itemEnt;
        EntityAI itemIn;
        ItemBase itemBs;
       
        EntityAI item = player.GetInventory().CreateInInventory(gun.GetRandomElement());
        itemBs = ItemBase.Cast(itemEnt);
        SetHealth(itemEnt, 20);
       
        EntityAI item1 = player.GetInventory().CreateInInventory(tops.GetRandomElement());
        itemBs = ItemBase.Cast(itemEnt);
        SetHealth(itemEnt, 20);
       
        EntityAI item2 = player.GetInventory().CreateInInventory(pants.GetRandomElement());
        itemBs = ItemBase.Cast(itemEnt);
        SetHealth(itemEnt, 20);
       
        EntityAI item3 = player.GetInventory().CreateInInventory(shoes.GetRandomElement());
        itemBs = ItemBase.Cast(itemEnt);
        SetHealth(itemEnt, 20);
               
        itemEnt = player.GetInventory().CreateInInventory(tool.GetRandomElement());
        itemBs = ItemBase.Cast(itemEnt);
        SetRandomHealth(itemEnt);

        itemEnt = player.GetInventory().CreateInInventory(medic.GetRandomElement());
        itemBs = ItemBase.Cast(itemEnt);
        SetRandomHealth(itemEnt);

        itemEnt = player.GetInventory().CreateInInventory(drink.GetRandomElement());
        itemBs = ItemBase.Cast(itemEnt);
        SetRandomHealth(itemEnt);

        itemEnt = player.GetInventory().CreateInInventory(food.GetRandomElement());
        itemBs = ItemBase.Cast(itemEnt);
        SetRandomHealth(itemEnt);
       
        itemEnt = player.GetInventory().CreateInInventory(backpack.GetRandomElement());
        itemBs = ItemBase.Cast(itemEnt);
        SetRandomHealth(itemEnt);
       
        itemEnt = player.GetInventory().CreateInInventory(vest.GetRandomElement());
        itemBs = ItemBase.Cast(itemEnt);
        SetRandomHealth(itemEnt);
       
        itemEnt = player.GetInventory().CreateInInventory(ammo.GetRandomElement());
        itemBs = ItemBase.Cast(itemEnt);
        SetRandomHealth(itemEnt);
       
    }
 
Last edited:
Is this the init.c from your MPMissons ChernarusPlus folder? If so, mine doesn't have this:

Code:
class CustomMission: MissionServer
{
Am I looking in the wrong init.c?

This is the I have: https://pastebin.com/T4JndEfD
That one there looks like the file from the offline version.

I have used the one that was supplied with the DayZ Server file release.

Yes this would be the init.c from the MPMissions CherarusPlus folder.
 
That's the only init.c I can find. My server is hosted with Vilayer.
Sorry for the delayed reply. I am not sure why I'm not getting notified when responses are made in this thread. Below I have pasted the init.c default file from the DayZ Server files which are available for free in your Steam Library under the tools section.

Code:
void main()
{

    Hive ce = CreateHive();
    if ( ce )
        ce.InitOffline();

    Weather weather = g_Game.GetWeather();

    weather.GetOvercast().SetLimits( 0.0 , 1.0 );
    weather.GetRain().SetLimits( 0.0 , 1.0 );
    weather.GetFog().SetLimits( 0.0 , 0.25 );

    weather.GetOvercast().SetForecastChangeLimits( 0.0, 0.2 );
    weather.GetRain().SetForecastChangeLimits( 0.0, 0.1 );
    weather.GetFog().SetForecastChangeLimits( 0.15, 0.45 );

    weather.GetOvercast().SetForecastTimeLimits( 1800 , 1800 );
    weather.GetRain().SetForecastTimeLimits( 600 , 600 );
    weather.GetFog().SetForecastTimeLimits( 1800 , 1800 );

    weather.GetOvercast().Set( Math.RandomFloatInclusive(0.0, 0.3), 0, 0);
    weather.GetRain().Set( Math.RandomFloatInclusive(0.0, 0.2), 0, 0);
    weather.GetFog().Set( Math.RandomFloatInclusive(0.0, 0.1), 0, 0);
    
    weather.SetWindMaximumSpeed(15);
    weather.SetWindFunctionParams(0.1, 0.3, 50);
}

class CustomMission: MissionServer
{   
    void SetRandomHealth(EntityAI itemEnt)
    {
        int rndHlt = Math.RandomInt(40,100);
        itemEnt.SetHealth("","",rndHlt);
    }

    override PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)
    {
        Entity playerEnt;
        playerEnt = GetGame().CreatePlayer(identity, characterName, pos, 0, "NONE");//Creates random player
        Class.CastTo(m_player, playerEnt);
        
        GetGame().SelectPlayer(identity, m_player);
        
        return m_player;
    }
    
    override void StartingEquipSetup(PlayerBase player, bool clothesChosen)
    {
/*
        player.RemoveAllItems();

        EntityAI item = player.GetInventory().CreateInInventory(topsArray.GetRandomElement());
        EntityAI item2 = player.GetInventory().CreateInInventory(pantsArray.GetRandomElement());
        EntityAI item3 = player.GetInventory().CreateInInventory(shoesArray.GetRandomElement());
*/
        EntityAI itemEnt;
        ItemBase itemBs;
        
        itemEnt = player.GetInventory().CreateInInventory("Rag");
        itemBs = ItemBase.Cast(itemEnt);
        itemBs.SetQuantity(4);
        SetRandomHealth(itemEnt);

        itemEnt = player.GetInventory().CreateInInventory("RoadFlare");
        itemBs = ItemBase.Cast(itemEnt);
    }
};
 
Mission CreateCustomMission(string path)
{
    return new CustomMission();
}
You should be able to just copy/paste this in but maybe make a backup copy of your init.c first before saving over, just to make sure it will still work.
 
I cant get this to work i get this error and my server crashes

Can't compile mission init script'!

$CurrentDir:mpmissions\dayzOffline.chernarusplus\init.c(120): Opened scope at the end of file, missing '}' ?

this is what my full init script looks like

Code:
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)
    {
        int rndHlt = Math.RandomInt(40,100);
        itemEnt.SetHealth("","",rndHlt);
    }
   
    void SetHealth(EntityAI itemEnt, int health)
    {
        itemEnt.SetHealth("","",health);
    }

    override PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName)
    {
        Entity playerEnt;
        playerEnt = GetGame().CreatePlayer(identity, characterName, pos, 0, "NONE");//Creates random player
        Class.CastTo(m_player, playerEnt);
       
        GetGame().SelectPlayer(identity, m_player);
       
        return m_player;
    }
   
   
   
    override void StartingEquipSetup(PlayerBase player, bool clothesChosen)
    {

        TStringArray tops = {"Shirt_BlueCheck","Shirt_RedCheck","Shirt_GreenCheck","Shirt_WhiteCheck","Shirt_PlaneBlack","HikingJacket_Blue","HikingJacket_Green","HikingJacket_Red","Sweater_Blue","Sweater_Gray","Sweater_Green","Sweater_Red","TShirt_Beige","TShirt_Black","TShirt_Blue","TShirt_Green","TShirt_Grey","TShirt_OrangeWhiteStripes","TShirt_Red","TShirt_RedBlackStripes","TShirt_White"};
        TStringArray pants = {"Jeans_Black","Jeans_BlueDark","Jeans_Blue","Jeans_Brown","Jeans_Green","Jeans_Grey"};
        TStringArray shoes = {"AthleticShoes_Black","AthleticShoes_Blue","AthleticShoes_Brown","AthleticShoes_Green","AthleticShoes_Grey","HikingBootsLow_Beige","HikingBootsLow_Black","HikingBootsLow_Blue","HikingBootsLow_Grey","HikingBoots_Black","HikingBoots_Brown","HikingJacket_green"};
        TStringArray tool = {"OrienteeringCompass","StoneKnife","PurificationTablets","RoadFlare"};
        TStringArray medic = {"Rags","BandageDressing"};
        TStringArray drink = {"SodaCan_Cola","SodaCan_Kvass","SodaCan_Pipsi","SodaCan_Spite"};
        TStringArray food = {"Worm","SmallGuts","PowderedMilk","PeachesCan","Pear"};
   
        player.RemoveAllItems();      
       
        EntityAI itemEnt;
        EntityAI itemIn;
        ItemBase itemBs;

        EntityAI item = player.GetInventory().CreateInInventory(tops.GetRandomElement());
        itemBs = ItemBase.Cast(itemEnt);
        SetHealth(itemEnt, 20);
       
        EntityAI item2 = player.GetInventory().CreateInInventory(pants.GetRandomElement());
        itemBs = ItemBase.Cast(itemEnt);
        SetHealth(itemEnt, 20);
       
        EntityAI item3 = player.GetInventory().CreateInInventory(shoes.GetRandomElement());
        itemBs = ItemBase.Cast(itemEnt);
        SetHealth(itemEnt, 20);
               
        itemEnt = player.GetInventory().CreateInInventory(tool.GetRandomElement());
        itemBs = ItemBase.Cast(itemEnt);
        SetRandomHealth(itemEnt);

        itemEnt = player.GetInventory().CreateInInventory(medic.GetRandomElement());
        itemBs = ItemBase.Cast(itemEnt);
        SetRandomHealth(itemEnt);

        itemEnt = player.GetInventory().CreateInInventory(drink.GetRandomElement());
        itemBs = ItemBase.Cast(itemEnt);
        SetRandomHealth(itemEnt);

        itemEnt = player.GetInventory().CreateInInventory(food.GetRandomElement());
        itemBs = ItemBase.Cast(itemEnt);
        SetRandomHealth(itemEnt);
        }
    }
};

Mission CreateCustomMission(string path)
{
    return new CustomMission();
}
the line the error is talking about is right at the bottom. im using gtx gaming for server host if that helps
 
It will be the line directly above your Mission CreateCustomMission line


itemEnt = player.GetInventory().CreateInInventory(food.GetRandomElement());
itemBs = ItemBase.Cast(itemEnt);
SetRandomHealth(itemEnt);
}
}
};

Mission CreateCustomMission(string path)
{
return new CustomMission();
}
 
Hello , nice work, many thanks Johnny Bravo
  • A query, could you tell me if you have modified the script for Humanity Based Loadouts on Respawn? I would like to combine it with the Base Building Plus mod that Humanity uses for crafting levels.... or I will appreciate any suggestion.
Thanks
 
Hello , nice work, many thanks Johnny Bravo
  • A query, could you tell me if you have modified the script for Humanity Based Loadouts on Respawn? I would like to combine it with the Base Building Plus mod that Humanity uses for crafting levels.... or I will appreciate any suggestion.
Thanks
I have not. When you're talking the humanity based loadout, you're talking whatever mod has that little bambi icon in bottom right?

I'm just at work right now but can start looking into it tonight if you can let me know what mod has the humanity in it.
 
Top