OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Dane on 25 Nov 2004, 22:12:58
-
What's wrong with this script?
_aaaPos1 = ["randomAAA1","randomAAA2","randomAAA3"]
_ranPos1 = ( _aaaPos1 select ( random ( (count _aaaPos1) - 0.5 ) ) )
_vehicle = ["VIT_BMD3","VIT_BMD3M","VIT_BMP3","VIT_BMP3A","VIT_BTR80"]
_ranVehicle1 = ( _vehicle select ( random ( (count _vehicle) - 0.5 ) ) )
#Sector1Create
_tank1 = "DKMM_TUNGUSKA" createvehicle getMarkerPos _ranPos1
"Suchcrew" createunit [getMarkerPos _ranPos1, earm1, "ec1 = this", 1, "SERGEANT"]
"Suchcrew" createunit [getMarkerPos _ranPos1, earm1, "ec2 = this", 1, "CORPORAL"]
"Suchcrew" createunit [getMarkerPos _ranPos1, earm1, "ec3 = this", 1, "PRIVATE"]
ec1 moveincommander _tank1
ec2 moveingunner _tank1
ec3 moveindriver _tank1
_escort1 = _ranVehicle1 createvehicle getMarkerPos _ranPos1
_IFV = ["VIT_BMD3","VIT_BMD3M","VIT_BMP3","VIT_BMP3A"]
_APC = ["VIT_BTR80"]
if (_escort1 == typeOf _IFV) : goto "IFV1"
~0.5
if (_escort1 == typeOf_APC) : goto "APC1"
But the script doesn't go to "IFV1" or "APC" ???
-
Maybe you could try:
? (_escort in _IFV) : goto "IFV1"
~0.5
goto "APC1"
Planck
-
No _escort wouldn't fit in APC because _escort should be an APC or IFV...
this should define IFV and APC...
_vehicle = ["VIT_BMD3","VIT_BMD3M","VIT_BMP3","VIT_BMP3A","VIT_BTR80"]
_ranVehicle1 = ( _vehicle select ( random ( (count _vehicle) - 0.5 ) ) )
_escort1 = _ranVehicle1 createvehicle getMarkerPos _ranPos1
_IFV = ["VIT_BMD3","VIT_BMD3M","VIT_BMP3","VIT_BMP3A"]
_APC = ["VIT_BTR80"]
this should determine if spawned vehicle is APC or IFV...
if (_escort1 == typeOf _IFV) : goto "IFV1"
~0.5
if (_escort1 == typeOf _APC) : goto "APC1"
but it doesn't
-
EDIT: Nvm. :P
:beat: *Gets Shot* :beat:
-
First off, welcome to the forums Dane.
It's always good to see new faces :)
Two problems with the line: if (_escort1 == typeOf _IFV) : goto "IFV1"
- You're mixing syntaxes... try either:
if (condition) then {command} or
? (condition) : command
- Planck's hit the nail on the head... well... he's using the right end of the hammer ;D
You're trying to compare an object to a whole array, instead of just one element.
Also you've got the typeOf in the wrong place.[/list]
Try something like this:
? ((typeOf _escort1) in _IFV): goto "IFV1"
~0.5
goto "APC1"
-
I think misunderstood what Planck ment with (_escort in _IFV) ::)
Thanks, i'll try this as soon i get home from work.
-
I don't get it...
_IFV is an array with classname of vehicles. right?
_ranvehicle is a random created vehicle. The types of the vehicles are stored in the _vehicle array. Still OK?
Now afaiK typeof only works with objects, you are calling it with an array...
maybe this works...
if (typeof _escort1 in _IFV) : goto "IFV1"
~0.5
if (typeof _escort1 in _APC) : goto "APC1"
**oops**
Planck allready told this...
-
Nope it doesn't.
I keep getting an error message, something with type array expected object.
So i guess your right it doesn't work with arrays, only objects but thanks anyway i'll keep experimenting with it and try a different approach maybe.
-
Does this work? :P
_aaaPos1 = ["randomAAA1","randomAAA2","randomAAA3"]
_ranPos1 = ( _aaaPos1 select ( random ( (count _aaaPos1) - 0.5 ) ) )
_vehicle = ["VIT_BMD3","VIT_BMD3M","VIT_BMP3","VIT_BMP3A","VIT_BTR80"]
_ranVehicle1 = ( _vehicle select ( random ( (count _vehicle) - 0.5 ) ) )
#Sector1Create
_tank1 = "DKMM_TUNGUSKA" createvehicle getMarkerPos _ranPos1
"Suchcrew" createunit [getMarkerPos _ranPos1, earm1, "ec1 = this", 1, "SERGEANT"]
"Suchcrew" createunit [getMarkerPos _ranPos1, earm1, "ec2 = this", 1, "CORPORAL"]
"Suchcrew" createunit [getMarkerPos _ranPos1, earm1, "ec3 = this", 1, "PRIVATE"]
ec1 moveincommander _tank1
ec2 moveingunner _tank1
ec3 moveindriver _tank1
_escort1 = _ranVehicle1 createvehicle getMarkerPos _ranPos1
_IFV = ["VIT_BMD3","VIT_BMD3M","VIT_BMP3","VIT_BMP3A"]
_APC = ["VIT_BTR80"]
_type = format ["%1",typeof _escort1]
? (_type in _IFV) : goto "IFV1"
~0.5
? (_type in _APC) : goto "APC1"
-
Fraid not. The random vehicle get spawned but script doesn't go to "APC or "IFV" were the different crews an soldiers get spawned. But this time i didn't recieve any error messages... weird :-\
-
Thats weird because it works for me. ???
The script did jump to the IFV1 or APC1 label in my test.
-
::) It worked for me to ;D forgot i made a few changes in script including labels... sorry bout that.
Thanks for helping all.