Jump to content
Sign in to follow this  
Ragnar_Darude

SetName?

Recommended Posts

Is there a way to change the name of a unit in-game without using the setidentity command since then i would have to create a static identity for each unit I want to use? There is a SetFace - command so i figured there would be a SetName command but it isnt. Is this correct?

Share this post


Link to post
Share on other sites

Use setIdentity instead (requires identity definition in description.ext).

Share this post


Link to post
Share on other sites

Hi sorry that i hijack your thread but i have a question with naming of vehicles:

I have a Vehicle which get created by a script - how can i give the vehicle a name like i do in the editor?

Because somehow my actionmenu, which should appear near that vehicle, only works when i place that vehicle with the editor and name it.

Regards, Christian

Share this post


Link to post
Share on other sites
try

nameofveh = createvehicle blabla

Thats exactly what i have done....

testvehicle = createVehicle ["vil_nysa", _spawn_pos, ["testvehicle = this ;"] , 0, "NONE"];

Is not working with my actionmenu script. But as soon as place a object on the map with this name, the action-menu is working....

I also tried by putting this below:

testvehicle setVehicleInit

"testvehicle = this;

this setVehicleVarName ""testvehicle"" ";

Share this post


Link to post
Share on other sites

You're right to use "setVehicleVarName" to give the unit a name.

Here's how I use it:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

// Create the vehicle at the chosen spot

_vehicle = _vehicleType createVehicle (_pos);

// Give it a random name

_vehicle setVehicleVarName format["%1_%2",_vehicleType, ceil(random 100)];

So if you spawned a HMMVW as your _vehicleType, the name would end up being something like HMMVW_34

For your example, you'd probably try this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_myVehicleObject = "vil_nysa" createVehicle (_spawn_pos);

_myVehicleObject setVehicleVarName "testvehicle";

Share this post


Link to post
Share on other sites

Its embarrassing for me but i'm very beginner of scripting, but for what is the "_vehicle" you use?

Regards, Christian

Share this post


Link to post
Share on other sites

I just modified my post above to make that more clear. The inital "_vehicle =" is only used in the current script (since it's a local variable with the _ before the variable name). It refers to the OBJECT of the vehicle you just created. Once you've used the setVehicleVarName to something, you can globally refer to it as that from then on.

Share this post


Link to post
Share on other sites
I just modified my post above to make that more clear.  The inital "_vehicle =" is only used in the current script (since it's a local variable with the _ before the variable name).  It refers to the OBJECT of the vehicle you just created.  Once you've used the setVehicleVarName to something, you can globally refer to it as that from then on.

Ok thanks, ill try it.... otherwise i can send you the completet script via PM and you can take a look over it? It uses very muhc while-do things and other stuff which seems to be very complex....

Xeno has made it for me, but he is only once a day Online and only for 10 minutes and so i have the feeling it takes some weeks until it is working....

Share this post


Link to post
Share on other sites
Sure, no problem smile_o.gif

Ok i sent you a PM with the script.... wink_o.gif

Share this post


Link to post
Share on other sites
I just modified my post above to make that more clear. The inital "_vehicle =" is only used in the current script (since it's a local variable with the _ before the variable name). It refers to the OBJECT of the vehicle you just created. Once you've used the setVehicleVarName to something, you can globally refer to it as that from then on.

Just to expand

The setVehicleVarName is like a new name given really, its a second name given to the unit/vehicle (all units are technically vehicles)

If you were to attempt to get the 'true' name of the unit/vehicle after setting the vehicleVarName, say thru a player sidechat Format, it would still return the original name given, either by you or the generic name given by the game itself.

The VehicleVarName, as stated, is accessed by the global used in the SetVehicleVarName, and it works like a dream - this is also an awesome way to hold units names for access that are deleted/respawned for various purposes smile_o.gif

The 'true' name of a unit, can never be modified, once its put in, it can never be re-assigned, nor reproduced, which is why this is a popular method for re-setting re-spawned units name for reference.

Think I said that all correctly tounge2.gif

Share this post


Link to post
Share on other sites

How to change the unit's "title" in the start-of-game lobby where you choose your role/class/unit:

When placing a unit in the editor, just fill in the "Description" field with any info you want to show up.

Took me way too long to find this out!

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  

×