Jump to content
DerToXXic

Player teleport outside Trigger

Recommended Posts

Hello,

 

I have an TDM Mission and I have a Trigger witch teleports player to there spawn when they are out of map.

But it doesn't work. It do nothing.

//teleport/opfor.sqf

 _tele = _this select 0;
_caller = _this select 1;

_caller setPos (getpos (opforspawn));

//opforspawn is an marker name
//"teleport/blufor.sqf"

 _tele = _this select 0;
_caller = _this select 1;

_caller setPos (getpos (bluforspawn));

//bluforspawn is an marker name
//Trigger

//Condition

!(player in thislist)

//On Activation

if (side player == west) then { 
 sleep 1; 
 execVM "teleport\blufor.sqf"; 
}else{ 
 execVM "teleport\opfor.sqf"; 
};

 

Share this post


Link to post
Share on other sites

Check the syntax.

getPos only works with objects or locations.

If you need to get a markers position you need to use getMarkerPos together with a string.

_caller setPos (getpos (bluforspawn));//won't work

_caller setPos (getMarkerPos "bluforspawn");//should work

Cheers

Share this post


Link to post
Share on other sites

to use markers you need to use getMarkerPos as grumpy stated above. also consider using just one .sqf file for teleporting and simply pass in a parameter to it with the players side like this

 

On activation

if (side player == west) then 
{ 
	null = ["west"] execVM "teleport\teleportUnit.sqf"; 
}else
{ 
	null = ["east"] execVM "teleport\teleportUnit.sqf"; 
};

 

teleportUnit.sqf

params ["_side", "_caller"];

if (_side isEqualTo "west") then
{
	_caller setPos (getMarkerPos "bluforspawn");
} else
{
	_caller setPos (getMarkerPos "opforspawn");
};

 

  • Like 1

Share this post


Link to post
Share on other sites
58 minutes ago, gokitty1199 said:

to use markers you need to use getMarkerPos as grumpy stated above. also consider using just one .sqf file for teleporting and simply pass in a parameter to it with the players side like this

 

On activation


if (side player == west) then 
{ 
	null = ["west"] execVM "teleport\teleportUnit.sqf"; 
}else
{ 
	null = ["east"] execVM "teleport\teleportUnit.sqf"; 
};

 

teleportUnit.sqf


params ["_side", "_caller"];

if (_side isEqualTo "west") then
{
	_caller setPos (getMarkerPos "bluforspawn");
} else
{
	_caller setPos (getMarkerPos "opforspawn");
};

 

 

Probably not that important in a simple script like that, but defining a variable named _side that's holding a string data type will just open a can of worms in the long run.

Variables should always give at least a hint to what they're holding.

You're also not passing the _caller to the teleportUnit.sqf.

 

It's also easier to use find and select in this case, since the amount of sides are finite, something like this is easy to read and adjust:

//on Activation:
null = [player] execVM "teleport\teleportUnit.sqf"; 

//teleportUnit.sqf
params ["_caller"];
_markers = ["bluforspawn","opforspawn","indforspawn","civspawn"];//just some examples
_sides = [west,east,resistance,civilian];//west will select "bluforspawn" and so on
_index = _sides find side _caller;

if (_index isEqualTo -1) exitWith {systemchat "Invalid side, no teleport chosen"};//exit just in case

_marker = _markers select _index;
_caller setPos getMarkerPos _marker;

Cheers

  • Like 2

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

×