Jump to content
Sign in to follow this  
GuyMz

Teleport Script

Recommended Posts

Hello, Im trying to make a tutorial which expanding most of the map, and i need a quick way to travel from certian areas to another.

I need a teleport script which will teleport to a certian marker on map, and can be activated by either a useraction or by clicking the marker on the map.

If someone can please address me to the script himself in BI that would be also very helpful.

Share this post


Link to post
Share on other sites

they are all outdated.

I've decided that instead of telporting, which is a real pain in the ***, i can make some respawn location and people could choose where to spawn, this should be easier to make.

so i tried making a many respawn markers for one side using prefix such a s respawn_west1, respawn_west2, but they randomly respawning in them, how can i choose where to spawn via the map??

Share this post


Link to post
Share on other sites
they are all outdated.

I've decided that instead of telporting, which is a real pain in the ***, i can make some respawn location and people could choose where to spawn, this should be easier to make.

so i tried making a many respawn markers for one side using prefix such a s respawn_west1, respawn_west2, but they randomly respawning in them, how can i choose where to spawn via the map??

Yes, when you place multiple respawn markers the game will spawn you at a random one automatically. If you want to let people choose where they spawn, then teleport is the only option.

Either addAction to an object near the main spawn, or use onMapSingleClick.

Keep in mind that with onMapSingleClick, though, you will possibly interrupt and/or be interrupted by other scripts that use the command, be it scripts from mods or from your own mission. So pay attention.

Share this post


Link to post
Share on other sites

Im sorry, but Im not really familliar with arma scripts, so i didnt understand how to do with the onmapsingleclick, and i tired to use the addaction way, but it didnt work, could you please explain and wirte the script lines.

thank you.

Share this post


Link to post
Share on other sites

This will open map, with 20 seconds timeout. If you click somewhere it will test whether you've clicked within 100m of any marker called td_X (X being number from 0 to anything incremented by one) and if you did it will teleport you onto it.

Go to your mission, and place markers named td_0, td_1, td_2 and so on.

You can do it easily by creating marker named td and copying him all over, it will automatically append the number sufix.

Then somewhere, into some object or player's init add: this addAction ["Teleport","mapClickTeleport.sqf"];

And create file called mapClickTeleport.sqf in mission's root.

_timeOut=[] spawn {
sleep 20;
onMapSingleClick 'false;';
hint 'Teleport timed out';
openMap false;
};
onMapSingleClick '
terminate _timeOut;
_num = 0;
_maxNum = 10; 
_targetDist = 999999;
_targetPos = [0];   
while {_num < _maxNum } do {
  _marker = format[''td_%1'',_num];
  if (getMarkerType _marker != '''' ) then {
    _markerPos = getMarkerPos _marker;
    _dist = _markerPos distance _pos;
	if(_dist < _targetDist && _dist < 100) then {
		_targetDist = _dist;
		_targetPos = _markerPos;
	};  
    _maxNum = _num + 10;       
  };
  _num = _num + 1;
};
if(count _targetPos > 1) then {						
	vehicle player setPos [_targetPos select 0, _targetPos select 1, 0];
} else {
	hint "No teleport target in that area";
}; 
onMapSingleClick ''false;''; 
openMap false;
true;
';
openMap true;

Share this post


Link to post
Share on other sites

Save this code as teleport.sqf then add a line like this to an in game object:

add action code:

this addAction ["Teleport - Talon","teleport.sqf",["FOB_Talon"]];

teleport.sqf:

// Teleports a person to the marker "FOB_Talon". You can place this marker anywhere on the map.
// The marker can also be moved.
//
// To use: Add this script as an action on an item like a flag pole.
//
//this addAction ["Teleport - Talon","teleport.sqf",["FOB_Talon"]];
//this addAction ["Teleport - Base","teleport.sqf",["Base"]];
//this addAction ["Teleport - Airfield","teleport.sqf",["Airstrip"]];

// Get the destination.
_dest = (_this select 3) select 0;

// Get a random direction
_dir = random 359;

// Move the person 15 meters away from the destination (in the direction of _dir)
player SetPos [(getMarkerPos _dest select 0)-10*sin(_dir),(getMarkerPos _dest select 1)-10*cos(_dir)];

Share this post


Link to post
Share on other sites

How would one go about changing this line to randomly pick a point from an array?

 

something like... player SetPos [<X number of markers radmomly placed around map>];

 

 

 

Share this post


Link to post
Share on other sites
3 hours ago, lawndartleo said:

How would one go about changing this line to randomly pick a point from an array?

 

something like... player SetPos [<X number of markers radmomly placed around map>];

 

 

 

 

Like this:

_markers = ["marker1","marker2","marker3"];
player setpos getMarkerPos (selectrandom _markers);

 

Cheers

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×