setVehicleVarName: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\[\[Category:[ _]?Scripting[ _]Commands[ _]Take[ _]On[ _]Helicopters(\|.*)?\]\]" to "{{GameCategory|tkoh|Scripting Commands}}")
m (Some wiki formatting)
 
(35 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Command|Comments=
{{RV|type=command
____________________________________________________________________________________________


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


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


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


|eff= local |Multiplayer Effects=
|game4= tkoh
|version4= 1.00


|gr1= Object Manipulation |GROUP1=
|game5= arma3
____________________________________________________________________________________________
|version5= 0.50


| 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:
|arg= global
<code>[[hint]] [[str]] _offroad; //MyFerrari</code>
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=
____________________________________________________________________________________________


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


|p1= object: [[Object]] |PARAMETER1=
|gr1= Object Manipulation


|p2= name: [[String]] |PARAMETER2=
|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]] |RETURNVALUE=
{{Feature|arma3|This does not work with [[Arma 3: Simple Objects|Simple Objects]].}}
____________________________________________________________________________________________
 
|x1= <code>[[player]] [[setVehicleVarName]] "aP";
aP = [[player]];</code> |EXAMPLE1=
____________________________________________________________________________________________
| mp= Execute on every client |=
| [[vehicleVarName]] |SEEALSO=


}}
|s1= object [[setVehicleVarName]] name
 
|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"


<h3 style="display:none">Notes</h3>
_playersCar setVehicleVarName "MyOffroad";
<dl class="command_description">
systemChat str _playersCar; // displays "MyOffroad"
<!-- Note Section BEGIN -->


<!-- Note Section END -->
isNil "MyOffroad"; // true - the MyOffroad variable is not set
</dl>
MyOffroad = _playersCar; // now it is
publicVariable "MyOffroad"; // broadcasts it over the network
</sqf>


<h3 style="display:none">Bottom Section</h3>
|x2= <sqf>_offroad setVehicleVarName ""; // Reset string representation to the default value</sqf>
[[Category:Scripting Commands|SETVEHICLEVARNAME]]
[[Category:Scripting Commands OFP Elite |SETVEHICLEVARNAME]]
{{GameCategory|arma1|Scripting Commands}}
[[Category:VBS2_Command_Group:_Variables|{{uc:{{PAGENAME}}}}]]
{{GameCategory|arma2|Scripting Commands}}
{{GameCategory|arma3|Scripting Commands}}
{{GameCategory|tkoh|Scripting Commands}}


<!-- CONTINUE Notes -->
|seealso= [[vehicleVarName]] [[BIS_fnc_objectVar]]
<dl class="command_description">
}}
<dd class="notedate">Posted on November 4, 2019 - 10:03 (UTC)</dd>
<dt class="note">[[User:DrSova|DrSova]]</dt>
<dd class="note">
Doesn't work with simple objects
</dd>
</dl>
<!-- DISCONTINUE Notes -->

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