Jump to content
Sign in to follow this  
malakdecaen

error Add Magazine to the good slot ??

Recommended Posts

Hi everybody ,

I know there is a problem for adding magazine to the good slot , you need to add a container , magazine and after a weapon

but the problem when my script load , the magazine slot on the weapon is empty .

Here is an example of how my saving script save :

15:52:18 "_x_0: ["U_C_Poloshirt_Pants"]"
15:52:18 "_x_1: ["V_BandollierB_khk"]"
15:52:18 "_x_2: ["B_Carryall_Base"]"
15:52:18 "_x_3: [""]"
15:52:18 "_x_4: ["arifle_MX_GL_F"]"
15:52:18 "_x_5: [""]"
15:52:18 "_x_6: ["ItemFlashlight"]"
15:52:18 "_x_7: ["ItemMap","ItemCompass","ItemRadio"]"
15:52:18 "_x_8: ["muzzle_snds_H","acc_flashlight","optic_Aco"]"
15:52:18 "_x_9: []"
15:52:18 "_x_10: ["","",""]"
15:52:18 "_x_11: ["PartGlass"]"
15:52:18 "_x_12: [""]"
15:52:18 "_x_13: ["U_B_Wetsuit","UGL_FlareWhite_F","UGL_FlareWhite_F","UGL_FlareWhite_F","UGL_FlareWhite_F",]"
15:52:18 "_x_14: [""]"
15:52:18 "_x_15: [""]"
15:52:18 "_x_16: ["arifle_MX_GL_F","ItemFlashlight"]"
15:52:18 "_x_17: ["30Rnd_65x39_caseless_mag_Tracer",15]"
15:52:18 "_x_18: []"
15:52:18 "_x_19: []"
15:52:18 "_x_20: ["arifle_MX_GL_F"]"

So you can see , in 17 is my magazine loaded with the exacte number of ammo in it .

and here is the loading script :

/*
--- Script fait par =[TTK]= Yourry ---
--- Chargement de l'inventaire sauvegardé ---
--- ARMA 3 ---
--- S.E.S ---
-- V0.90--
*/


private ["_loadout", "_i", "_details"];


_loadout = _this select 0;

diag_log"SES_Loadgear----START";

if(isNil {_loadout}) exitWith {hint"ERREUR: pas de sauvegarde d'inventaire !!!"}; //Slot data doesn't exist

//DEbug
_nb = 0;
diag_log"--------------------------";
diag_log format ["SES_Load_gear---NAME PLAYER: %1",(name player)];
{
	diag_log format ["_x_%2: %1",_x,_nb];
	_nb = _nb + 1;
} foreach _loadout;
diag_log"--------------------------";


//Strip the unit down
RemoveAllWeapons player;
{player removeMagazine _x;} foreach (magazines player);
removeUniform player;
removeVest player;
removeBackpack player;
removeGoggles player;
removeHeadGear player;

{
player unassignItem _x;
player removeItem _x;
} foreach (assignedItems player);

for "_i" from 1 to (count _loadout) do {
switch (_i-1) do {
//---------------------------------------------------------------------------------------------------------------------------------------------
	//Donne du sac
	case (2) : {
		if(count (_loadout select (_i-1))>0) then {
			{
				if(_x!="") then {
					player addBackpack _x;
					//Supprime le contenu de certain sac déjà pré-rempli :
					{
					player removeItemFromBackpack  _x; /*diag_log format ["%1",_x];	*/
					}foreach (backPackItems player);
				};
			} foreach (_loadout select (_i-1));
		};
	};

	//Chargement du sac à dos 		
	case (13) : {
		if(count (_loadout select (_i-1))>0) then {
			{		
				if(_x!="") then {
					_details = [_x] call VAS_fnc_fetchCfgDetails;
					//diag_log format ["Détails_sac: _x: %1 // %2",_x,_details];						
					switch (_details select 6) do {
						case "CfgMagazines": {(unitBackpack player) addMagazineCargoGlobal [_x,1];};
						//case "CfgWeapons": {(unitBackpack player) addWeaponCargoGlobal [_x,1];};	
						case "CfgWeapons": {if(count(_details select 7)==0)then{(unitBackpack player) addItemCargoGlobal [_x,1];}else{(unitBackpack player) addWeaponCargoGlobal [_x,1];};};								
						//default {(unitBackpack player) addItemCargoGlobal [_x,1];};		
						default {(unitBackpack player) addWeaponCargoGlobal [_x,1];};						
					};
				};
			} foreach (_loadout select (_i-1));			
		};
	};
//------------------------------------------------------------------------------------------------------------------------------------------------
	//Donne un uniforme
	case (0) : {		
		if(count (_loadout select (_i-1))>0) then {
			{
				if(_x!="") then {	
					player addUniform _x;
					/*diag_log format ["%1",_x];*/	
				};
			} foreach (_loadout select (_i-1));
		};		
	};

	//Chargement de l'uniforme :
	case (11) : {
		if(count (_loadout select (_i-1))>0) then {
			{
				if(_x!="") then {
					_details = [_x] call VAS_fnc_fetchCfgDetails;
					//diag_log format ["Détails_uniform: _x: %1 // %2",_x,_details];
					switch (_details select 6) do {
					case "CfgMagazines": {player addItemToUniform _x;};
					case "CfgWeapons": {if(count(_details select 7)==0)then{player addItemToUniform _x;}else{player addItemToUniform _x;}};
					default {player addItemToUniform _x;	/*diag_log format ["Item: %1",_x];*/	};
					};
				};
			} foreach (_loadout select (_i-1));
		};
	};
//---------------------------------------------------------------------------------------------------------------------------------------------
	//Donne une veste
	case (1) : {
		if(count (_loadout select (_i-1))>0) then {
			{
				if(_x!="") then {
					player addVest _x; /*diag_log format ["%1",_x];	*/
				};
			} foreach (_loadout select (_i-1));
		};
	};

	//Chargement de la veste :
	case (12) : {
		if(count (_loadout select (_i-1))>0) then {
			{
				if(_x!="") then {
					_details = [_x] call VAS_fnc_fetchCfgDetails;
					//diag_log format ["Détails_uniform: _x: %1 // %2",_x,_details];
					switch (_details select 6) do {
						case "CfgMagazines": {player addItemToVest _x;};
						case "CfgWeapons": {if(count(_details select 7)==0)then{player addItemToVest _x;}else{player addItemToVest _x;}};
						default {player addItemToVest _x;	/*diag_log format ["Item: %1",_x];*/	};
					};
				};
			} foreach (_loadout select (_i-1));
		};
	};
//--------------------------------------------------------------------------------------------------------------------------------------------
	//Rend le nombre de balle exacte dans le chargeur des armes :
	case (17) : {
		if(count (_loadout select (_i-1))>0) then {
			if(((_loadout select (_i-1))select 0) !="") then {
				if(count (_loadout select (_i-1))>1) then {
					player addMagazine [((_loadout select (_i-1))select 0),((_loadout select (_i-1))select 1)];
				}else{
					player addMagazine ((_loadout select (_i-1))select 0);
				};
				/*diag_log format ["%1 // %2",((_loadout select (_i-1))select 0),((_loadout select (_i-1))select 1)];*/
			};
		};
	};
	case (18) : {
		if(count (_loadout select (_i-1))>0) then {
			if(count(_loadout select (_i-1))>1)then{
				if(count((_loadout select (_i-1))>1))then{
					player addMagazine [((_loadout select (_i-1))select 0),((_loadout select (_i-1))select 1)];
				}else{
					player addMagazine ((_loadout select (_i-1))select 0);
				};
				/*diag_log format ["%1 // %2",((_loadout select (_i-1))select 0),((_loadout select (_i-1))select 1)];*/
			};
		};
	};
	case (19) : {
		if(count (_loadout select (_i-1))>0) then {
			if(((_loadout select (_i-1))select 0) !="") then {
				if(count(_loadout select (_i-1))>1)then{
					player addMagazine [((_loadout select (_i-1))select 0),((_loadout select (_i-1))select 1)];
				}else{
					player addMagazine ((_loadout select (_i-1))select 0);
				};
				/*diag_log format ["%1 // %2",((_loadout select (_i-1))select 0),((_loadout select (_i-1))select 1)];*/
			};
		};
	};
//------------------------------------------------------------------------------------------------------------------------------------------
	//Donne les armes du joueurs :
	case (4) : {
		if(count (_loadout select (_i-1))>0) then {
			{
				if(_x!="") then {
					player addWeapon _x;
				};
			} foreach (_loadout select (_i-1));
			//Supprime les items des armes par défaut
			{player removePrimaryWeaponItem _x}foreach (primaryWeaponItems player);
		};
	};
	case (5) : {
		if(count (_loadout select (_i-1))>0) then {
			{
				if(_x!="") then {
					player addWeapon _x;
				};
			} foreach (_loadout select (_i-1));
			//Supprime les items des armes par défaut
			//{player removeSecondaryWeaponItem _x}foreach (secondaryWeaponItems player);
		};
	};
	case (6) : {
		if(count (_loadout select (_i-1))>0) then {
			{
				if(_x!="") then {
					player addWeapon _x;
				};
			} foreach (_loadout select (_i-1));
			//Supprime les items des armes par défaut
			{player removeHandgunItem _x}foreach (handgunItems player);
		};
	};
	case (20) : {
		if(count (_loadout select (_i-1))>0) then {
			{
				if(_x!="") then {
					player selectWeapon (_x);
				};
			} foreach (_loadout select (_i-1));
		};
	};
//-------------------------------------------------------------------------------------------------------------------------------------------
	//Donne les items
	case (7) : {
		if(count (_loadout select (_i-1))>0) then {
			{
				if(_x!="") then {
				player addweapon _x; // Assign l'arme directement dans le bon slot sans passer par l'inventaire
				}else {
				player linkItem _x; // Assign l'arme directement dans le bon slot sans passer par l'inventaire
				//player addItem _x;
				//player assignItem _x;
				};
			} foreach (_loadout select (_i-1));
		};
	};

//------------------------------------------------------------------------------------------------------------------------------------------
	//Donne le casque
	case (14) : {
		if(count (_loadout select (_i-1))>0) then {
			{
				if(_x!="") then {
					player addHeadGear _x;
				};
			} foreach (_loadout select (_i-1));
		};
	};

//------------------------------------------------------------------------------------------------------------------------------------------
	//Donne les lunettes
	case (15) : {
		if(count (_loadout select (_i-1))>0) then {
			{
				if(_x!="") then {
					player addGoggles _x;
				};
			} foreach (_loadout select (_i-1));
		};
	};
//-----------------------------------------------------------------------------------------------------------------------------------------
	//Assigne les items l'arme principale
	case (8) : {
		if(count (_loadout select (_i-1))>0) then {
			{
				if(_x!="") then {
					//ON lance un spawn pour temporiser le montage des armes sinon l'ajout d'item déconne
					_x spawn {sleep 1;player addPrimaryWeaponItem _this;};
				};
			} foreach (_loadout select (_i-1));
		};
	};

	//Assigne les items l'arme secondaire
	case (9) : {
		if(count (_loadout select (_i-1))>0) then {
			{
				if(_x!="") then {
					//ON lance un spawn pour temporiser le montage des armes sinon l'ajout d'item déconne
					_x spawn {sleep 1;player addSecondaryWeaponItem _this;};
				};
			} foreach (_loadout select (_i-1));
		};
	};

	//Assigne les items sur le pistolet
	case (10) : {
		if(count (_loadout select (_i-1))>0) then {
			{
				if(_x!="") then {
					//ON lance un spawn pour temporiser le montage des armes sinon l'ajout d'item déconne
					_x spawn {sleep 1;player addHandgunItem _this;};
				};
			} foreach (_loadout select (_i-1));
		};
	};
};
};

//Recharge les armes
diag_log"SES_Loadgear----END";

With this script , my magazine are placed in my vest but not in the good slot .

Can you help me please ?

Thanks a lot for you'r times .

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  

×