Home   Help Search Login Register  

Author Topic: how to get name of Vehicle (eg M1Abrams)  (Read 1088 times)

0 Members and 1 Guest are viewing this topic.

Ronald Speirs

  • Guest
how to get name of Vehicle (eg M1Abrams)
« on: 09 Jul 2003, 21:53:15 »
How can I get the name of a vehicle (eg. M1Abrams) a unit is in ?
I need it to count how many vehicles of a certain type are (still) on the battlefield after a battle has taken place.

Example:

I have defined W1 to be an array with all the units of group1:

W1 = units group1

I select first unit of the group:

_element = w1 select 0

I thought I could get the name of the vehicle like this:

_vehicle = name vehicle _element

Then print it on screen via the hint command:

hint format ["%1 is in a %2", _element, _vehicle]

I get : "West Bravo black:1 is in a James Pound" while I wanted to have "West Bravo black:1 is in a M1Abrams".

How could I do this  ???

Thanks for any help offered.

Ronald Speirs

Offline Igor Drukov

  • Contributing Member
  • **
  • Conscientious Subjector
Re:how to get name of Vehicle (eg M1Abrams)
« Reply #1 on: 09 Jul 2003, 22:01:51 »
Replace :

Quote
_vehicle = name vehicle _element

by :

Code: [Select]
_vehicle=typeof vehicle _element
« Last Edit: 09 Jul 2003, 22:02:37 by Igor Drukov »

Ronald Speirs

  • Guest
Re:how to get name of Vehicle (eg M1Abrams)
« Reply #2 on: 09 Jul 2003, 23:45:36 »
Now it works.  :D

Thanks a lot. I was really stuck.

Looks like Typeof is a new command.

I would be grateful if you could tell me where I can find an overview of these new commands.

There was no 'Typeof' command in the latest version of the BIS comref (doc stated commands for version 1.85).

Cheerio

Ronald Speirs
101 Airborne Division
506 Infantry Regiment
Easy-Company

Offline Igor Drukov

  • Contributing Member
  • **
  • Conscientious Subjector
Re:how to get name of Vehicle (eg M1Abrams)
« Reply #3 on: 09 Jul 2003, 23:53:53 »
Yes, TypeOf is the one command which was added with the 1.90 patch. It is indeed very useful. Don't worry, there is no other (well, to my knowledge).

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:how to get name of Vehicle (eg M1Abrams)
« Reply #4 on: 10 Jul 2003, 18:25:16 »
u cud also u use counttype command ;D

dats compitable w/ all OFP vers  8)  ;)

goes somin like dat

"Tank" countType array > 0

da tank is da type of da vehicle
array is array of vehicles ur checkin
nd da num is just da num u compare em 2 ;)

;D

btw if da prob is solved - solve da topic ;)

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Ronald Speirs

  • Guest
Re:how to get name of Vehicle (eg M1Abrams)
« Reply #5 on: 12 Jul 2003, 10:52:09 »
With the 'typeof' command I don't need to know how the vehicle is exactly called (usefull when using  AddOns).

I think the 'CountType' command is not as flexible as the 'Typeof' command.

With the CountType command you probably have to define the array of possible vehicles yourself. Something like _array = ["M1Abrams", "M113", ...]

Or am I wrong ?

Can you give a more practical example of the array you are using with the CountType command ?

In relation to this subject, I have a small additional question. How can I found out if a vehicle (variable unit) is a helicopter.

eg. vehicle Player1 --> how can I know if the vehicle of Player1 is a helicopter object ?

"helicopter" countType vehicle Player1 will probably not work because countType works on arrays. Do I have to create an array with all the possible helicopter names  ???

Cheerio

Ronald Speirs

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:how to get name of Vehicle (eg M1Abrams)
« Reply #6 on: 12 Jul 2003, 12:52:57 »
That's exactly what you have to do. But it's not nearly as hard as you think ;)

? "Helicopter" counttype [vehicle player] == 1: hint "You're in a helicopter"

You don't need to assign an array a variable name for it to be used... you can just throw some square brackets around the object you want to make an array out of ;)

Counttype is much more versatile, but will only work with version 1.91...