setVehicleVarName: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\|game([0-9]) ?= (.+) \|version([0-9]) ?= (.+) " to "|game$1= $2 |version$3= $4 ")
m (Fix example)
Line 22: Line 22:
|gr1= Object Manipulation
|gr1= Object Manipulation


|descr= 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:
|descr= Sets string representation of an object to a custom string.<br>
<code>[[hint]] [[str]] _offroad; //MyFerrari</code><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.
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 [[{{PAGENAME}}#Example_1|Example 1]].
In scripts an extra step is needed to achieve the same effect. See [[{{PAGENAME}}#Example 1|Example 1]].


{{Feature|arma3|This does not work with [[Arma 3: Simple Objects]].}}
{{Feature|arma3|This does not work with [[Arma 3: Simple Objects|Simple Objects]].}}


|mp= 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.
|s1= object [[setVehicleVarName]] name
 
|s1= object '''setVehicleVarName''' name


|p1= object: [[Object]]
|p1= object: [[Object]]
Line 38: Line 36:
|r1= [[Nothing]]
|r1= [[Nothing]]
   
   
|x1= <code>[[player]] [[setVehicleVarName]] "aP";{{cc|Change the string representation and assign it to a variable to work with}}
|x1= <code>[[private]] _playersCar = [[vehicle]] [[player]];
aP = [[player]];</code>
[[systemChat]] [[str]] _playersCar; {{cc|displays e.g "ce06b00# 164274: offroad_01_unarmed_f.p3d"}}
 
_playersCar [[setVehicleVarName]] "MyOffroad";
[[systemChat]] [[str]] _playersCar; {{cc|displays "MyOffroad"}}
 
[[isNil]] "MyOffroad"; {{cc|[[true]] - the MyOffroad '''variable''' is not set}}
MyOffroad = _playersCar; {{cc|now it is}}
[[publicVariable]] "MyOffroad"; {{cc|broadcasts it over the network}}
</code>


|x2= <code>_offroad [[setVehicleVarName]] ""; {{cc|Reset string representation to the default value}}</code>
|x2= <code>_offroad [[setVehicleVarName]] ""; {{cc|Reset string representation to the default value}}</code>


|seealso= [[vehicleVarName]] [[BIS_fnc_objectVar]]
|seealso= [[vehicleVarName]] [[BIS_fnc_objectVar]]
}}
}}

Revision as of 15:43, 19 May 2021

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