Jump to content
Sign in to follow this  
fn_Quiksilver

How to restrict a Magazine? (not weapon)

Recommended Posts

This does not seem to work in the .sqf:

if (player hasMagazine "SatchelCharge_Remote_Mag") then

{

if ((playerSide == west && typeOf player != "B_soldier_exp_F") || (playerside == east && typeOf player != "O_soldier_exp_F") || (playerside == resistance && typeOf player != "I_soldier_exp_F")) then

{

player removeMagazine "SatchelCharge_Remote_Mag";

player globalChat "Only Explosives Specialists are trained with this item. Explosive removed.";

};

};

Share this post


Link to post
Share on other sites

There is no hasMagazine command

You can try to do this with a TAKE eventhandler

Quick and dirty (and untested):

TRN_fnc_checkMagazine = {

if ((_this select 2) == "SatchelCharge_Remote_Mag") && ((playerSide == west && typeOf player != "B_soldier_exp_F") || (playerside == east && typeOf player != "O_soldier_exp_F") || (playerside == resistance && typeOf player != "I_soldier_exp_F"))) then
{
	player removeMagazine (_this select 2);
	player globalChat "Only Explosives Specialists are trained with this item. Explosive removed.";
};
};

player addEventhandler ["TAKE", _this spawn TRN_fnc_checkMagazine];

Share this post


Link to post
Share on other sites

That's probably fine, but I think there are still some situations where the Take eventhandler is buggy. For example, I know it doesn't work properly when you pick up an explosive that has been spawned. Not a common situation, but still.

Instead of hasMagazine you would want

 if ("SatchelCharge_Remote_Mag" in (magazines player)) then {

Share this post


Link to post
Share on other sites

If you want to make sure that the mag will never be used you can put the code that checks it in onEachFrame, not sure if that would have an impact on performance, but I use onEachFrame with a pretty complex code with lots of ifs and math calculations, and it doesn't seem to affect the game performance, so I guess a simple mag check wont cause many problems.

Share this post


Link to post
Share on other sites

Did anyone get this to work? I tried the OP's method with

if ("SatchelCharge_Remote_Mag" in (magazines player)) then {

but it did not work at all.

Share this post


Link to post
Share on other sites
	 
if ("SatchelCharge_Remote_Mag" in (magazines player)) then {
if (!(typeOf player in ["B_soldier_exp_F", "B_G_Soldier_exp_F", "O_soldier_exp_F", "I_soldier_exp_F"])) then {
	player removeMagazine "SatchelCharge_Remote_Mag";
	player globalChat "Only Explosives Specialists are trained with this item. Explosive removed.";
};
};

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  

×