OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: gundernak on 16 Jan 2004, 00:34:54

Title: condition: unit has any weapon or he has not weapon at all?
Post by: gundernak on 16 Jan 2004, 00:34:54
Hi all,

this Q is based on my previous '@ or loop' post.

Is there a good solution to check the unit has any weapon or to check the unit has no wepon at all.

Because now I use a script like this:

Code: [Select]
_dude = _this select 0

@ _dude hasWeapon "M16" or _dude hasWeapon "AK74SU" or _dude hasWeapon "AK74" or _dude hasWeapon "AK74GrenadeLauncher" or _dude hasWeapon "AK47CZ" or _dude hasWeapon "AK47" or _dude hasWeapon "AK47GrenadeLauncher" or _dude hasWeapon "PK" or _dude hasWeapon "SVDDragunov" or _dude hasWeapon "RPGLauncher" or _dude hasWeapon "HK" or _dude hasWeapon "M4" or _dude hasWeapon "M16GrenadeLauncher" or _dude hasWeapon "M60" or _dude hasWeapon "M21" or _dude hasWeapon "LAWLauncher"

_dude setCaptive false

exit
offcourse these are all weapon type he can have

...and I guess there is a much wiser way to check it...

thanks in advance
Title: Re:condition: unit has any weapon or he has not weapon at all?
Post by: Planck on 16 Jan 2004, 00:43:55
Have you tried playing with weapons unit.


Planck
Title: Re:condition: unit has any weapon or he has not weapon at all?
Post by: gundernak on 16 Jan 2004, 00:52:28
No, I have not tryed.

Just now I have found it in the off com ref, unoff com ref does not containt this... ???

Anyway I do not know how can I build it to a check...
I have to check if a unit has ANY weapon, or has not ANY AT ALL...

Could you give me a hint on this
Title: Re:condition: unit has any weapon or he has not weapon at all?
Post by: Planck on 16 Jan 2004, 00:55:21
I suppose you could check if the array was empty.....null.

This would mean he had no weapons.

On the other hand if the array was not empty.........he has weapons.


Planck
Title: Re:condition: unit has any weapon or he has not weapon at all?
Post by: macguba on 16 Jan 2004, 01:46:48
Unofficial com ref, although excellent and worthy of consultation on every point, is rather old.    A lot of commands have been added since it was written.     The "new" version of it is the online command ref in the Ed Depot, which has helpful Comments added for many commands.
Title: Re:condition: unit has any weapon or he has not weapon at all?
Post by: gundernak on 16 Jan 2004, 02:08:16
thanks Planck, I've tryed and OK :)

thanks macguba ;)