Jump to content
austin_medic

Another logic problem?

Recommended Posts

Alright so I'm trying to get some arrays of weapons, magazines, etc, into a listbox, that worked out fine.

 

Trying to be able to purchase these items is a bit of a problem as I can't seem to be able to get the price value out of the array that holds that information.

 

supplyBoxPurchase.sqf //this is called from anotehr function that grabs data from the dialog after an item is selected 

_gear = _this select 0;
_crate = AUSMD_buyBox;
_crate allowDamage false;
clearWeaponCargoGlobal _crate;
clearMagazineCargoGlobal _crate;
clearBackpackCargoGlobal _crate;
clearItemCargoGlobal _crate;

_isWep = isClass (configFile >> "CfgWeapons" >> (_gear select 0));
_isMag = isClass (configFile >> "CfgMagazines" >> (_gear select 0));
_isItem = isClass (configFile >> "CfgWeapons" >> (_gear select 0));
_isBag = isClass (configFile >> "CfgVehicles" >> (_gear select 0));
if (_isWep) then {
	_arrPath = ([Sand_Weapons,(_gear select 0)] call BIS_fnc_findNestedElement);
	_pathPrice = (Sand_Weapons select _arrPath select 0) select 1;
	_price = _pathPrice;
	if(_price > GV_Sand_Balance) exitWith {hint "You cannot afford Weapons!";};
	if(isNil "_price") then {_price = 1000;hint "there was an error";};
	GV_Sand_Balance = GV_Sand_Balance - _price;
	publicVariable "GV_Sand_Balance";
	_crate addWeaponCargoGlobal [(_gear select 0), (_gear select 1)];
	hint format ["Purchased for $ %1",_price];
};
if(_isMag) then
{
	_arrPath = ([Sand_Magazines,(_gear select 0)]) call BIS_fnc_findNestedElement;
	_pathPrice = Sand_Magazines select (_arrPath select 0) select 1;
	_price = _pathPrice;
	if(_price > GV_Sand_Balance) exitWith {hint "You cannot afford Mags!";};
	GV_Sand_Balance = GV_Sand_Balance - _price;
	publicVariable "GV_Sand_Balance";
	_crate addMagazineCargoGlobal [(_gear select 0), (_gear select 1)];
	hint format ["Purchased for $ %1",_price];
};
if(_isItem) then
{
	_arrPath = ([Sand_Items,(_gear select 0)]) call BIS_fnc_findNestedElement;
	_pathPrice = Sand_Items select (_arrPath select 0) select 1;
	_price = _pathPrice;
	if(_price > GV_Sand_Balance) exitWith {hint "You cannot afford Items!";};
	GV_Sand_Balance = GV_Sand_Balance - _price;
	publicVariable "GV_Sand_Balance";
	_crate addItemCargoGlobal [(_gear select 0), (_gear select 1)];
	hint format ["Purchased for $ %1",_price];
};
if(_isBackpack) then
{
	_arrPath = ([Sand_Backpacks,(_gear select 0)]) call BIS_fnc_findNestedElement;
	_pathPrice = Sand_Backpacks select (_arrPath select 0) select 1;
	_price = _pathPrice;
	if(_price > GV_Sand_Balance) exitWith {hint "You cannot afford Items!";};
	GV_Sand_Balance = GV_Sand_Balance - _price;
	publicVariable "GV_Sand_Balance";
	_crate addBackpackCargoGlobal [(_gear select 0), (_gear select 1)];
	hint format ["Purchased for $ %1",_price];
};

 

 

 

my price arrays:


sand_Weapons =
[
	["arifle_MX_Black_F", 1000],
	["arifle_MXC_Black_F", 1000],
	["arifle_MXM_Black_F", 2000],
	["srifle_EBR_F", 3000],
	["srifle_DMR_03_F", 3000],
	["LMG_Mk200_F", 4000],
	["LMG_Zafir_F", 5000],
	["Rangefinder", 1000],
	["Binocular", 500]
];

sand_Magazines =
[
	["30Rnd_65x39_caseless_mag", 10],
	["200Rnd_65x39_cased_Box", 75],
	["200Rnd_65x39_cased_Box_Tracer", 100],
	["20Rnd_762x51_Mag", 10],
	["150Rnd_762x54_Box", 75],
	["150Rnd_762x54_Box_Tracer", 100],
	["SmokeShell", 30],
	["SmokeShellRed", 30],
	["SmokeShellOrange", 30],
	["SmokeShellYellow", 30],
	["SmokeShellGreen", 30],
	["SmokeShellBlue", 30],
	["SmokeShellPurple", 30],
	["Chemlight_red", 5],
	["Chemlight_yellow", 5],
	["Chemlight_blue", 5],
	["Chemlight_green", 5]
];

sand_Items =
[
	["optic_Aco", 1000],
	["optic_mrco", 2000],
	["optic_Hamr", 2000],
	["optic_SOS", 2000],
	["bipod_01_F_blk", 50],
	["acc_flashlight", 50],
	["Medikit", 250],
	["FirstAidKit", 50],
	["ItemGPS", 500],
	["B_UavTerminal", 1000],
	["U_BG_Guerrilla_6_1", 100],
	["U_B_FullGhillie_lsh", 100],
	["U_B_GhillieSuit", 100],
	["U_B_Wetsuit", 100],
	["V_RebreatherB", 800],
	["G_B_Diving", 200],
	["MineDetector", 600]
];

sand_Backpacks =
[
	["B_UAV_01_backpack_F", 2000],
	["B_AssaultPack_rgr", 100],
	["I_HMG_01_weapon_F", 15000],
	["I_GMG_01_weapon_F", 20000],
	["I_Mortar_01_weapon_F", 25000],
	["I_HMG_01_support_F", 1000],
	["I_GMG_01_support_F", 1000],
	["I_Mortar_01_support_F", 1000],
	["B_Parachute", 2500]
];

Share this post


Link to post
Share on other sites

Nevermind, I solved the problem, wasn't related to this at all (dont know why you cant convert strings to numbers -_-)

Share this post


Link to post
Share on other sites

Nevermind, I solved the problem, wasn't related to this at all (dont know why you cant convert strings to numbers -_-)

Use parseNumber to convert strings to numbers.

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

×