setVehicleVarName: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(explained better)
Line 11: Line 11:
____________________________________________________________________________________________
____________________________________________________________________________________________


| Sets the name of the variable which contains a reference to this object. It is necessary in MP to change the variable content after a respawn. When you only use 'myVar <nowiki>=</nowiki> <vehicle>', you'll just have a normal variable, when you use this command as well, 'myVar' will be the name for the vehicle, i.e. if you have other variables containing the vehicle, they'll now return 'myVar' and not WEST ...
| Sets string representation of an object to a custom string. For example it is possible to return "MyFerrari" instead of default "ce06b00# 164274: offroad_01_unarmed_f.p3d" when querying object as string:
 
<code>[[hint]] [[str]] offroad; //MyFerrari</code>
'''Note:''' This command does not set 'myVar' to contain the vehicle, this has to be done separately. |= Description
When a vehicle is created and named in the editor, the name becomes both the variable containing the vehicle object and the string representation of the vehicle object. [[vehicleVarName]] on the other hand is only string representation of the object. So if you want to refer to the actual object by its [[vehicleVarName]], an extra step needed to assign the object to a variable of the same name. For example to see and refer to offroad as myFerrari:
<code>offroad [[setVehicleVarName]] "MyFerrari"; MyFerrari {{=}} offroad;</code>
In multiplayer environment [[setVehicleVarName]] has to be executed on every PC if you want the custom name to be known everywhere. If vehicle is created and named in the editor, the vehicle name will be known globally automatically. <br>
To reset [[vehicleVarName]] and [[str]] representation of the object to original form set [[vehicleVarName]] to an empty string:
<code>offroad [[setVehicleVarName]] "";</code> |= Description
____________________________________________________________________________________________
____________________________________________________________________________________________


Line 25: Line 29:
____________________________________________________________________________________________
____________________________________________________________________________________________
   
   
|x1= <pre>player setVehicleVarName "aP"</pre> |= Example 1
|x1= <code>[[player]] [[setVehicleVarName]] "aP";</code> |= Example 1
____________________________________________________________________________________________
 
|x3= <pre>//Assign a variable to an object and be able to refer to that
//object using the variable, in both single and multi player.
_Object="M1A1" CreateVehicle (GetPos Player);
_VarName="MYTANK";
_Object SetVehicleVarName _VarName;
_Object Call Compile Format ["%1=_This ; PublicVariable ""%1""",_VarName];
</pre> |= Example 3
____________________________________________________________________________________________
____________________________________________________________________________________________
 
| mp= Execute on every client |=
| [[vehicleVarName]], [[isValidVarName_(VBS2)|isValidVarName (VBS2)]]  |= See also
| [[vehicleVarName]]  |= See also


}}
}}

Revision as of 23:16, 23 April 2014

-wrong parameter ("Arma") defined!-1.00
Hover & click on the images for description

Description

Description:
Sets string representation of an object to a custom string. For example it is possible to return "MyFerrari" instead of default "ce06b00# 164274: offroad_01_unarmed_f.p3d" when querying object as string: hint str offroad; //MyFerrari When a vehicle is created and named in the editor, the name becomes both the variable containing the vehicle object and the string representation of the vehicle object. vehicleVarName on the other hand is only string representation of the object. So if you want to refer to the actual object by its vehicleVarName, an extra step needed to assign the object to a variable of the same name. For example to see and refer to offroad as myFerrari: offroad setVehicleVarName "MyFerrari"; MyFerrari = offroad; In multiplayer environment setVehicleVarName has to be executed on every PC if you want the custom name to be known everywhere. If vehicle is created and named in the editor, the vehicle name will be known globally automatically.
To reset vehicleVarName and str representation of the object to original form set vehicleVarName to an empty string: offroad setVehicleVarName "";
Multiplayer:
Execute on every client
Groups:
Uncategorised

Syntax

Syntax:
object setVehicleVarName name
Parameters:
object: Object
name: String
Return Value:
Nothing

Examples

Example 1:
player setVehicleVarName "aP";

Additional Information

See also:
vehicleVarName

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note

Notes

Bottom Section