Jump to content
barn

Teleport all players in trigger

Recommended Posts

Hi everyone!

Quick question:

I have an addaction on an object "teleport with players nearby"

I have a marker named: triggertower

When i execute the action, it's suppose to teleport all the players in the marker on the object

 

So i made a script like this:
 

Quote

this addAction ["ENTER WITH PLAYERS", {{if (isPlayer _x) then { if (_x inArea triggertower) then { _x setPos [(getPos Obelisk1 select 0) +5, (getPos Obelisk1 select 1) +0, (getPos Obelisk1 select 2) +2];}; }} forEach allUnits.

 

It works on local and teleport the player, but on a server, no one is teleported not even the player doing the action.

 

Can anybody help me understand what I am doing wrong ?

Thanks.

 

Share this post


Link to post
Share on other sites
9 hours ago, barn said:

this addAction ["ENTER WITH PLAYERS", {{if (isPlayer _x) then { if (_x inArea triggertower) then { _x setPos [(getPos Obelisk1 select 0) +5, (getPos Obelisk1 select 1) +0, (getPos Obelisk1 select 2) +2];}; }} forEach allUnits.

What you have here is incomplete, missing a semicolon ( ; ) and ending in a period ( . ), which shouldn't work.  Should be:

this addAction [
	"ENTER WITH PLAYERS",
	{
		{
			if (isPlayer _x) then {
				if (_x inArea triggertower) then {
					_x setPos [(getPos Obelisk1 select 0) +5, (getPos Obelisk1 select 1) +0, (getPos Obelisk1 select 2) +2];
				};
			};
		} forEach allUnits;
	}
];

Recommend you use (_x In allPlayers) rather than (isPlayer _x), since isPlayer can sometimes be problematic in multiplayer.

 

Also possible that in description.ext you might have security protocol (CfgDisabledCommands) in place for setPos command, allowing server to use it, but not allowing clients to use it.

  • Like 1

Share this post


Link to post
Share on other sites

Hi! Thanks for the reply it helps a lot !

 

So i tried as you said and had some params to fix the distance view and change the date when activate:

 

Quote

this addAction
[
    "<t color='#00FF00'>ENTER WITH PLAYERS</t>",
    {
        {
            if (_x In allPlayers) then {
                if (_x inArea triggertower) then {
                    _x setPos [(getPos Obelisk1 select 0) +5, (getPos Obelisk1 select 1) +0, (getPos Obelisk1 select 2) +2];
                };
            };
        } forEach allUnits; setDate [2002, 4, 12, 23, 0];
    },
    nil,
    1.5,
    true,
    true,
    "",
    "true",
    5,
    false,
    "",
    ""
];

 

And compress it for the init of an object on mission:

Quote

this addAction ["<t color='#00FF00'>ENTER WITH PLAYERS</t>",{{if (_x In allPlayers) then {if (_x inArea triggertower) then {_x setPos [(getPos Obelisk1 select 0) +5, (getPos Obelisk1 select 1) +0, (getPos Obelisk1 select 2) +2];};};} forEach allUnits; setDate [2002, 4, 12, 23, 0];},nil,1.5,true, true,"", "true", 3, false, "", ""];

 

No errors so far, so i will try it in MP !

Thanks again!

 

Share this post


Link to post
Share on other sites

Thanks HazJ !

 

So, i tried the mission today with this new code and with a 2 players on the mission...It's not working. No one is teleported.

 

Is there an other way to do it if _x In allPlayers and isPlayer _x can't work in MP ?

 

 

Share this post


Link to post
Share on other sites

Not tested. For quick test, name your trigger say trg1 and inside init.sqf:

player addAction [
    "Teleport everyone to trigger",
    {
		_x setPos getPos trg1;
    } forEach allPlayers - entities "HeadlessClient_F";
];

 

Share this post


Link to post
Share on other sites

Hi!

 

So i've finally had the time to make a test.

 

HazJ, your script return an error "Error ] missing" on line :} forEach allPlayers - entities "HeadlessClient_F";

 

So i tried with a execVM in the ini of the player and your script in a file "test.sqf". And now the error appears when the mission start. And i start the mission at the trigger without activating the action in my menu.

 

EDIT: ok i tried with an other player in MP and with this command:

 

Quote

this addAction ["<t color='#00FF00'>ENTER WITH PLAYERS</t>",{{if (_x In allPlayers) then {if (_x inArea triggertower) then {_x setPos [(getPos Obelisk1 select 0) +5, (getPos Obelisk1 select 1) +0, (getPos Obelisk1 select 2) +2];};};} forEach allPlayers - entities "HeadlessClient_F"; setDate [2002, 4, 12, 23, 0];},nil,1.5,true, true,"", "true", 3, false, "", ""];

 

Same result: The time change, the getpos is not working...

 

Share this post


Link to post
Share on other sites

Maybe try this, has some added Order of Operations and removes some parts not needed :

this addAction 
[
	"<t color='#00FF00'>ENTER WITH PLAYERS</t>",
	{
		{
			if (_x inArea triggertower) then {
				_x setPos 
				[
					((getPos Obelisk1) select 0) +5, 
					((getPos Obelisk1) select 1) +0, 
					((getPos Obelisk1) select 2) +2
				];
			};
		} forEach (allPlayers - (entities "HeadlessClient_F")); 
		setDate [2002, 4, 12, 23, 0];
	},
	nil,
	1.5,
	true,
	true,
	"",
	"true",
	3
];

If your mission isn't using Headless Client, and you don't anticipate any being added, you might do away with its reference and just use (allPlayers).

 

What is the markerType, x-axis and y-axis of the triggerTower marker?  And what type object is Obelisk1?

  • 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

×