Jump to content
Sign in to follow this  
Double Doppler

Attachto with classname

Recommended Posts

Is it possible to attach an object through the vehicle's init with just the classname? The reason for this is I have a dynamic mission I am working on where the vehicle has its init set before being bought by a player.

like instead of

_l1 = createvehicle "red_light" [this,[0,0,0]];

could be:

createvehicle "red_light" [this,[0,0,0]];

Or somthing like that so I dont have to name stuff (it gets messy when a unit buys a vehicle if objects are named..)

Remember I want to do this in the vehicle's init only with out naming objects preferably. Just by classname.

I would be greatly pleased if someone would help out!

Share this post


Link to post
Share on other sites

If all you need to do is create the object, attach it to the vehicle and forget about it, then you could add the following to the vehicle's init line:

(createvehicle "red_light" [this,[0,0,0]]) attachTo [this];

If you need to store the object for reference later on, you could use the vehicle's name space (using setVariable) to store and later on retrieve it.

Share this post


Link to post
Share on other sites

Will not work! gives me a missing bracket error. And If I reverse createvehicle and "red_light" it will give me a "Error Type Object, expected number before the "createvehicle"

space.

these syntax errors driving me nuts!

Edited by Double Doppler

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×