Jump to content
Sign in to follow this  
Casio91Fin

Rearm items

Recommended Posts

Hello all.

I have a problem that should get two items added to the script, but I haven’t succeeded. That is why I am asking for help.

DLC = S. O. G. Prairie Fire

 

These two items should be added to the player

1. (vn_m67_grenade_mag) max 4.

2. (vn_b_item_firstaidkit) max 5.
 

Spoiler

this addAction  
[  
 "Rearm",  
 {  
  If (Player CanAdd ((GetArray (ConfigFile >> "CfgWeapons" >> currentWeapon player >> "Magazines")) Select 0)) Then {     
     While {Player CanAdd ((GetArray (ConfigFile >> "CfgWeapons" >> currentWeapon player >> "Magazines")) Select 0)} Do     
        {Player AddMagazine ((GetArray (ConfigFile >> "CfgWeapons" >> currentWeapon player >> "Magazines")) Select 0);};     
     Player playMove "AinvPknlMstpSrasWrflDnon_Putdown_AmovPknlMstpSrasWrflDnon";  
  if (count magazines player > 10) then {{player removeMagazineGlobal _x} forEach (magazines player select [10, 20]);};};  
 }, nil, 1.5, true, true, "", "true", 5, false, "", ""  
];

 

 

Share this post


Link to post
Share on other sites

Hey

 

Try this to add no more than 4 grenades to inventory

player addMagazines [
	"vn_m67_grenade_mag",
	4 - ({_x isEqualTo "vn_m67_grenade_mag"} count itemsWithMagazines player)
];

For first aid kits you will need to do it differently

while {
	player canAdd "vn_b_item_firstaidkit" && 
	({_x isEqualTo "vn_b_item_firstaidkit"} count itemsWithMagazines player) < 5
} do {
	player addItem "vn_b_item_firstaidkit";
};

 

Share this post


Link to post
Share on other sites

@_foley thank you it works like a dream 🤗
 

Spoiler

this addAction  

[  

 "Rearm",  

 {  

  If (Player CanAdd ((GetArray (ConfigFile >> "CfgWeapons" >> currentWeapon player >> "Magazines")) Select 0)) Then {    

     While {Player CanAdd ((GetArray (ConfigFile >> "CfgWeapons" >> currentWeapon player >> "Magazines")) Select 0)} Do    

        {Player AddMagazine ((GetArray (ConfigFile >> "CfgWeapons" >> currentWeapon player >> "Magazines")) Select 0);};    

     Player playMove "AinvPknlMstpSrasWrflDnon_Putdown_AmovPknlMstpSrasWrflDnon";  

  if (count magazines player > 15) then {{player removeMagazineGlobal _x} forEach (magazines player select [15, 20]);};

  player addMagazines ["vn_m67_grenade_mag", 4 - ({_x isEqualTo "vn_m67_grenade_mag"} count itemsWithMagazines player)];

  while {player canAdd "vn_b_item_firstaidkit" && ({_x isEqualTo "vn_b_item_firstaidkit"} count itemsWithMagazines player) < 5} do

  {player additem "vn_b_item_firstaidkit";};

  };  

 }, nil, 1, true, true, "", "true", 5, false, "", ""  

];

 

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  

×