androkiller 10 Posted December 18, 2016 hello so i have a ammo box with this in the init this addAction ["<t color='#0000ff'>Arsenal</t>","Ammobox.sqf"]; in the ammobox.sqf i am simply checking the side of the player, what type of unit and then loading the VA with the gear i let them have. however i am having a problem with defining the object (ammobox). if i define _mybox to the box which the addAction is on the the script doesnt work. but if i dont define it, the script work but gives me a error message stating i need to define _mybox . So what do i do? //ammobox.sqf private ["_mybox"]; if(getPlayerUID player in playerUidArray) exitWith { ["Open",true] spawn BIS_fnc_arsenal; }; if(playerSide == west) then { if ((typeOf player) == "B_medic_F") exitWith{ [_mybox, b_weaponsR, true, false] call BIS_fnc_addVirtualWeaponCargo; //b_weaponsR = array of weapon classnames [_mybox, b_itemsR, true, false] call BIS_fnc_addVirtualItemCargo; //b_itemsR = array of items classnames [_mybox, b_bagsR, true, false] call BIS_fnc_addVirtualBackpackCargo; //b_bagsR = array of bags classnames [_mybox, true, true, false] call BIS_fnc_addVirtualMagazineCargo; ["Open",false] spawn BIS_fnc_arsenal; }; }; if(playerSide == east) then { if ((typeOf player) == "O_medic_F") exitWith{ [_mybox, o_weaponsR, true, false] call BIS_fnc_addVirtualWeaponCargo; //o_weaponsR = array of weapon classnames [_mybox, o_itemsR, true, false] call BIS_fnc_addVirtualItemCargo; //o_itemsR = array of items classnames [_mybox, o_bagsR, true, false] call BIS_fnc_addVirtualBackpackCargo; //o_bagsR = array of bags classnames [_mybox, true, true, false] call BIS_fnc_addVirtualMagazineCargo; ["Open",false] spawn BIS_fnc_arsenal; }; }; Share this post Link to post Share on other sites
dchan200 18 Posted December 18, 2016 First, you should define _mybox. Second, I think your root problem is using player rather than the unit who activated the addAction which is _this select 1 in ammobox.sqf. Try this: Spoiler ammobox.sqf //ammobox.sqf private ["_mybox"]; _mybox = _this select 0; _unit = _this select 1; if(getPlayerUID(_unit) in playerUidArray) exitWith { ["Open",true] spawn BIS_fnc_arsenal; }; if(side(_unit) == west) then { if ((typeOf _unit) == "B_medic_F") exitWith{ [_mybox, b_weaponsR, true, false] call BIS_fnc_addVirtualWeaponCargo; //b_weaponsR = array of weapon classnames [_mybox, b_itemsR, true, false] call BIS_fnc_addVirtualItemCargo; //b_itemsR = array of items classnames [_mybox, b_bagsR, true, false] call BIS_fnc_addVirtualBackpackCargo; //b_bagsR = array of bags classnames [_mybox, true, true, false] call BIS_fnc_addVirtualMagazineCargo; ["Open",false] spawn BIS_fnc_arsenal; }; }; if(side(_unit) == east) then { if ((typeOf _unit) == "O_medic_F") exitWith{ [_mybox, o_weaponsR, true, false] call BIS_fnc_addVirtualWeaponCargo; //o_weaponsR = array of weapon classnames [_mybox, o_itemsR, true, false] call BIS_fnc_addVirtualItemCargo; //o_itemsR = array of items classnames [_mybox, o_bagsR, true, false] call BIS_fnc_addVirtualBackpackCargo; //o_bagsR = array of bags classnames [_mybox, true, true, false] call BIS_fnc_addVirtualMagazineCargo; ["Open",false] spawn BIS_fnc_arsenal; }; }; Share this post Link to post Share on other sites
androkiller 10 Posted December 18, 2016 16 hours ago, dchan200 said: First, you should define _mybox. Second, I think your root problem is using player rather than the unit who activated the addAction which is _this select 1 in ammobox.sqf. Try this: Reveal hidden contents ammobox.sqf //ammobox.sqf private ["_mybox"]; _mybox = _this select 0; _unit = _this select 1; if(getPlayerUID(_unit) in playerUidArray) exitWith { ["Open",true] spawn BIS_fnc_arsenal; }; if(side(_unit) == west) then { if ((typeOf _unit) == "B_medic_F") exitWith{ [_mybox, b_weaponsR, true, false] call BIS_fnc_addVirtualWeaponCargo; //b_weaponsR = array of weapon classnames [_mybox, b_itemsR, true, false] call BIS_fnc_addVirtualItemCargo; //b_itemsR = array of items classnames [_mybox, b_bagsR, true, false] call BIS_fnc_addVirtualBackpackCargo; //b_bagsR = array of bags classnames [_mybox, true, true, false] call BIS_fnc_addVirtualMagazineCargo; ["Open",false] spawn BIS_fnc_arsenal; }; }; if(side(_unit) == east) then { if ((typeOf _unit) == "O_medic_F") exitWith{ [_mybox, o_weaponsR, true, false] call BIS_fnc_addVirtualWeaponCargo; //o_weaponsR = array of weapon classnames [_mybox, o_itemsR, true, false] call BIS_fnc_addVirtualItemCargo; //o_itemsR = array of items classnames [_mybox, o_bagsR, true, false] call BIS_fnc_addVirtualBackpackCargo; //o_bagsR = array of bags classnames [_mybox, true, true, false] call BIS_fnc_addVirtualMagazineCargo; ["Open",false] spawn BIS_fnc_arsenal; }; }; Still gives the same problems due to _mybox is defined as the box, resulting in for me that no guns put in the virtual cargo (and no error messages) at all but it works fine still if i dont define _mybox but then error messages will appear but the script works to how i want it. So is there something wrong with box? Is there a way of defining _mybox as an object which only exists when the script is run and is unique for each player whom activate it? Share this post Link to post Share on other sites
theend3r 83 Posted December 18, 2016 Just a note that a more elegant way to this private ["_mybox"]; _mybox = _this select 0; _unit = _this select 1; is params["_mybox", "_unit"] Also, checking if "B_medic_F" is BLUFOR seems a bit redundant. Not that it matters since no one will get through if(getPlayerUID(_unit) in playerUidArray) exitWith { ["Open",true] spawn BIS_fnc_arsenal; }; anyway. Share this post Link to post Share on other sites
dchan200 18 Posted December 19, 2016 1 hour ago, theend3r said: params["_mybox", "_unit"] Good point. I flip flop between the two methods, but I should stick to using params when giving examples in the future. 2 hours ago, androkiller said: Still gives the same problems due to _mybox is defined as the box, resulting in for me that no guns put in the virtual cargo (and no error messages) at all but it works fine still if i dont define _mybox but then error messages will appear but the script works to how i want it. So is there something wrong with box? Is there a way of defining _mybox as an object which only exists when the script is run and is unique for each player whom activate it? Let's start over so I can get a better view of what's wrong. I'm still under the impression that you need to define _mybox and that is not the core issue. However, I would like you to clear up some of my assumptions: if(getPlayerUID(_unit) in playerUidArray) exitWith { ["Open",true] spawn BIS_fnc_arsenal; }; What is in playerUidArray? 3 hours ago, androkiller said: Still gives the same problems due to _mybox is defined as the box, resulting in for me that no guns put in the virtual cargo (and no error messages) at all but it works fine still if i dont define _mybox but then error messages will appear but the script works to how i want it. Could you post the error you get when _mybox is not defined? Could you elaborate on "works fine still if i dont define _mybox"? Are you in playerUidArray? Do you get the full arsenal? Are you playing a unit of type B_medic_F or O_medic_F? If so, do you get the limited arsenal you defined? Share this post Link to post Share on other sites
androkiller 10 Posted December 19, 2016 1 hour ago, dchan200 said: What is in playerUidArray? Could you post the error you get when _mybox is not defined? Could you elaborate on "works fine still if i dont define _mybox"? Are you in playerUidArray? Do you get the full arsenal? Are you playing a unit of type B_medic_F or O_medic_F? If so, do you get the limited arsenal you defined? becuase i am the person testing if it work i put myself in the array just to make sure that stuff works and then remove my self from it to check the rest of the stuff. the script works, does what i wanted it to do but shows me an error say i need to define _mybox as an object, if i do this the script no work anymore so i dont get wtf i am meant to define it as. if i define it as the ammobox it self it dosent work if i define it as any object on the map it does not work. i cant elaborate any more for simplicity, If i define _mybox to any object the script does not work if i do not then the script works but gives me error messages. Share this post Link to post Share on other sites
theend3r 83 Posted December 19, 2016 8 hours ago, androkiller said: becuase i am the person testing if it work i put myself in the array just to make sure that stuff works and then remove my self from it to check the rest of the stuff. the script works, does what i wanted it to do but shows me an error say i need to define _mybox as an object, if i do this the script no work anymore so i dont get wtf i am meant to define it as. if i define it as the ammobox it self it dosent work if i define it as any object on the map it does not work. i cant elaborate any more for simplicity, If i define _mybox to any object the script does not work if i do not then the script works but gives me error messages. I forgot to take a look at the way you call the script, sorry. Try: this addAction ["<t color='#0000ff'>Arsenal</t>",{[_this select 0, _this select 1] execVM "Ammobox.sqf"}]; Share this post Link to post Share on other sites