OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Ronald Speirs 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
-
Replace :
_vehicle = name vehicle _element
by :
_vehicle=typeof vehicle _element
-
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
-
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).
-
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
-
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
-
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...