Jump to content

[Released] Custom spawn loadout dependend on humanity


chargedlight1

Recommended Posts

If you dont want to use: http://opendayz.net/threads/release-essv2-enhanced-spawn-selection-v2.21547/
As you want a random spawn location for player who join your server just like me.

One thing to notice is that i didn't test this without anti-hack. ( I've used infistar on server side with a reason. PM me if you want to know that reason and why i did it in this specific way. ) 


Without Antihack on server side* NOT TESTED, NEED RESPONSE IF WORKS OR SOLUTION! :

First add this in init:

execVM "Custom\loadout.sqf"; 

Above:

dayz_paraSpawn = false; // Halo spawn
DZE_BackpackAntiTheft = false; // Prevent stealing from backpacks in trader zones



in Custom\loadout.sqf:

//change loadout on spawn,
// added by: Stijnkluiters github: https://github.com/stijnkluiters

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


_humanity = player getVariable["humanity",0]; // This is where my own server failed because of my anti-hack

_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"];
};    

With Antihack on server side* TESTED, WORKS! :

Go to /z/addons/dayz_server/compile/server_playerLogin.sqf

And add:

"_primcharvar",
"_humanity"
// Line 1 in code.
to private[];


after doing so.

Add this:
 

//Do Connection Attempt
// humanity
_doLoop = 0;
while {_doLoop < 5} do {
	_key = format["CHILD:102:%1:",_charID];
	_primcharvar = _key call server_hiveReadWrite;
	if (count _primcharvar > 0) then {
		if ((_primcharvar select 0) != "ERROR") then {
			_doLoop = 9;
		};
	};
	_doLoop = _doLoop + 1;
};

_humanity = _primcharvar select 5;

after:
 

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

// NEW CODE HERE!


find: PVCDZ_plr_Login

add this under that.
 

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

Go to: 
Init.sqf

Add: execVM "Custom\loadout.sqf"; 

above:

dayz_paraSpawn = false; // Halo spawn
DZE_BackpackAntiTheft = false; // Prevent stealing from backpacks in trader zones


in Custom\loadout.sqf
 

//change loadout on spawn,
// added by: Stijnkluiters github: https://github.com/stijnkluiters

// 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;

diag_log format["CHARGEDLIGHT1: humanity: %1",_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 {
//bandit
    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"];
};  







 

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
  • Advertisement
  • Discord

×
×
  • Create New...