Variable syntax help, please :)

Andy Murtagh

New Member
Hi guys,

Need a little bit of help with the syntax of a variable definition. Later in a script that I use I have the following:
Code:
player setPos [4676.18,2509.28,0.001];

I utilise this to teleport a recently kicked player that went somewhere they shouldn't have away from where they were. At present, as you can see, it's hard-coded in the script body to teleport them to Balota. What I'd like to do is use a variable there instead, in case people want the option of sending them elsewhere; so something like:
Code:
player setPos _destination;

That's fine, but what I'm not sure of is the syntax to set _destination earlier in the script. Is it as simple as:
Code:
_destination = [4676.18,2509.28,0.001];

I want to be able to use _destination to hold the coordinate location of where the player will be moved to, can any confirm what the syntax for this should be? Trial and error may win out, but I thought I'd see about saving myself some time :)

As an aside, anyone know of a way to decide on a random location and set _destination to it?

Thanks!
Q.
 
As far as I understand that is correct. Check this out, it should help.

For your second question, one way this could be done would be using BIS_fnc_selectRandom and an array of potential locations, such as below:
Code:
_destinations = [
[4676.18,2509.28,0.001], //BALOTA
[9999,9999,9999], //ANOTHER LOCATION
[9999,9999,9999] //ANOTHER LOCATION
] call BIS_fnc_selectRandom;


You may, to make things easier to understand and change, use variables for each location as shown below:
Code:
_balota = [4676.18,2509.28,0.001];
_location1= [9999,9999,9999];
_location2= [9999,9999,9999];

_destinations = [_balota, _location1, _location2] call BIS_fnc_selectRandom;


Hope that helps ( and is correct :/ ).
 
That's great, many thanks Moses. The first (just setting the variable) worked like a charm. I'll try the random function in a few days :) Thanks for your help!
 
Back
Top