Johnny Bravo
New Member
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
and below the opening {, change your code so it looks like below.
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.
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
{
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.