Jump to content
  • 0

trying to get Humanity variable


chargedlight1

Question

https://epochmod.com/forum/topic/43153-released-custom-spawn-loadout-dependend-on-humanity/#comment-285478

-- OLD THREAT -- SOLVED!

Hello guys,

I have a question about spawning my gear on login. I want my default gear dependend on the amount of humanity. i'm currently working in the file: z\dayz_server\compile\server_playerLogin.sqf
But i cant get a reach on how to get that variable in the server. I dont know how to atleast. I've tried alot of variables like:
player getVariable['humanity',0]; which gives me <NULL>
and trying to debug _playerObj and_primary without luck.. server just crashes without any notification.
Here was my line of code to debug that:

diag_log format["object _playerObj: %1",_playerObj];
diag_log format["object _primary: %1",_primary];

does anyone know how to get that humanity variable ? i want to make a switch statement in the if statement here:

 

if (!_isNew) then {
	//RETURNING CHARACTER
	_inventory = _primary select 4;
	_backpack = _primary select 5;
	_survival = _primary select 6;
	_CharacterCoins = _primary select 7;
	_model = _primary select 8;
	_group = _primary select 9;
	_playerCoins = _primary select 10;
	_BankCoins = _primary select 11;
	_hiveVer = _primary select 12;
	if !(_model in AllPlayers) then {_model = "Survivor2_DZ";};
} else {
	_isInfected = if (DZE_PlayerZed) then {_primary select 3} else {0};
	_model = _primary select 4;
	_group = _primary select 5;
	_playerCoins = _primary select 6;
	_BankCoins = _primary select 7;
	_hiveVer = _primary select 8;	
	if (isNil "_model") then {
		_model = "Survivor2_DZ";
	} else {
		if (_model == "") then {_model = "Survivor2_DZ";};
	};
	//Record initial inventory only if not player zombie 
	if (_isInfected != 1) then {
		_config = configFile >> "CfgSurvival" >> "Inventory" >> "Default";
		_mags = getArray (_config >> "magazines");
		_wpns = getArray (_config >> "weapons");
		_bcpk = getText (_config >> "backpack");
		// Switch statement right here
		if (!isNil "DefaultMagazines") then {_mags = DefaultMagazines;};
		if (!isNil "DefaultWeapons") then {_wpns = DefaultWeapons;};
		if (!isNil "DefaultBackpack") then {_bcpk = DefaultBackpack;};
	
		//Wait for HIVE to be free
		_key = format["CHILD:203:%1:%2:%3:",_charID,[_wpns,_mags],[_bcpk,[],[]]];
		_key call server_hiveWrite;
	};

Something like:
 

if (!_isNew) then {
	//RETURNING CHARACTER
	_inventory = _primary select 4;
	_backpack = _primary select 5;
	_survival = _primary select 6;
	_CharacterCoins = _primary select 7;
	_model = _primary select 8;
	_group = _primary select 9;
	_playerCoins = _primary select 10;
	_BankCoins = _primary select 11;
	_hiveVer = _primary select 12;
	if !(_model in AllPlayers) then {_model = "Survivor2_DZ";};
} else {
	_isInfected = if (DZE_PlayerZed) then {_primary select 3} else {0};
	_model = _primary select 4;
	_group = _primary select 5;
	_playerCoins = _primary select 6;
	_BankCoins = _primary select 7;
	_hiveVer = _primary select 8;	
	if (isNil "_model") then {
		_model = "Survivor2_DZ";
	} else {
		if (_model == "") then {_model = "Survivor2_DZ";};
	};
	
	//Record initial inventory only if not player zombie 
	if (_isInfected != 1) then {
		_config = configFile >> "CfgSurvival" >> "Inventory" >> "Default";
		_mags = getArray (_config >> "magazines");
		_wpns = getArray (_config >> "weapons");
		_bcpk = getText (_config >> "backpack");
		// * CUSTOM LOADOUT SWITCHCASE! *
		switch (true) do {
			case(_humanity >= 5000): {
				DefaultMagazines = ["itemMap" //etc...];
			};
		};
		if (!isNil "DefaultMagazines") then {_mags = DefaultMagazines;};
		if (!isNil "DefaultWeapons") then {_wpns = DefaultWeapons;};
		if (!isNil "DefaultBackpack") then {_bcpk = DefaultBackpack;};
	
		//Wait for HIVE to be free
		_key = format["CHILD:203:%1:%2:%3:",_charID,[_wpns,_mags],[_bcpk,[],[]]];
		_key call server_hiveWrite;
	};
};


 

Link to comment
Share on other sites

Recommended Posts

  • 0
48 minutes ago, chargedlight1 said:

WARNING does not work yet! 

Variables are not getting executed. Trying to think of a solution. 
Weird thing is that it SHOULD work... default_magazines are defined RIGHT THERE in that Specific file..

 

any rpt?

Link to comment
Share on other sites

  • 0

First of all i fixed this problem. 

 I've installed infistar on the server side. the reason i did this is because orther people can see the code which is an security issue. I thaught.. Ill do it right. since infistar tells you to install things client side. Now, Infistar blocks the player object/variable! Which means normal variable wont work
Now i still used the fix from gathering data from the database. Since the Default... Weapons/Backpack/Magazines are defined CLIENTSIDE. and the code i was using was: SERVERSIDE. i made the humanity variable from the server side. PUBLIC. which means it can be called on the clientside & serverside. 

 

/* Humanity */
Humanity = _humanity;
(owner _playerObj) publicVariableClient "Humanity";


and in the init:


 

// Uncomment the lines below to change the default loadout
execVM "Custom\loadout.sqf"; // Don't remove this line
dayz_paraSpawn = false; // Halo spawn



And in the loadout:

 

//change loadout on spawn,

// default array = [
//"ItemBandage",
//"ItemBandage",
//"17Rnd_9x19_glock17",
//"17Rnd_9x19_glock17",
//"ItemMorphine",
private ["_isHero","_humanity","_isBandit"];


waitUntil {uiSleep 1; !isNil ("PVCDZ_plr_Login")};
waitUntil {uiSleep 1; !isNil ("Humanity")};
_humanity = Humanity;

_isBandit = _humanity < -5000;
_isHero = _humanity > 5000;

if (_isHero) then {
//hero
    diag_log format["LOADOUT: Hero"];
    DefaultMagazines = ["ItemMap","HandRoadFlare","ItemBandage","ItemPainkiller","8Rnd_9x18_Makarov","8Rnd_9x18_Makarov"];
    DefaultWeapons = ["Makarov_DZ","ItemFlashlight"];
    DefaultBackpack = "DZ_Patrol_Pack_EP1";
    DefaultBackpackItems = []; // Can include both weapons and magazines i.e. ["PDW_DZ","30Rnd_9x19_UZI"];
};    
if (_isBandit) then {
//bndit
    diag_log format["LOADOUT: Bandit"];
    DefaultMagazines = ["ItemMap","HandRoadFlare","ItemBandage","ItemPainkiller","8Rnd_9x18_Makarov","8Rnd_9x18_Makarov"];
    DefaultWeapons = ["Makarov_DZ","ItemFlashlight"];
    DefaultBackpack = "DZ_Patrol_Pack_EP1";
    DefaultBackpackItems = []; // Can include both weapons and magazines i.e. ["PDW_DZ","30Rnd_9x19_UZI"];
}


I hope i cleared some things up.

TESTED AND WORKING!

- Chargedlight.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Discord

×
×
  • Create New...