OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: websnake on 23 Oct 2005, 20:24:03

Title: Detecting Mags
Post by: websnake on 23 Oct 2005, 20:24:03
I want to be able to detect if a player has a magazine.

For example the player has an m21 magazine, he doesnt have a m21 rifle but i want to be able to know if he holds a magazine.

I know i can use 'hasweapon' to know if the man has a certain weapon, but i need something like this for magazines.

cheers
Title: Re:Detecting Mags
Post by: Planck on 23 Oct 2005, 20:27:27
Hmmm........

magazines player

maybe?


Planck
Title: Re:Detecting Mags
Post by: websnake on 23 Oct 2005, 21:41:22
 I've tried 'magazines player' and this returns an array of mags held by the player, how do i within a script search this array for one specific type of mag. for example an m21 magazine?
Title: Re:Detecting Mags
Post by: THobson on 23 Oct 2005, 22:55:38
if ("M21" in magazines player) then {....} else {....}
Title: Re:Detecting Mags
Post by: websnake on 24 Oct 2005, 00:33:29
how do i run this for more than one player?
Title: Re:Detecting Mags
Post by: websnake on 24 Oct 2005, 01:12:53
ok i think i have it working for more than one player, tho it needs more testing. I have now hit another problem, i'm trying to add an action to the player when he has an m21 mag

example - _u          = _this select 0
_mags = magazines _u
if ("m21" in magazines _u) then {_u addaction ["Got one","true.sqs"]}
if ("m60" in magazines _u) then {_u addaction ["Got two","true1.sqs"]}

problem is that it keeps adding the same addaction to the menu over and over again, i also want to delete the action when the script true or true1 has been fired. any suggestions?