Home   Help Search Login Register  

Author Topic: Two questions  (Read 553 times)

0 Members and 1 Guest are viewing this topic.

klavan

  • Guest
Two questions
« on: 27 Jul 2005, 19:24:54 »
First question
I wonder if is possible to determine the "kind" of an object (men, tank, apc, and so on)
I've tried these lines:

? typeof _dude != "Man" : exit
?_dude != typeof "Man" : exit

In the first case I receive an error message (about object and string).
In the second case I don't receive any error message, but the script exit even if _dude is a man  (maybe because i'm using the wrong command or beacuse ofp doesn't recognize "man" as a class?).
My overall objective is to exit the script if the object is not a man (it's part of a close combat script).
 

Second question
Is there a way to determine if a man is disarmed? Or have i to check if the man hasn't any kind of weapon that may be presents in the scenario?

Thanks for your help
Klavan
« Last Edit: 27 Jul 2005, 19:27:48 by klavan »

Offline Blanco

  • Former Staff
  • ****
Re:Two questions
« Reply #1 on: 27 Jul 2005, 20:06:33 »
Quote
I wonder if is possible to determine the "kind" of an object (men, tank, apc, and so on)

Yes, the command you'll need is  CountType


Code: [Select]
?"man" countype [_dude] > 0 : hint "_dude is a man"
or

Code: [Select]
?"tank" counttype [_dude] <= 0 : hint "_dude is not a tank"
Make sure the operand is a string and array or list
You can check other types as well :

"all"
"land"
"air"
"tank"
"APC"
"man"
"helicopter"
...
For more vehicletypes check the cfgvehicles section in the command reference.

Quote
Second question
Is there a way to determine if a man is disarmed? Or have i to check if the man hasn't any kind of weapon that may be presents in the scenario?

try :

Code: [Select]
?Count weapons _unit == 0 : hint "_unit is disarmed"
*edit*

Hmm, he can still have some magz...

Code: [Select]
?Count weapons _unit == 0 && count magazines _unit == 0: hint "_unit is completly disarmed"
:)
« Last Edit: 27 Jul 2005, 20:13:06 by Blanco »
Search or search or search before you ask.

Offline 456820

  • Contributing Member
  • **
Re:Two questions
« Reply #2 on: 27 Jul 2005, 20:09:41 »
2nd question is has weapon eg
unit_name !hasweapon "weapon name"
i think thats the right syntax
« Last Edit: 27 Jul 2005, 20:28:33 by 456820 »

klavan

  • Guest
Re:Two questions
« Reply #3 on: 27 Jul 2005, 20:26:57 »
OK, both the two suggestions by Blanco were right.
Thank you man.
Klavan

PS
I've to learn to use my own brain more often, i think...... 8)