Jump to content
  • 0

Give loadout based on humanity level


THAC0_Gewch

Question

Recommended Posts

  • 0

Wouldn't this override their inventory every time they log in? I imagine you will need a check to verify the player is a new spawn.

 

Also youll need this under the back pack line

 

DefaultBackpackWeapon = "";

 

I don't believe it would, it's basically just doing what you would normally do for default loadouts in the init.sqf, just that it's only applying it to certain players based on their humanity.

 

Thanks for the tip on DefaultBackpackWeapon, I probably should add that in.

Link to comment
Share on other sites

  • 0

I don't believe it would, it's basically just doing what you would normally do for default loadouts in the init.sqf, just that it's only applying it to certain players based on their humanity.

 

Thanks for the tip on DefaultBackpackWeapon, I probably should add that in.

Oh ok cool :) Sorry i couldnt help more :(

Link to comment
Share on other sites

  • 0

I've made some adjustments for testing, the following code is also not working:

Execution line in init.sqf is now:

null = [] execVM "scripts\loadout.sqf";

Loadout.sqf is now the following:
 

// HERO LOADOUT GRANTER
Private ["_humanity"];

waitUntil {!isNull player}; // Make sure player object exists
waitUntil {(getPlayerUID player) != ""}; // Check that player is actually a player
_humanity = (player getVariable["humanity",0]);

if((_humanity) >= 20000) then {
diag_log "GRANTING HERO LOADOUT TO PLAYER";
//Overridden inventory here
DefaultMagazines = ["ItemBandage","ItemBandage","ItemBandage","ItemBandage","17Rnd_9x19_glock17","17Rnd_9x19_glock17","ItemMorphine","ItemPainkiller"];
DefaultWeapons = ["glock17_EP1","ItemMap"];
DefaultBackpack = "DZ_British_ACU";
}; // END HERO LOADOUT GRANTER
Link to comment
Share on other sites

  • 0

Hello,

 

 I really would like to get this figured out for my server as well. Problem we are having is Bandits spawn in with survivor clothes and it creates a multitude of issues...

 

I found this thread... http://opendayz.net/threads/humanity-based-loadouts.10447/ and it looks like it might work but only problem is, my server_playerLogin.sqf looks different.

 

The one from the above thread...

    if (true) then {
        _key = format["CHILD:999:select replace(`inventory`, '""', '\'') `inventory`, replace(`backpack`, '""', '\'') `backpack` from `instance` where `id` = ?:[%1]:",dayZ_instance];
        _data = "HiveEXT" callExtension _key;
        //Process result
        _result = call compile format ["%1", _data];
        _status = _result select 0;
        if (_status == "CustomStreamStart") then {
            if ((_result select 1) > 0) then {
                _data = "HiveEXT" callExtension _key;
                _result = call compile _data;
                _inventory = call compile (_result select 0);
                _backpack = call compile (_result select 1);
            };
        };
    };

//PLACE NEW CODE HERE

    if (true) then {
        _key = format["CHILD:999:select replace(cl.`inventory`, '""', '\'') inventory, replace(cl.`backpack`, '""', '\'') backpack, replace(coalesce(cl.`model`, 'Survivor2_DZ'), '""', '\'') model from `cust_loadout` cl join `cust_loadout_profile` clp on clp.`cust_loadout_id` = cl.`id` where clp.`unique_id` = '?':[%1]:",str(_playerID)];
        _data = "HiveEXT" callExtension _key;
        //Process result
        _result = call compile format ["%1", _data];
        _status = _result select 0;
        if (_status == "CustomStreamStart") then {
            if ((_result select 1) > 0) then {
                _data = "HiveEXT" callExtension _key;
                _result = call compile format ["%1", _data];
                _inventory = call compile (_result select 0);
                _backpack = call compile (_result select 1);
                _model = call compile (_result select 2);
            };
        };
    };

 and mine looks like...

private ["_isInfected","_doLoop","_hiveVer","_isHiveOk","_playerID","_playerObj","_primary","_key","_charID","_playerName","_backpack","_isNew","_inventory","_survival","_model","_mags","_wpns","_bcpk","_config","_newPlayer"];

#ifdef DZE_SERVER_DEBUG
diag_log ("STARTING LOGIN: " + str(_this));
#endif

_playerID = _this select 0;
_playerObj = _this select 1;
_playerName = name _playerObj;

if (_playerName == '__SERVER__' || _playerID == '' || local player) exitWith {};

if (isNil "sm_done") exitWith { 
#ifdef DZE_SERVER_DEBUG
	diag_log ("Login cancelled, server is not ready. " + str(_playerObj)); 
#endif
};

if (count _this > 2) then {
	dayz_players = dayz_players - [_this select 2];
};

//Variables
_inventory =	[];
_backpack = 	[];
_survival =		[0,0,0];
_isInfected =   0;
_model =		"";

if (_playerID == "") then {
	_playerID = getPlayerUID _playerObj;
};

if ((_playerID == "") or (isNil "_playerID")) exitWith {
#ifdef DZE_SERVER_DEBUG
	diag_log ("LOGIN FAILED: Player [" + _playerName + "] has no login ID");
#endif
};

#ifdef DZE_SERVER_DEBUG
diag_log ("LOGIN ATTEMPT: " + str(_playerID) + " " + _playerName);
#endif

//Do Connection Attempt
_doLoop = 0;
while {_doLoop < 5} do {
	_key = format["CHILD:101:%1:%2:%3:",_playerID,dayZ_instance,_playerName];
	_primary = _key call server_hiveReadWrite;
	if (count _primary > 0) then {
		if ((_primary select 0) != "ERROR") then {
			_doLoop = 9;
		};
	};
	_doLoop = _doLoop + 1;
};

if (isNull _playerObj or !isPlayer _playerObj) exitWith {
#ifdef DZE_SERVER_DEBUG
	diag_log ("LOGIN RESULT: Exiting, player object null: " + str(_playerObj));
#endif
};

if ((_primary select 0) == "ERROR") exitWith {
#ifdef DZE_SERVER_DEBUG
    diag_log format ["LOGIN RESULT: Exiting, failed to load _primary: %1 for player: %2 ",_primary,_playerID];
#endif
};

//Process request
_newPlayer = 	_primary select 1;
_isNew = 		count _primary < 7; //_result select 1;
_charID = 		_primary select 2;

#ifdef DZE_SERVER_DEBUG
diag_log ("LOGIN RESULT: " + str(_primary));
#endif

/* PROCESS */
_hiveVer = 0;

if (!_isNew) then {
	//RETURNING CHARACTER		
	_inventory = 	_primary select 4;
	_backpack = 	_primary select 5;
	_survival =		_primary select 6;
	_model =		_primary select 7;
	_hiveVer =		_primary select 8;
	
	if (!(_model in AllPlayers)) then {
		_model = "Survivor2_DZ";
	};
	
} else {
	if (DZE_PlayerZed) then {
		_isInfected = _primary select 3;
	} else {
		_isInfected = 0;
	};
	_model =		_primary select 4;
	_hiveVer =		_primary select 5;
	
	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");

		if(!isNil "DefaultMagazines") then {
			_mags = DefaultMagazines;
		};
		if(!isNil "DefaultWeapons") then {
			_wpns = DefaultWeapons;
		};
		if(!isNil "DefaultBackpack") then {
			_bcpk = DefaultBackpack;
		};
		//_randomSpot = true;
	
		//Wait for HIVE to be free
		_key = format["CHILD:203:%1:%2:%3:",_charID,[_wpns,_mags],[_bcpk,[],[]]];
		_key call server_hiveWrite;
	};
};

#ifdef DZE_SERVER_DEBUG
diag_log ("LOGIN LOADED: " + str(_playerObj) + " Type: " + (typeOf _playerObj) + " at location: " + (getPosATL _playerObj));
#endif

_isHiveOk = false;
if (_hiveVer >= dayz_hiveVersionNo) then {
	_isHiveOk = true;
};

if (worldName == "chernarus") then {
	([4654,9595,0] nearestObject 145259) setDamage 1;
	([4654,9595,0] nearestObject 145260) setDamage 1;
};

dayzPlayerLogin = [_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model,_isHiveOk,_newPlayer,_isInfected];
(owner _playerObj) publicVariableClient "dayzPlayerLogin";

I am also on a dayz,st server. Maybe the file changed with Epoch Updates? Idk,

 

Anyone know how to set up custom loadouts based on humanity?

 

Thanks,

 

Zero

Link to comment
Share on other sites

  • 0

I think I could do this; at work atm, will do it when I go home okay? 

 

~Mochan

Mochan, that would be great! Thank You!

 

This is actually a very interessting idea. Keep me up to date about this, please!

I absolutely will! If we come up with a solution I will post it here!

 

@ZeroK00L

that cant work because of the hive child 999 and 998 they are not supported in epoch

Ah I see, too bad! Thanks for the info!

 

Zero

Link to comment
Share on other sites

  • 0

im unsure why you would want to use hive calls for this, it could be quite easy done with a few lines of code in the init

 

I'm not trying to use Hive Calls, to be honest Id rather not. That's why I am asking for help. If its so easy, would you mind sharing?

 

Zero

Link to comment
Share on other sites

  • 0

I'm not trying to use Hive Calls, to be honest Id rather not. That's why I am asking for help. If its so easy, would you mind sharing?

 

Zero

 

idk what you want me to share, as this is common knowlage ... you can use these lines to determin if the player is freshspawned or not:

waitUntil {!isNil ("PVDZE_plr_LoginRecord")};
if (dayzPlayerLogin2 select 2 and !(player isKindOf "PZombie_VB")) then {

then add some code below to switch skin of the player if he has a certain amount of humanity

Link to comment
Share on other sites

  • 0

idk what you want me to share, as this is common knowlage ... you can use these lines to determin if the player is freshspawned or not:

waitUntil {!isNil ("PVDZE_plr_LoginRecord")};
if (dayzPlayerLogin2 select 2 and !(player isKindOf "PZombie_VB")) then {

then add some code below to switch skin of the player if he has a certain amount of humanity

 

If this is common knowledge why are there so many threads of people trying to get help with custom load outs? Just forget it. If you are not willing to contribute to this community a working script or some snippet that will help lead into the right direction and are just going to post elitist statements and be a dick then I don't want your help. When I get this figured out I will post a TuT for anyone wanting it.

Link to comment
Share on other sites

  • 0

If this is common knowledge why are there so many threads of people trying to get help with custom load outs? Just forget it. If you are not willing to contribute to this community a working script or some snippet that will help lead into the right direction and are just going to post elitist statements and be a dick then I don't want your help. When I get this figured out I will post a TuT for anyone wanting it.

 

omg, are you serius?

 

if you are, you are obviusly an idiot ...

 

i just told you how you can do this, its not that hard.

just add a few lines underneth what i wrote to determin what humanity the player has and hand out skins or gear acordingly ...

 

or do you expect me to write the script for you aswell??

 

you are terribly wrong if you are, i could really care less about this ...

if i really wanted this, it im sure i could code it before i go to lunch, as it is quite the simple task.

(infact i already did something like this, as i created the spawn selection i use on my servers)

 

if you are so lost and frustrated that you feel you need to attack whoever is trying to help, then i guess it must be really hard for you, and i do feel sorry for you then.

 

either way ill point you in the direction (again, even tho this is also common knowledge aswell) ...

 

but try chekout "player_humanityMorph".

 

 

edit:

oh and btw, custom loadout is a lot easier as the epoch guys already prepared for that:

DefaultMagazines = [];
DefaultWeapons = [];
DefaultBackpack = "";
Link to comment
Share on other sites

  • 0

idk what you want me to share, as this is common knowlage ... you can use these lines to determin if the player is freshspawned or not:

waitUntil {!isNil ("PVDZE_plr_LoginRecord")};
if (dayzPlayerLogin2 select 2 and !(player isKindOf "PZombie_VB")) then {

then add some code below to switch skin of the player if he has a certain amount of humanity

 

 

Hey thanks for this post, I appreciate you taking the time. I know that what I'm trying to accomplish is probably super simple, I just started Arma scripting a few weeks ago so I'm still getting the hang of it. That's why what I came up with is noob-level to the max. I'm assuming there are no issues with what I posted here:

 

 

// HERO LOADOUT GRANTER
Private ["_humanity"];
_humanity = player getVariable["humanity",0];

diag_log "GRANTING HERO LOADOUT TO PLAYER";
if(_humanity >= 20000) then {
//Overridden inventory here
DefaultMagazines = ["ItemBandage","ItemBandage","ItemBandage","ItemBandage","17Rnd_9x19_glock17","17Rnd_9x19_glock17","ItemMorphine","ItemPainkiller"];
DefaultWeapons = ["glock17_EP1","ItemMap"];
DefaultBackpack = "DZ_British_ACU";
}; // END HERO LOADOUT GRANTER

 

Am I correct? If so I think I could probably just take everything from the if statement down and drop it under the code you've provided. I'll give this a shot and report back. Thanks again.

Link to comment
Share on other sites

  • 0

Hey thanks for this post, I appreciate you taking the time. I know that what I'm trying to accomplish is probably super simple, I just started Arma scripting a few weeks ago so I'm still getting the hang of it. That's why what I came up with is noob-level to the max. I'm assuming there are no issues with what I posted here:

 

 

// HERO LOADOUT GRANTER
Private ["_humanity"];
_humanity = player getVariable["humanity",0];

diag_log "GRANTING HERO LOADOUT TO PLAYER";
if(_humanity >= 20000) then {
//Overridden inventory here
DefaultMagazines = ["ItemBandage","ItemBandage","ItemBandage","ItemBandage","17Rnd_9x19_glock17","17Rnd_9x19_glock17","ItemMorphine","ItemPainkiller"];
DefaultWeapons = ["glock17_EP1","ItemMap"];
DefaultBackpack = "DZ_British_ACU";
}; // END HERO LOADOUT GRANTER

 

Am I correct? If so I think I could probably just take everything from the if statement down and drop it under the code you've provided. I'll give this a shot and report back. Thanks again.

 

looks about right ... if you dont know, then for this to work, you will need to edit server_playerSetup.sqf aswell ... find this:

dayzPlayerLogin2 = [_worldspace,_state];

change it to this:

dayzPlayerLogin2 = [_worldspace,_state,_randomSpot];

and you should be good ...

Link to comment
Share on other sites

  • 0

looks about right ... if you dont know, then for this to work, you will need to edit server_playerSetup.sqf aswell ... find this:

dayzPlayerLogin2 = [_worldspace,_state];

change it to this:

dayzPlayerLogin2 = [_worldspace,_state,_randomSpot];

and you should be good ...

 

Ok great, thanks for the tip. I didn't know that. What am I accomplishing by making this change?

 

 

Edit:

I've made the required changes, including the change to the playerSetup sqf in the server pbo. Loadouts still are not working, here's what my script looks like now:

 

// HERO LOADOUT GRANTER
Private ["_humanity"];

waitUntil {!isNil ("PVDZE_plr_LoginRecord")};

_humanity = (player getVariable["humanity",0]);
if (dayzPlayerLogin2 select 2 and !(player isKindOf "PZombie_VB")) then {
if(_humanity >= 20000) then {
diag_log ("GRANTING HERO LOADOUT TO PLAYER");
//Overridden inventory here
DefaultMagazines = ["ItemBandage","ItemBandage","ItemBandage","ItemBandage","17Rnd_9x19_glock17","17Rnd_9x19_glock17","ItemMorphine","ItemPainkiller"];
DefaultWeapons = ["glock17_EP1","ItemMap"];
DefaultBackpack = "DZ_British_ACU";
DefaultBackpackWeapon = "";
};
}; // END HERO LOADOUT GRANTER
Link to comment
Share on other sites

  • 0

I *think* I know what is happening here. So you have   null = [] execVM "scripts\loadout.sqf";   in your init.sqf, above the player monitor, which is where a loadout script based on UID should be located because it sets the default loadout AFTER the server has determined the players UID (line 7 or 31 in server_playerLogin.sqf), and before the server has checked if there is default loadout defined (line 118-126 in server_playerLogin.sqf). The problem with trying to base the loadout on humanity in this way is that the server doesn't check or apply a players humanity before defining the default loadout (in server_playerLogin.sqf). So whats happening is that your script is checking the humanity of the player before the server has even bothered to pull it from the database and apply it to the player, so doing it in this way, the player will always show as 0 (or null) humanity when your script is called and since your DefaultMagazines, ect, is only applied IF humanity is greater than 20000, it will never been seen by the server when setting up the player. 

 

One *possible* way to get this to work (loadout based on humanity) is by not defining a default loadout (DefaultMagazines, ect), but by adding the items directly to the player when they login...you've actually already got the 'wait til player has respawned' line in your script:  if (dayzPlayerLogin2 select 2 and !(player isKindOf "PZombie_VB")) then    instead of defining your default loadout here (because the server has already done that) you could instead add the items directly to the player, mabye something like:  player addMagazine 'ItemBandage';  and  player addWeapon 'ItemMap';   and all the other stuff you want that player to have.

 

This *might* work. I'm not at home and can't test it right now, but I'm fairly sure that is why your script isn't working. Good luck!

Link to comment
Share on other sites

  • 0

I *think* I know what is happening here. So you have   null = [] execVM "scripts\loadout.sqf";   in your init.sqf, above the player monitor, which is where a loadout script based on UID should be located because it sets the default loadout AFTER the server has determined the players UID (line 7 or 31 in server_playerLogin.sqf), and before the server has checked if there is default loadout defined (line 118-126 in server_playerLogin.sqf). The problem with trying to base the loadout on humanity in this way is that the server doesn't check or apply a players humanity before defining the default loadout (in server_playerLogin.sqf). So whats happening is that your script is checking the humanity of the player before the server has even bothered to pull it from the database and apply it to the player, so doing it in this way, the player will always show as 0 (or null) humanity when your script is called and since your DefaultMagazines, ect, is only applied IF humanity is greater than 20000, it will never been seen by the server when setting up the player. 

 

One *possible* way to get this to work (loadout based on humanity) is by not defining a default loadout (DefaultMagazines, ect), but by adding the items directly to the player when they login...you've actually already got the 'wait til player has respawned' line in your script:  if (dayzPlayerLogin2 select 2 and !(player isKindOf "PZombie_VB")) then    instead of defining your default loadout here (because the server has already done that) you could instead add the items directly to the player, mabye something like:  player addMagazine 'ItemBandage';  and  player addWeapon 'ItemMap';   and all the other stuff you want that player to have.

 

This *might* work. I'm not at home and can't test it right now, but I'm fairly sure that is why your script isn't working. Good luck!

 

This does make alot of sense! Thanks for the tip! Our server hosted through Dyaz.St sets up the default loadout in the init.sqf though? Does that make a difference on what you said? I've tried everything else so gonna try this tonight. Thanks again!

Link to comment
Share on other sites

  • 0

Finally got it! Thanks to THAC0_Gewch for kicking off this thread! Hope this works for you too bro! Special thanks to Halvhjearne for his tough love ;) lol and Extra Special Thanks to ritualmsry for pointing out that last little thing I was missing! I am no pro scripter by far and have tested this thoroughly so please forgive me if I made any mistakes and please feel free to clean it up or modify/improve! It actually is quite easy when you have the right info and kind people willing to help! I've learned so much from this little trial and my server is finally perfect! Running 20+ Scripts now very cleanly. Thanks for your help guys, couldn't have got this without you!

 

In your init.sqf add under if (!isDedicated) then {              (This may vary on your setup)

[] execVM "Loadouts\heroloadout.sqf";
[] execVM "Loadouts\banditloadout.sqf";

heroloadout.sqf

// Hells Cowboys Hero Loadout
Private ["_humanity"];

waitUntil {!isNil ("PVDZE_plr_LoginRecord")};

_humanity = (player getVariable["humanity",0]);
if (dayzPlayerLogin2 select 2 and !(player isKindOf "PZombie_VB")) then {
if(_humanity >= 5000) then {
removeAllWeapons player;
removeAllItems player;
removeBackpack player;
player addMagazine '30Rnd_556x45_Stanag';
player addMagazine '30Rnd_556x45_Stanag';
player addMagazine '30Rnd_556x45_Stanag';
player addMagazine '30Rnd_556x45_Stanag';
player addMagazine 'ItemBandage';
player addMagazine 'ItemBandage';
player addMagazine 'ItemBandage';
player addMagazine 'ItemBandage';
player addMagazine 'ItemMorphine';
player addMagazine 'ItemAntibiotic';
player addMagazine 'ItemPainkiller';
player addMagazine 'ItemSodaLemonade';
player addMagazine 'FoodbaconCooked';
player addMagazine '7Rnd_45ACP_1911';
player addMagazine '7Rnd_45ACP_1911';
player addMagazine '7Rnd_45ACP_1911';
player addMagazine '7Rnd_45ACP_1911';
player addMagazine 'ItemGoldBar10oz';
player addMagazine 'Skin_Soldier_Sniper_PMC_DZ';
player addWeapon 'M4A1_Aim';
player addWeapon 'Colt1911';
player addWeapon 'ItemCrowbar';
player addWeapon 'ItemToolbox';
player addWeapon 'ItemEtool';
player addWeapon 'ItemGPS';
player addWeapon 'ItemMap';
player addWeapon 'ItemKnife';
player addWeapon 'MeleeHatchet_DZE';
player addWeapon 'ItemCompass';
player addWeapon 'ItemMatchbox';
player addBackpack 'DZ_British_ACU';
};
};

banditloadout.sqf

// Hells Cowboys Bandit Loadout
Private ["_humanity"];

waitUntil {!isNil ("PVDZE_plr_LoginRecord")};

_humanity = (player getVariable["humanity",0]);
if (dayzPlayerLogin2 select 2 and !(player isKindOf "PZombie_VB")) then {
if(_humanity <= -5000) then {
removeAllWeapons player;
removeAllItems player;
removeBackpack player;
player addMagazine '30Rnd_545x39_AK';
player addMagazine '30Rnd_545x39_AK';
player addMagazine '30Rnd_545x39_AK';
player addMagazine '30Rnd_545x39_AK';
player addMagazine 'ItemBandage';
player addMagazine 'ItemBandage';
player addMagazine 'ItemBandage';
player addMagazine 'ItemBandage';
player addMagazine 'ItemMorphine';
player addMagazine 'ItemAntibiotic';
player addMagazine 'ItemPainkiller';
player addMagazine 'ItemSodaRabbit';
player addMagazine 'FoodCanDemon';
player addMagazine '15Rnd_9x19_M9';
player addMagazine '15Rnd_9x19_M9';
player addMagazine '15Rnd_9x19_M9';
player addMagazine '15Rnd_9x19_M9';
player addMagazine 'ItemGoldBar10oz';
player addMagazine 'Skin_GUE_Commander_DZ';
player addWeapon 'AKS_74_kobra';
player addWeapon 'UZI_EP1';
player addWeapon 'ItemCrowbar';
player addWeapon 'ItemToolbox';
player addWeapon 'ItemEtool';
player addWeapon 'ItemGPS';
player addWeapon 'ItemMap';
player addWeapon 'ItemKnife';
player addWeapon 'MeleeHatchet_DZE';
player addWeapon 'ItemCompass';
player addWeapon 'ItemMatchbox';
player addBackpack 'DZ_Backpack_EP1';
};
};

Obvisiouly you can change the items spawned to whatever you want :) Have fun!

 

Zero

 

Edit: Forget to mention two minor weird things. 1.) When first spawning, player needs to switch to Pistol then back to Rifle for rifle to load ammo. Not sure why it doesn't spawn ready to load ammo. Tried the command reloadplayer; but that didn't help. 2.) The skin ends up in inventory not on player. I tried removing the Skin_ portion off of the skin and got a config error. Go figure. Let me know if you guys get around this. :)

Link to comment
Share on other sites

  • 0

Ah, ok, thanks!

waitUntil {!isNil ("PVDZE_plr_LoginRecord")};

Does that piece of code prevent losing "inventory" on regulars?

 

That makes sure the player has logged in...

 

This one...

if (dayzPlayerLogin2 select 2 and !(player isKindOf "PZombie_VB")) then {

... makes sure the player is a new spawn. :)

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
×
×
  • Create New...