Introduced in | |
Version: | 1.19 |
---|---|
Description | |
Description: | Sets the variable to the given value in the variable space of the given element. To remove a variable, set it to nil (for example, Variables can only be set for existing entities. Once an entity is removed, all associated variables are removed as well. Variables can be assigned to the following entities: |
Syntax | |
Syntax: | element setVariable [name, value, public, resetOnRespawn, recordForAAR] |
Parameters: |
|
Return Value: | Nothing |
Alternative Syntax | |
Syntax: | map setVariable [name, value, clear] (V2.0+) |
Parameters: |
|
Return Value: | Nothing |
Examples | |
Examples: | car1 setVariable ["owner",player,true]; |
Additional Information | |
See also: | getVariable, VBS Object Variables |
Multiplayer: | |
Problems: |
Notes
- Posted on Feb 13, 2012
- Kronzky
- If the value stored via setVariable is an array, then its value can be changed by reference:
player setVariable ["myArray", [1,2,3]]; _ptr = player getVariable "myArray"; // _ptr is pointer to [1,2,3], so is "myArray" on player _ptr set [1,4]; // modiying the pointer will modify the value stored in "myArray" player sidechat str(_ptr); // now returns [1,4,3] player sidechat str(player getVariable "myArray"); // returns [1,4,3] as well // If the variable name is re-assigned, it will become "disconnect" from the original pointer player setVariable ["myArray", [1,2,3]]; player sidechat str(_ptr); // still returns [1,4,3] (from the original array reference) player sidechat str(player getVariable "myArray"); // returns [1,2,3] (the newly assigned array values)