OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: TH on 01 Aug 2004, 16:30:23

Title: Assigning a script to created vehicles
Post by: TH on 01 Aug 2004, 16:30:23
In mfcti how can i assign a script/scripts to a vehicle as soon as its built at the factory, or build menu...for example when a person builds a flag i want it to be assigned a script.
Title: Re:Assigning a script to created vehicles
Post by: Roni on 01 Aug 2004, 23:19:33
Hi TH !

You can ether give the new object a name and then give the named object the addaction or, if the new object is created next to a known object such as the player, then you can search for the nearest object of that type and assign it that way.

Example 1 -

newObject = "ACamp" createVehicle [_xPos, _yPos, 0]
newObject addAction ["Break Camp", "breakcamp.sqs"]


OR

"ACamp" createVehicle [_xPos, _yPos, 0]
nearestobject [_player, "ACamp"] addAction ["Break Camp", "breakcamp.sqs"]



I prefer the second method, that way I can create multiple versions of the same object without having to give each one a unique name.

Good luck !



Roni
Title: Re:Assigning a script to created vehicles
Post by: TH on 01 Aug 2004, 23:48:49
thx roni, got it to work a different way... ;D
Title: Re:Assigning a script to created vehicles
Post by: Roni on 02 Aug 2004, 01:41:49
No probs - good luck with it !