Jump to content
kgino1045

How to Teleport script??

Recommended Posts

It's hard and annoying that going to helipad or jet like 1km from player position so i decide to make a teleport system for pilot

I try those but didn't work

This script has been around for a while, so I am unsure of the author. That said, it's pretty darned simple. I have edited it to get an object position instead of a marker position.

Create a file named "teleport.sqf" in your mission folder.

teleport.sqf:

//this addAction ["Teleport -destinationName","teleport.sqf",[objectName]];

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

// Get a random direction
_dir = random 359;

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

Name your LAV - I'll name it "MHQ1" for this example.

Place a flagpole. Enter the addAction (with proper names) in the flagpole's init line:

this addAction ["Teleport - MHQ","teleport.sqf",[MHQ1]];

That's it. The flagpole will teleport you to the general vicinity of the MHQ (within a few meters). The only thing this doesn't do is check if the MHQ is active/moving, though teleporting to the MHQ while it is moving works fine.

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)];

any script and how to do that will be really appreciate

Share this post


Link to post
Share on other sites

all you need to do is add a marker down on the map somewhere

e.g

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

so i place down a marker called FOB_Talon MAKE SURE ITS NAME NOT TEXT

another e.g

this addAction ["Teleport - BASE","teleport.sqf",["BASE1"]];

so i create a marker called BASE1

also make sure you create a file and call it teleport.sqf otherwise this will not work

if you need any help im here

remember we are using that script provided which you have shown

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

Here is how to make it on map click.

104 cutText ["Click on the map where you'd like Teleport.","PLAIN DOWN",5];
waitFor = true;
["teleportSelf","onMapSingleClick","vehicle player setPos [_pos select 0, _pos select 1,0];	104 cutText ['','PLAIN DOWN',5]; waitFor = false;"] call BIS_fnc_addStackedEventHandler;
waitUntil{!waitFor};
["teleportSelf","onMapSingleClick"] call BIS_fnc_removeStackedEventHandler;

{player reveal _x}forEach nearestObjects [player,[],100];	

Share this post


Link to post
Share on other sites

sorry for the noob question, but, how i do this? i have to create a sqf file with this?

Here is how to make it on map click.

104 cutText ["Click on the map where you'd like Teleport.","PLAIN DOWN",5];
	waitFor = true;
	["teleportSelf","onMapSingleClick","vehicle player setPos [_pos select 0, _pos select 1,0];	104 cutText ['','PLAIN DOWN',5]; waitFor = false;"] call BIS_fnc_addStackedEventHandler;
	waitUntil{!waitFor};
	["teleportSelf","onMapSingleClick"] call BIS_fnc_removeStackedEventHandler;
	
{player reveal _x}forEach nearestObjects [player,[],100];	

and in init of player put this?

 

     player addAction ["Teleport", {player execVM "teleport1.sqf"}];

Share this post


Link to post
Share on other sites

Note: if just using Editor/Preview. You can hold LAlt when left-click mouse to teleport as well.

  • Like 2

Share this post


Link to post
Share on other sites

Place a box on the map and name it  box1

 

Place a soldier on the map and name him blue1.  make sure he is a long way from the box

 

Place a trigger on the map. When the man walks into the trigger it will fire.

 

In the On Activation type:   blue1 setpos (getpos box1);

 

Blue1 walks into the trigger, it fires and the man is teleported to box1.

 

Instead of a box, use something small like a watch.  And make the watch invisible.

Share this post


Link to post
Share on other sites

Note: if just using Editor/Preview. You can hold LAlt when left-click mouse to teleport as well.

worked perfectly, thank you !!

Share this post


Link to post
Share on other sites

Note: if just using Editor/Preview. You can hold LAlt when left-click mouse to teleport as well.

this method does not work on MP, how can I make it work in MP, coop missions?

Share this post


Link to post
Share on other sites

onMapSingleClick.sqs

_pos = _this select 0_units = _this select 1_shift = _this select 
2_alt = _this select 3
?_shift && !_alt && mapDebug : {vehicle _x setPos _pos} 
foreach _units
?Count _units != 0 : Exit
?!_alt && !_shift : "wp1" setMarkerPosLocal _pos?_alt && 
!_shift && mapDebug : vehicle Player setPos _pos

open map , click on map were you wanna go press  ctrl + alt ...

if you want this to work after death add code to a respawn...along with it being in init.

Share this post


Link to post
Share on other sites

onMapSingleClick.sqs

_pos = _this select 0_units = _this select 1_shift = _this select 
2_alt = _this select 3
?_shift && !_alt && mapDebug : {vehicle _x setPos _pos} 
foreach _units
?Count _units != 0 : Exit
?!_alt && !_shift : "wp1" setMarkerPosLocal _pos?_alt && 
!_shift && mapDebug : vehicle Player setPos _pos

open map , click on map were you wanna go press  ctrl + alt ...

if you want this to work after death add code to a respawn...along with it being in init.

 

This is sqs and will only cause confusion

private ["_dest"];

_dest = param [0,objNull];

if (alive _dest && !(isNull _dest)) then
{
    3 fadeSound 0;
    cutText["A few minutes later...","BLACK OUT",3];
    sleep 3;
    player  setPos [(getPos _dest  select 0) + 3 , (getPos _dest select 1) + 3, getPos _dest select 2];
    cutText["A few minutes later...","BLACK IN",5];
    2 fadeSound 1;
}
else
{
    hint "Respawn is currently not available.";
};

That's the teleport script I use in my dialogues.

 

 

[_objectToTeleportTo] execVM "your script path.sqf";

 

Just make sure it's called only on the clients machine, otherwise all player units will be teleported.

  • Like 1

Share this post


Link to post
Share on other sites
private ["_dest"];

_dest = param [0,objNull];

if (alive _dest && !(isNull _dest)) then
{
    3 fadeSound 0;
    cutText["A few minutes later...","BLACK OUT",3];
    sleep 3;
    player  setPos [(getPos _dest  select 0) + 3 , (getPos _dest select 1) + 3, getPos _dest select 2];
    cutText["A few minutes later...","BLACK IN",5];
    2 fadeSound 1;
}
else
{
    hint "Respawn is currently not available.";
};

I'm sorry for another noob question, buy, I usually play  dynamic missions alone and this command <[_objectToTeleportTo] execVM "teleport.sqf script";> I should put in my init player or init.sqf?

Share this post


Link to post
Share on other sites

Interesting, but in the end he says you can have the same effect with sqf by simply defining a inline function and call it.

Share this post


Link to post
Share on other sites

Note: if just using Editor/Preview. You can hold LAlt when left-click mouse to teleport as well.

 

Man.. I thought I knew all the editor tricks!!  Thanks for this one.

Share this post


Link to post
Share on other sites

Man.. I thought I knew all the editor tricks!!  Thanks for this one.

 

I think this was introduced later after the release, that's why it's probably not well known.

  • Like 1

Share this post


Link to post
Share on other sites

Interesting, but in the end he says you can have the same effect with sqf by simply defining a inline function and call it.

that's  my my point ... sqs sometimes is just simpler code, works well for what its worth.. and again don't need to know extra trick like (for noobs) learning fnc, pre init fnc and what not...

some things a very frustrating from my view point.

I have a ofp rts working 90% in arma3 all sqs..

trying to get some of these codes/scripts to work sqf.. some are never going to work as sqf, I don't get the same effect.

or it dosnt work at all... I find some sqs code to be just run and done .. were sqf is run wait .....were is it going .... oh here it is ..

just unfortunate that I'm not a good pro scripter, because id use sqs,sqf and fms....

Share this post


Link to post
Share on other sites

Quick question im trying to make a unit for marines and we have a light armor section that launches on lcacs while we launch from the USS Nimitz, is there a way to set the height of where the player will teleport?, because it automatically teleports them to sea level at 0

Share this post


Link to post
Share on other sites

Quick question im trying to make a unit for marines and we have a light armor section that launches on lcacs while we launch from the USS Nimitz, is there a way to set the height of where the player will teleport?, because it automatically teleports them to sea level at 0

 player  setPos [(getPos _dest  select 0) + 3 , (getPos _dest select 1) + 3, YourHeight];
  • Like 2

Share this post


Link to post
Share on other sites

how i can teleport to the top of a tower. i tried but i cant get it to work.

 

    //this addAction ["Teleport -destinationName","teleport.sqf",[objectName]];

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


// Get a random direction
_dir = random 359;

// Move the person a few meters away from the destination (in the direction of _dir)
player SetPos [(getPos _dest select 0)-3*sin(_dir),(getPos _dest select 1)-3*cos(_dir)];
player setPosATL [getPosATL _dest select 0, getPosATL _dest select 1, getPosATL _dest select 2];          <-------------------------------------------------------------------------------

 

i can teleport to ground lvl but i want to get the "above terrain lvl" of the object and teleport to the top of a tower.

edit. nevermind the setposatl works perfectly..

oh and patterson i just anwsered youre question.. getPosATL _dest select 2 gets the height based on the height of the object you put the init code in.

 

 

here is my example. its a firing range with an endless supply of ai being heli dropped in once they lose 70% of its force. i use the teleport script to teleport the player to different parts of the range to get better vantage points

http://steamcommunity.com/sharedfiles/filedetails/?id=267375554

Share this post


Link to post
Share on other sites

Try this, play around with the 3 - random 3 to adjust your distance.

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

// Get a random direction
_dir = random 359;

// Get destination
_spot =  getPosATL _dest;

// Move the person a few meters away from the destination then turn in the direction of _dir)
player setDir _dir;
player SetPosATL (_spot vectorAdd [3 - random 3, 3 - random 3,0]);

  • Like 1

Share this post


Link to post
Share on other sites

 

Try this, play around with the 3 - random 3 to adjust your distance.

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

// Get a random direction
_dir = random 359;

// Get destination
_spot =  getPosATL _dest;

// Move the person a few meters away from the destination then turn in the direction of _dir)
player setDir _dir;
player SetPosATL (_spot vectorAdd [3 - random 3, 3 - random 3,0]);

_dest = (_this select 3) select 0;
player setPosATL [getPosATL _dest select 0, getPosATL _dest select 1, getPosATL _dest select 2]; 

works just fine i just didnt do it right. typos...

thanks anyway

Share this post


Link to post
Share on other sites

Back in the day i did a teleport script where it teleports you to where you shoot (or where the bullet lands). Someone might find it useful

//Init.sqf

_unitwep = player;
bulletinair = false;
bulletinairpos = [];

_unitwep addeventhandler ["Fired",   
{ 
 _this spawn  {
	_unit = player;
	if (!bulletinair) then {
	bulletinair = true;
	_bullet = _this select 6; 
	_pos = getPosATL _bullet;
	while {alive _bullet} do {_pos = getPosATL _bullet; bulletinairpos = getposATL _bullet};
	_roundpos = [(round (_pos select 0)),(round (_pos select 1)),(round (getposATL _bullet select 2))];
	_null = (_pos select 0) + (_pos select 1) + (_pos select 2);
	if (_null == 0) then {hint format ["Error: pos = %1",_pos]} else {_unit setpos [_pos select 0, _pos select 1,0.5]; hint format ["Teleported to: %1",_roundpos]};
	waitUntil {!alive _bullet};
	bulletinair = false;
	bulletinairpos = [];
	} else {hint format ["Wait for bullet to hit the ground, its %1M from the ground",(round (bulletinairpos select 2))]};
 }; 
}];
  • Like 1

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

×