Forum Jump :

Author Message


Posts: 2
Rank:


Level: Member

Country: us
Location:
Occupation: Dental Tech
Age: 29
In-game name:

 
#1 Posted at 2015-10-10 23:26        
     
I'm running an Invade and Annex server and I've noticed some difficulties editing the original script that allows weapons only for certain squad members. If I give two weapons to two different squad members neither of them can use them.

Assuming these are the same, (its been a long time since I've coded)
	if (({player hasWeapon _x} count _sniperSpecialised) > 0) then {
		if (({player isKindOf _x} count _snipers) < 1) then {
			player removeWeapon (primaryWeapon player);
			titleText [SNIPER_MSG,"PLAIN",3];
		};
	};

is the same as this:
    	if ((({player hasWeapon _x} count _sniperGroup) > 0) && (({player isKindOf _x} count _snipers) < 1)) then {
            player removeWeapon (primaryWeapon player);
			titleText [SNIPER_MSG,"PLAIN",3];
		};
	};

and I'm trying to work something out like this but I'm certain it will allow both groups to use both weapons:
if (({player hasWeapon _x} count _sniperGroup) > 0) | (({player hasWeapon _x} count _marksmanGroup) > 0) then {
		if  (({player isKindOf _x} count _snipers) < 1) | (({player isKindOf _x} count _marksman) < 1) then {
            player removeWeapon (primaryWeapon player);
			titleText [SNIPER_MSG,"PLAIN",3];
		};
	};

Can someone help me figure this out. I want snipers to use both groups, and marksmen to use only marksmen groups.


Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 20
In-game name: Wak

 
#2 Posted at 2015-10-10 23:42        
     
Use two bars || or use or.

Also no need for all the parenthesis, might give someone cataracts.

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage

Advertisement


Author Message


Posts: 2
Rank:


Level: Member

Country: us
Location:
Occupation: Dental Tech
Age: 29
In-game name:

 
#3 Posted at 2015-10-11 01:47        
     
I thought if you use a multi Boolean you need to divide it out to keep the operations separate.

And you can use just "or" in arma scripting?

if (({player hasWeapon _x} count _sniperGroup) > 0) && (({player isKindOf _x} count _snipers) < 1)) then {
            player removeWeapon (primaryWeapon player);
			titleText [SNIPER_MSG,"PLAIN",3];
		};
	};
This should work technically. (in my brain that is)
Okay I get that, but I am confused why if I add restriction to weapons and give two different squad "roles" weapons neither can use them. It has to do with the code that's similiar to this.

I have this as a template.


#define SNIPER_MSG "Only Snipers may use this weapon system. Sniper rifle removed."
#define MRK_MSG "Only Marksman and Spotters may use this weapon system. Rifle removed."

//Weapon Groups
_sniperGroup = ["srifle_DMR_01_F","srifle_DMR_01_ACO_F"]; //there are more just to keep it short
_marksmenGroup = ["srifle_DMR_02_F","srifle_DMR_02_camo_F"];

//Squad member roles
sniperTeam = ["B_sniper_F","B_spotter_F"];
_marksman = ["B_soldier_M_F","B_spotter_F","B_recon_M_F"];

if I add all the rifles in _marksmenGroup to _sniperGroup Neither players(marksmen and snipers) would be able to use DMR02 and DMR02 Camo
I would like to make the array to be added to a group and the ones without that array cannot use those weapons.

_sniperGroup = ["srifle_DMR_01_F","srifle_DMR_01_ACO_F"]; //
_marksmenGroup = ["srifle_DMR_02_F","srifle_DMR_02_camo_F"];

//Squad member roles
sniperTeam = ["B_sniper_F","B_spotter_F"];
_marksman = ["B_soldier_M_F","B_spotter_F","B_recon_M_F"];

if (({player hasWeapon _x} count _sniperGroup) > 0) && (({player isKindOf _x} count _snipers) < 1)) then {

    if (({player hasWeapon _x} count _marksmanGroup) > 0) && (({player isKindOf _x} count _marksman) < 1)) then {
    
     player removeWeapon (primaryWeapon player);
     titleText [WEP_MSG,"PLAIN",3];
    } 
    
 };

sleep 1;

I feel if I check for sniper array first, then marksman then it should pass.

*edit* it only removes the marksman rifle if not a marksman, it passes the first statement as true then skips to the next if statement. should've figured that myself...and I'm shocked the next part hasn't worked either :(

_wepTest = 0;
_wepTest1 = 0;
    
    if ((({player hasWeapon _x} count _sniperSpecialised) > 0) && (({player isKindOf _x} count _snipers) < 1)) then {
        _wepTest = 1;
        if ((({player hasWeapon _x} count _marksmanGun) > 0) && (({player isKindOf _x} count _marksman) < 1)) then {
        _wepTest1 = 1;
            if (_wepTest > 0) then {
            player removeWeapon (primaryWeapon player);
            titleText [SNIPER_MSG,"PLAIN",3];
        } else if (_wepTest1 > 0) then {
            player removeWeapon (primaryWeapon player);
            titleText [MRK_MSG,"PLAIN",3];
        } else {
            _wepTest = 0;
            _wepTest1 = 0;
            
            
        };
            
    };
    
};

Added 14 minutes later:

Oh good lord. I over complicate things a lot. I apologize for anyone whom might actually had to site here and read through this. In case anyone is interested:

#define SNIPER_MSG "Only Snipers may use this weapon system. Sniper rifle removed."
#define MRK_MSG "Only Marksman and Spotters may use this weapon system. Rifle removed."

//Weapon Groups
_sniperGroup = ["srifle_DMR_01_F","srifle_DMR_01_ACO_F"]; //there are more just to keep it short
_marksmenGroup = ["srifle_DMR_02_F","srifle_DMR_02_camo_F"];

//Squad member roles
sniperTeam = ["B_sniper_F","B_spotter_F"];
_marksman = ["B_soldier_M_F","B_spotter_F","B_recon_M_F"];

Instead of trying to combine groups and combine scripting checks. I just let the first check pass as this:
	if (({player hasWeapon _x} count _sniperSpecialised) > 0) then {
		if (({player isKindOf _x} count _snipers) < 1) then {
			player removeWeapon (primaryWeapon player);
			titleText [SNIPER_MSG,"PLAIN",3];
		};
	};

	sleep 1;

Then I just checked the next statement on Marksman rifles by adding a sniper check:
	if (restrict_Marksman) then {
		if (({player hasWeapon _x} count _marksmanGun) > 0) then {
			if (({player isKindOf _x} count _marksman) < 1) then {
                if (({player isKindOf _x} count _snipers) < 1) then {
				player removeWeapon (primaryWeapon player);
				titleText [MRK_MSG,"PLAIN",3];
                };
			};
		};
		sleep 1;
	};

This post was edited by meezits (2015-10-11 04:06, 743 days ago)