Jump to content
Sign in to follow this  
-RIP-Tyson

Naming a spawned vehicle

Recommended Posts

As always apologies if this has been asked before - I have searched and searched for over an hour and cannot find the answer....

I am spawning a mission critical scud launcher using the following code in a trigger -

x = [markerPos "scud1", random 360, "MAZ_543_SCUD_TK_EP1", EAST] call BIS_fnc_spawnVehicle;

How do I name it scud1 so I can have another trigger !alive scud1 for an objective?

Ideally I want to do this all in the trigger which spawns the object and I want it to work on a dedicated coop server....

Please can someone help?

Share this post


Link to post
Share on other sites

You already named it.

[color="Red"]x[/color] = [markerPos "scud1", random 360, "MAZ_543_SCUD_TK_EP1", EAST] call BIS_fnc_spawnVehicle; 

If this works similarly to spawnGroup, then x is the vehicle name. Simply replace it with scud1.

Share this post


Link to post
Share on other sites
;1747449']You already named it.

[color="Red"]x[/color] = [markerPos "scud1", random 360, "MAZ_543_SCUD_TK_EP1", EAST] call BIS_fnc_spawnVehicle; 

If this works similarly to spawnGroup' date=' then x is the vehicle name. Simply replace it with scud1.

That's what i was hoping but it doesn't seem to be the case....

Share this post


Link to post
Share on other sites

You need to do a little more

x = [markerPos "scud1", random 360, "MAZ_543_SCUD_TK_EP1", EAST] call BIS_fnc_spawnVehicle;newname = x select 0;

Scud will now be "newname" and you can chooses whatever name you want.

Share this post


Link to post
Share on other sites
You need to do a little more

x = [markerPos "scud1", random 360, "MAZ_543_SCUD_TK_EP1", EAST] call BIS_fnc_spawnVehicle;newname = x select 0;

Scud will now be "newname" and you can chooses whatever name you want.

works like a charm - thank you very much... :)

Share this post


Link to post
Share on other sites

Assuming you do this on the server in a mp game and you need the trigger to trig with the other players too you need to broadcast it at the end:

publicVariable "newname";

Then the non-server players machine will know what newname is.

Share this post


Link to post
Share on other sites
Assuming you do this on the server in a mp game and you need the trigger to trig with the other players too you need to broadcast it at the end:

publicVariable "newname";

Then the non-server players machine will know what newname is.

All I want is for the server to spawn the scud launcher and give it a name as the next objective is to destroy that launcher... do i still need to make it a public variable?

if So am i just adding that last bit onto the code at the end?

Share this post


Link to post
Share on other sites

It all depends on how you do it. For example if you use the task system which is local then you have to. An example trigger:

Condition:

!alive scud1

On act

player createSimpleTask ["Extract"];

Then you have to use publicVariable because:

- You create the scud launcher on the server. On the server you tell that scud1 = (this new scud launcher).

- However all the other players computers don't know what scud1 is.

- So the trigger won't activate there. publicVariable "varname" tells everybody else what varname is now.

Yes you just add it at the end. Remember to enclose the name in quotes. If the variable is: scud1 then you have to say:

publicVariable "scud1";

NOT:

publicVariable scud1;

Share this post


Link to post
Share on other sites

Brilliant thanks

---------- Post added at 06:33 PM ---------- Previous post was at 05:39 PM ----------

Sorry to answer my own thread...

The bit that says Random 360 I'm guessing is making the unit face a random direction.... what do I change to fix the direction to look say due East?

Share this post


Link to post
Share on other sites
Tyson;1747591']

The bit that says Random 360 I'm guessing is making the unit face a random direction.... what do I change to fix the direction to look say due East?

You write: 90

0 North

90 East

180 South

270 West

Share this post


Link to post
Share on other sites

Change random 360 to 90? Without random. Or "90", if it doesn't work without quotes.

E: too slow :(

Share this post


Link to post
Share on other sites

x = [markerPos "helispawnpos", 0, "UH60M_EP1", WEST] call BIS_fnc_spawnVehicle;Heli = x select 0;

sleep 2;

_wp_pos = getMarkerPos "helihit";

_hwp = Heli addWaypoint [_wp_pos, 15];
_hwp setWaypointType "MOVE";
_hwp setWaypointSpeed "NORMAL";

publicVariable "Heli";

Could anyone tell me why this isn't working? It keeps giving me a script error, saying it expected a group, and the waypoint is not added.

Edit: Ok, I think it's because Heli is a unit name, not a group name, and it is trying to give the waypoint to a group name of Heli. Any ideas?

Edited by Grimes [3rd ID]

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  

×