Jump to content
Sign in to follow this  
Norbak

I can't save Items and magazines inside the backpack using the savelayout.sqf

Recommended Posts

I can't save the layout inside the backpack. It's only working for main weapons,main magazines and type of backpack but not for the contents of the backpack.

the script is the Xeno's Savelayout.sqf , a bit modified:

// by Xeno

WaitUntil{isDedicated || not isNull player};

#include "x_setup.sqf"

_unit = _this select 1;

_weapons = weapons _unit;

_magazines = magazines _unit;

_backpack = unitBackpack _unit;

_backpackmags = getMagazineCargo _backpack;

_backpackweps = getWeaponCargo _backpack;

if (primaryWeapon player == "" || primaryWeapon player == " ") exitWith {"You need a primary weapon to save the layout !!!" call XfGlobalChat};

_d_custom_layout = [_weapons,_magazines,typeOf _backpack,_backpackmags, _backpackweps];

d_custom_layout = _d_custom_layout;

__pSetVar ["d_custom_backpack", if (count __pGetVar(d_player_backpack) > 0) then {

[__pGetVar(d_player_backpack) select 0, __pGetVar(d_player_backpack) select 1]

} else {

[]

}];

#ifdef __ACE__

d_custom_ruckbkw = __pGetVar(ACE_weapononback);

d_custom_ruckmag = __pGetVar(ACE_RuckMagContents);

d_custom_ruckwep = __pGetVar(ACE_RuckWepContents);

#endif

"Weapons and magazines layout saved. You will respawn with this layout." call XfGlobalChat;

Share this post


Link to post
Share on other sites

Rucksacks are an ACE feature. You would need to check ACE's capabilities with ruck contents.

Share this post


Link to post
Share on other sites

Sorry, saw this part and thought you were talking about ACE rucksack contents.

#ifdef __ACE__

d_custom_ruckbkw = __pGetVar(ACE_weapononback);

d_custom_ruckmag = __pGetVar(ACE_RuckMagContents);

d_custom_ruckwep = __pGetVar(ACE_RuckWepContents);

#endif

--- Edit --

Can only suggest:

1) check the return on _backpackmags and _backpackweps when defined.

2) compare the returns of _d_custom_layout and d_custom_layout after each is defined.

3) check the return on d_custom_layout before and after __pSetVar processes it.

These will help identify where the breakdown is occurring.

Edited by OpusFmSPol

Share this post


Link to post
Share on other sites

First, use launch param -showScriptErrors, and don't use launch param -noLogs. That way the errors encountered will get logged to the .rpt file and flash on screen as they occur, giving you an idea of when its happening.

Then run the script like this, using diag_log and format commands to dump the variable values into the .rpt log, but in a way that you can make sense of the results:

// by Xeno
 WaitUntil{isDedicated || not isNull player};
 #include "x_setup.sqf"

 _unit = _this select 1;

 _weapons = weapons _unit;
 _magazines = magazines _unit;
 _backpack = unitBackpack _unit;
 _backpackmags = getMagazineCargo _backpack;
[b]diag_log format ["_backpackmags: %1",_backpackmags];[/b]
 _backpackweps = getWeaponCargo _backpack;
[b]diag_log format ["_backpackweps: %1",_backpackweps];[/b]

 if (primaryWeapon player == "" || primaryWeapon player == " ") exitWith {"You need a primary weapon to save the layout !!!" call XfGlobalChat};

 _d_custom_layout = [_weapons,_magazines,typeOf _backpack,_backpackmags, _backpackweps];
[b]diag_log format ["_d_custom_layout: %1",_d_custom_layout];[/b]

 d_custom_layout = _d_custom_layout;
[b]diag_log format ["d_custom_layout: %1",d_custom_layout];[/b]

 __pSetVar ["d_custom_backpack", if (count __pGetVar(d_player_backpack) > 0) then {
 [__pGetVar(d_player_backpack) select 0, __pGetVar(d_player_backpack) select 1]
 } else {
 []
 }];
[b]diag_log format ["d_custom_layout: %1",d_custom_layout];[/b]

 #ifdef __ACE__
 d_custom_ruckbkw = __pGetVar(ACE_weapononback);
 d_custom_ruckmag = __pGetVar(ACE_RuckMagContents);
 d_custom_ruckwep = __pGetVar(ACE_RuckWepContents);
 #endif

 "Weapons and magazines layout saved. You will respawn with this layout." call XfGlobalChat;

After the script fails, exit and go to the .rpt file. Review the values that were dumped in and compare what they are versus what they should be. That should give you an idea where the failure occurs.

Edited by OpusFmSPol

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×