DayZ
Heroes And Bandits
 This topic has been pinned, so it's probably important
DaemonForge  [developer] 12 Jun, 2020 @ 2:46pm
init.c
These are Helper functions you can use in your init.c
These functions will allow you to set custom Character skins for different affinities and load outs based on their level

Get Player Skin
m_HeroesAndBandits.getPlayerSkin(PlayerID)
This will return the players skin based on what is defined in the BambiSkins, HeroSkins, or BanditSkins in the config file


Get Player Hero Or Bandit
m_HeroesAndBandits.GetPlayerHeroOrBandit(PlayerID)
This will return whether a player is a hero, bandit or bambi in a string


Get Player Affinity
m_HeroesAndBandits.GetPlayerAffinity(PlayerID)
This will return the players Affinity in a string usually bambi, hero, bandit but this can be configured by the server admins will return bambi(Default Level Affinity) if the player can't be found


Get Player Humanity
m_HeroesAndBandits.GetPlayerHumanity(PlayerID)
This will return the players Humanity in a float value, it will return 0 if the player can't be found


Get Player Level Name
m_HeroesAndBandits.GetPlayerLevelName(PlayerID)
Returns the Level Name in a string, it will return the default level's name (usually Bambi) if the player can't be found


Get Player Stat
m_HeroesAndBandits.GetPlayerStat(PlayerID, ActionName)
Returns INT of the player stats for the Action specified, if player or the player's stat doesn't exist it returns 0


Recalcuate Player Stats
m_HeroesAndBandits.updatePlayerTotals()
This will load and then recalcuate all of the players humanity based on the current action values. Since this will load all players into the local system, it is recommended to remove the code and restart the server once it finishes booting. To prevent any potential performance decreases especially on large population servers.
Last edited by DaemonForge; 5 Jul, 2020 @ 9:46pm
< >
Showing 1-5 of 5 comments
DaemonForge  [developer] 12 Jun, 2020 @ 3:02pm 
Get Player Skin Example
The below code will replace some code your init.c
override PlayerBase CreateCharacter(PlayerIdentity identity, vector pos, ParamsReadContext ctx, string characterName) { Entity playerEnt; playerEnt = GetGame().CreatePlayer(identity, m_HeroesAndBandits.getPlayerSkin(identity.GetPlainId()), pos, 0, "NONE"); Class.CastTo(m_player, playerEnt); GetGame().SelectPlayer(identity, m_player); return m_player; }
Last edited by DaemonForge; 12 Jun, 2020 @ 3:04pm
DaemonForge  [developer] 12 Jun, 2020 @ 3:05pm 
Get Player Affinity Example
This would be added to the StartingEquipSetup function in the init.c this would give any player with the Affinity of bandit a bandana Mask when they fresh spawn in.
TStringArray bandanaMask = {"BandanaMask_BlackPattern","BandanaMask_CamoPattern","BandanaMask_GreenPattern", "BandanaMask_PolkaPattern"}; if(m_HeroesAndBandits.GetPlayerAffinity(player.GetIdentity().GetPlainId()) == "bandit") { player.GetInventory().CreateInInventory(bandanaMask.GetRandomElement()); }

Add after the below if using expansion mod
itemEnt = itemTop.GetInventory().CreateInInventory(chemlightArray[rndIndex]); SetRandomHealth(itemEnt); } }
Last edited by DaemonForge; 15 Jun, 2020 @ 9:01am
DaemonForge  [developer] 12 Jun, 2020 @ 3:09pm 
Get Player Humanity Example
This could be used similar to above but instead give load outs to any player over a certain humanity
EG, every player with over 15,000 Humanity will spawn in with a Glock19 and a mag for it

if ( m_HeroesAndBandits.GetPlayerHumanity( player.GetIdentity().GetPlainId() ) >= 15000) { player.GetInventory().CreateInInventory("Glock19"); player.GetInventory().CreateInInventory("Mag_Glock_15Rnd"); }
Last edited by DaemonForge; 15 Jun, 2020 @ 8:58am
DaemonForge  [developer] 12 Jun, 2020 @ 3:10pm 
Get Player Level Name Example
To do later or if anyone creates an example send it to me Ill add it here

but this could be used similar to Get Affinity but instead give load outs to any player with a certain level
Last edited by DaemonForge; 12 Jun, 2020 @ 3:10pm
DaemonForge  [developer] 12 Jun, 2020 @ 3:11pm 
Get Player Stat Example
This could be used to give certain players items for doing more than a certain number of actions for example if a player had bandage other players for than 100 times AND they have given blood to more than 20 players they spawn in with a first aid kit
if ( m_HeroesAndBandits.GetPlayerStat( player.GetIdentity().GetPlainId(), "BandagePlayer" ) > 100 && m_HeroesAndBandits.GetPlayerStat( player.GetIdentity().GetPlainId(), "GiveBloodPlayer" ) > 20) { EntityAI kit = player.GetInventory().CreateInInventory("FirstAidKit"); kit.GetInventory().CreateInInventory("TetracyclineAntibiotics"); kit.GetInventory().CreateInInventory("BandageDressing"); kit.GetInventory().CreateInInventory("BandageDressing"); kit.GetInventory().CreateInInventory("CharcoalTablets"); kit.GetInventory().CreateInInventory("BloodTestKit"); }
Last edited by DaemonForge; 15 Jun, 2020 @ 1:47pm
< >
Showing 1-5 of 5 comments
Per page: 1530 50