Jump to content
  • 0

loosing backpack while using player_humanityMorph ?


meanbeandk

Question

Hi im trying to make a script that changes a players skin to a rocker skin with out loosing his backpack

 

Here is my code

private ["_bagType","_bagMagazines","_bagWeapons","_array1","_array2"];


_unitBag = unitBackpack player;
_bagType = typeOf _unitBag;
_bagWeapons = getWeaponCargo _unitBag;
_bagMagazines = getMagazineCargo _unitBag;

removeBackpack (vehicle player);
sleep 1;
[dayz_playerUID,dayz_characterID,'Rocker2'] spawn player_humanityMorph;
sleep 1;

if(_bagType == "CZ_VestPouch_EP1" || _bagType == "DZ_LargeGunBag_EP1" || _bagType == "DZ_ALICE_Pack_EP1" || _bagType == "DZ_Assault_Pack_EP1" || _bagType == "DZ_Backpack_EP1" || _bagType == "DZ_British_ACU" || _bagType == "DZ_CivilBackpack_EP1" || _bagType == "DZ_Czech_Vest_Pouch" || _bagType == "DZ_Patrol_Pack_EP1" || _bagType == "DZ_TK_Assault_Pack_EP1" || _bagType == "DZ_GunBag_EP1" || _bagType == "DZ_CompactPack_EP1" || _bagType == "DZ_TerminalPack_EP1") then {
	
	(vehicle player) addBackpack _bagType;
	sleep 0.1;

	_array1 = _bagWeapons select 0;
	_array2 = _bagWeapons select 1;
	for [{_i=0}, {_i < count _array1}, {_i=_i+1}] do
	{
		(unitBackpack player) addWeaponCargo [(_array1 select _i),(_array2 select _i)];
	}forEach ARRAY;
		
	_array1 = _bagMagazines select 0;
	_array2 = _bagMagazines select 1;
	for [{_i=0}, {_i < count _array1}, {_i=_i+1}] do
	{
		(unitBackpack player) addMagazineCargo [(_array1 select _i),(_array2 select _i)];
	}forEach ARRAY;

};

i think my problem is that the sleep funtion don't work wile using  player_humanityMorph

if i make this. 

It takes off my backpack and put it on again.

sleep 1;
//[dayz_playerUID,dayz_characterID,'Rocker2'] spawn player_humanityMorph;
sleep 1;

Hope some one can help me  :)

 

 

Link to comment
Share on other sites

10 answers to this question

Recommended Posts

  • 0

 

 

why (vehicle player) ?

 

its the play that im taking the bag of

 

not so good to this but trying to learn  :)

 

 

 

As far as i know, sleeping is not allowed when not in a loop and it throws a script error.

 

get no errors that i can see it chages the skin and there is no backpack  :)

Link to comment
Share on other sites

  • 0

then it change my skin but still no backpack  :(

i think my problem is that it have to wait until the player_humanityMorph is over maby check when player has the skin on then go on with the script. But don't know how to do that

 

With "WaitUntil" ->

 

private ["_bagType","_bagMagazines","_bagWeapons","_array1","_array2"];


_unitBag = unitBackpack player;
_bagType = typeOf _unitBag;
_bagWeapons = getWeaponCargo _unitBag;
_bagMagazines = getMagazineCargo _unitBag;

removeBackpack player;
[dayz_playerUID,dayz_characterID,'Rocker2'] spawn player_humanityMorph;

waitUntil {uisleep .25;!isNull player};

if(_bagType == "CZ_VestPouch_EP1" || _bagType == "DZ_LargeGunBag_EP1" || _bagType == "DZ_ALICE_Pack_EP1" || _bagType == "DZ_Assault_Pack_EP1" || _bagType == "DZ_Backpack_EP1" || _bagType == "DZ_British_ACU" || _bagType == "DZ_CivilBackpack_EP1" || _bagType == "DZ_Czech_Vest_Pouch" || _bagType == "DZ_Patrol_Pack_EP1" || _bagType == "DZ_TK_Assault_Pack_EP1" || _bagType == "DZ_GunBag_EP1" || _bagType == "DZ_CompactPack_EP1" || _bagType == "DZ_TerminalPack_EP1") then {
	
	player addBackpack _bagType;

	_array1 = _bagWeapons select 0;
	_array2 = _bagWeapons select 1;
	for [{_i=0}, {_i < count _array1}, {_i=_i+1}] do
	{
		(unitBackpack player) addWeaponCargo [(_array1 select _i),(_array2 select _i)];
	}forEach ARRAY;
		
	_array1 = _bagMagazines select 0;
	_array2 = _bagMagazines select 1;
	for [{_i=0}, {_i < count _array1}, {_i=_i+1}] do
	{
		(unitBackpack player) addMagazineCargo [(_array1 select _i),(_array2 select _i)];
	}forEach ARRAY;

};
Link to comment
Share on other sites

  • 0

This is (about) how it actually should look alike:

private ["_bagType","_bagMagazines","_bagWeapons","_array1","_array2","_bpWpnsTypes","_bpWpnsQtys","_bpMagsTypes","_bpMagsQtys"];


_unitBag = unitBackpack player;
_bagType = typeOf _unitBag;
_bagWeapons = getWeaponCargo _unitBag;
_bagMagazines = getMagazineCargo _unitBag;

removeBackpack player;
[dayz_playerUID,dayz_characterID,'Rocker2'] spawn player_humanityMorph;

waitUntil {uisleep .25;!isNull player};

if(_bagType == "CZ_VestPouch_EP1" || _bagType == "DZ_LargeGunBag_EP1" || _bagType == "DZ_ALICE_Pack_EP1" || _bagType == "DZ_Assault_Pack_EP1" || _bagType == "DZ_Backpack_EP1" || _bagType == "DZ_British_ACU" || _bagType == "DZ_CivilBackpack_EP1" || _bagType == "DZ_Czech_Vest_Pouch" || _bagType == "DZ_Patrol_Pack_EP1" || _bagType == "DZ_TK_Assault_Pack_EP1" || _bagType == "DZ_GunBag_EP1" || _bagType == "DZ_CompactPack_EP1" || _bagType == "DZ_TerminalPack_EP1") then {
    
	player addBackpack _bagType;

    if (count _bagWeapons > 0) then {
        _bpWpnsTypes = _bagWeapons select 0;
        _bpWpnsQtys = _bagWeapons select 1;
        
        {
            (unitBackpack player) addWeaponCargoGlobal [_x,(_bpWpnsQtys select _forEachIndex)];
        } forEach _bpWpnsTypes;
    };

    if (count _bagMagazines > 0) then {
        _bpMagsTypes = _bagMagazines select 0;
        _bpMagsQtys = _bagMagazines select 1;

        {
            (unitBackpack player) addMagazineCargoGlobal [_x,(_bpMagsQtys select _forEachIndex)];
        } forEach _bpMagsTypes;
    };

};

Link to comment
Share on other sites

  • 0

still no backpack  :(

 

I just noticed, it seems like the Rocker2 can't have a Backpack. Can't even pick one up. Try a different Skin

Link to comment
Share on other sites

  • 0
if(_bagType == "CZ_VestPouch_EP1" || _bagType == "DZ_LargeGunBag_EP1" || _bagType == "DZ_ALICE_Pack_EP1" || _bagType == "DZ_Assault_Pack_EP1" || _bagType == "DZ_Backpack_EP1" || _bagType == "DZ_British_ACU" || _bagType == "DZ_CivilBackpack_EP1" || _bagType == "DZ_Czech_Vest_Pouch" || _bagType == "DZ_Patrol_Pack_EP1" || _bagType == "DZ_TK_Assault_Pack_EP1" || _bagType == "DZ_GunBag_EP1" || _bagType == "DZ_CompactPack_EP1" || _bagType == "DZ_TerminalPack_EP1") then {

 

no need to check for every type of bag, you could just do something like:

if(!isNull (unitBackpack player))then{

if you want to check if something is a bag, you could use something like:

if(_myitem isKindOf "Bag_base")then{
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Discord

×
×
  • Create New...