setVehicleVarName: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Some wiki formatting)
 
(57 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


| arma |= Game name
|game1= arma1
|version1= 1.00


|1.00|= Game version
|game2= arma2
|version2= 1.00


|arg= global |=  
|game3= arma2oa
|version3= 1.50


|eff= local |= Effects in MP
|game4= tkoh
____________________________________________________________________________________________
|version4= 1.00


| 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 ...
|game5= arma3
|version5= 0.50


'''Note:''' This command does not set 'myVar' to contain the vehicle, this has to be done separately. |= Description
|arg= global
____________________________________________________________________________________________


| object''' setVehicleVarName''' name |= Syntax
|eff= local


|p1= object: [[Object]] |= Parameter 1
|gr1= Object Manipulation


|p2= name: [[String]] |= Parameter 2
|descr= Sets string representation of an object to a custom string.<br>
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.
In scripts an extra step is needed to achieve the same effect - see {{Link|#Example 1}}.


| [[Nothing]] |= Return value
{{Feature|arma3|This does not work with [[Arma 3: Simple Objects|Simple Objects]].}}
____________________________________________________________________________________________
 
|x1= <pre>player setVehicleVarName "aP"</pre> |= Example 1
____________________________________________________________________________________________


|x3= <pre>//Assign a variable to an object and be able to refer to that
|s1= object [[setVehicleVarName]] name
//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
____________________________________________________________________________________________


| [[vehicleVarName]], [[isValidVarName_(VBS2)|isValidVarName (VBS2)]] |= See also
|p1= object: [[Object]]


}}
|p2= name: [[String]]
 
|r1= [[Nothing]]
 
|x1= <sqf>
private _playersCar = vehicle player;
systemChat str _playersCar; // displays e.g "ce06b00# 164274: offroad_01_unarmed_f.p3d"
 
_playersCar setVehicleVarName "MyOffroad";
systemChat str _playersCar; // displays "MyOffroad"


<h3 style="display:none">Notes</h3>
isNil "MyOffroad"; // true - the MyOffroad variable is not set
<dl class="command_description">
MyOffroad = _playersCar; // now it is
<!-- Note Section BEGIN -->
publicVariable "MyOffroad"; // broadcasts it over the network
</sqf>


<!-- Note Section END -->
|x2= <sqf>_offroad setVehicleVarName ""; // Reset string representation to the default value</sqf>
</dl>


<h3 style="display:none">Bottom Section</h3>
|seealso= [[vehicleVarName]] [[BIS_fnc_objectVar]]
[[Category:Scripting Commands|SETVEHICLEVARNAME]]
}}
[[Category:Scripting Commands OFP Elite |SETVEHICLEVARNAME]]
[[Category:Scripting Commands ArmA|SETVEHICLEVARNAME]]
[[Category:VBS2_Command_Group:_Variables|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]

Latest revision as of 16:21, 20 March 2023

Hover & click on the images for description

Description

Description:
Sets string representation of an object to a custom string.
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. In scripts an extra step is needed to achieve the same effect - see Example 1.
Arma 3
This does not work with Simple Objects.
Groups:
Object Manipulation

Syntax

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

Examples

Example 1:
private _playersCar = vehicle player; systemChat str _playersCar; // displays e.g "ce06b00# 164274: offroad_01_unarmed_f.p3d" _playersCar setVehicleVarName "MyOffroad"; systemChat str _playersCar; // displays "MyOffroad" isNil "MyOffroad"; // true - the MyOffroad variable is not set MyOffroad = _playersCar; // now it is publicVariable "MyOffroad"; // broadcasts it over the network
Example 2:
_offroad setVehicleVarName ""; // Reset string representation to the default value

Additional Information

See also:
vehicleVarName BIS_fnc_objectVar

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