Jump to content
WurschtBanane

Teleporting via user action (SOLVED)

Recommended Posts

Hi again, i want to create a user action on an object that will teleport the person activating it to a marker called marker_Nimitz.

 

I have read about player setpos xxx but i am pretty sure this will not work in multiplayer with JIPing units.

Share this post


Link to post
Share on other sites
[this,["Teleport Action",{_this setPos getMarkerPos "marker_nimitz"}]] remoteExec ["addAction",0,true];

I believe this should work.

Not entirely positive though.

should be able to add it to the player.

BUT, I believe you're adding this to the nimitz carrier?

I recommend you see what the height of the ship is from sea level.

Share this post


Link to post
Share on other sites

Wont work, as it will not work once the player disconnects and joins in on another slot (JIP), as unit init lines are deleted then.

 

I asked if i could add an action to an object (like a flag) and teleport the player.

Share this post


Link to post
Share on other sites
23 minutes ago, WurschtBanane said:

Wont work, as it will not work once the player disconnects and joins in on another slot (JIP), as unit init lines are deleted then.

 

I asked if i could add an action to an object (like a flag) and teleport the player.

RemoteExec will solve your JIP issues.

I dont understand why it wouldnt work.

To teleport?

This addAction["teleport",{_this setPos getMarkerPos "marker_nimitz"}];

I would recommend you to put this in the initplayerlocal otherwise if its being executed on a flag. There would be no jip issues

Share this post


Link to post
Share on other sites

[player addaction ["<t color='#004EFF'>Teleporter soldier</t>", {_pos = getMarkerPos "marker_nimitz",player setpos _pos },[], 1, false, true,"","alive _target and (getposatl player distance getposatl flagteleport) <10"]] call bis_fnc_mp;

 

create into mission folder OnplayerRespawn.sqf    ( input this script)

https://community.bistudio.com/wiki/Event_Script

name your flag in editor  >> flagteleport   >>init box : this allowdamage false; (for no destruction of the flag , flag dammage adios addaction)

good edition by;))

Share this post


Link to post
Share on other sites
5 minutes ago, Nach said:

[flagteleport addaction ["<t color='#004EFF'>Teleporter soldier</t>", { _pos = getmarkerpos "marker_nimitz" ,player setpos _pos},[], 1, false, true,"","alive _target and (getposatl flagteleport distance getposatl  player) < 10"]] call bis_fnc_mp;

 

name your flag in editor  >> flagteleport

Why are we using mp still?

Whst you wrote there is pretty similar to what i had wrote above.

Conditions great and all.

 

 

Share this post


Link to post
Share on other sites
49 minutes ago, Midnighters said:

Why are we using mp still?

Whst you wrote there is pretty similar to what i had wrote above.

Conditions great and all.

 

 

sorry,   into  onplayerRespawn.sqf  and init.sqf

[player addaction ["<t color='#004EFF'>Teleporter soldier</t>", {_pos = getMarkerPos "marker_nimitz",player setpos _pos },[], 1, false, true,"","alive _target and (getposatl player distance getposatl flagteleport) <10"]] call bis_fnc_mp;

Share this post


Link to post
Share on other sites
18 minutes ago, Nach said:

sorry,   into  onplayerRespawn.sqf

[player addaction ["<t color='#004EFF'>Teleporter soldier</t>", {_pos = getMarkerPos "marker_nimitz",player setpos _pos },[], 1, false, true,"","alive _target and (getposatl player distance getposatl flagteleport) <10"]] call bis_fnc_mp;

No no, im talking about bis_fnc mp

RemoteExec has.faster annd more reliable performance

Share this post


Link to post
Share on other sites
13 minutes ago, Midnighters said:

No no, im talking about bis_fnc mp

RemoteExec has.faster annd more reliable performance

yes it s right , remotexec  normaly if you input an addaction into object init box  there a no matter for JIP .

All clients read addaction  . maybe destruction object in game

Share this post


Link to post
Share on other sites
4 hours ago, Midnighters said:

[this,["Teleport Action",{_this setPos getMarkerPos "marker_nimitz"}]] remoteExec ["addAction",0,true];

This addAction["teleport",{player setPos getMarkerPos "marker_nimitz"}];

no variable function into an script addaction thanks to KK to tell me that ;)

Share this post


Link to post
Share on other sites
8 minutes ago, Nach said:

This addAction["teleport",{player setPos getMarkerPos "marker_nimitz"}];

no variable function into an script addaction thanks to KK to tell me that ;)

What would make the mp function any better?

error on my end with the _this , thought the magic variable for addAction would run in code as well.

But I'm still terribly confused as to why you're telling me remoteExec won't work JIP comparibly to MP function?!?

Share this post


Link to post
Share on other sites
13 hours ago, Nach said:

[player addaction ["<t color='#004EFF'>Teleporter soldier</t>", {_pos = getMarkerPos "marker_nimitz",player setpos _pos },[], 1, false, true,"","alive _target and (getposatl player distance getposatl flagteleport) <10"]] call bis_fnc_mp;

 

create into mission folder OnplayerRespawn.sqf    ( input this script)

https://community.bistudio.com/wiki/Event_Script

name your flag in editor  >> flagteleport   >>init box : this allowdamage false; (for no destruction of the flag , flag dammage adios addaction)

good edition by;))

EDIT: DID NOT WORK, user action not showing up on the flag.

 

Will it work if i put the code into the initPlayerServer.sqf?

 

Share this post


Link to post
Share on other sites

This addAction["teleport",{player setPos getMarkerPos "marker_nimitz"}];

 

This would indeed work, but who will it teleport when there are 15 players on the server?

Share this post


Link to post
Share on other sites

The simplest solution I could find was to execute the below in initPlayerLocal.sqf.  This will also take care of JIP clients.

 

player addaction ["Teleport",{(_this select 1) setpos (markerpos "marker_Nimitz")},nil,1.5,true,true,"","(_target == _this)"];

This assumes the marker variable name is marker_Nimitz when placed in editor. 

 

If you wanted to use this in the characters editor init, replace "player" with "0 = this".

I also added a condition of "_target == _this".   Without it, if a player looks at another player, they would have two teleport buttons if used in the character's init.

 

 

 

Midnighter's code in his first reply would work if placed in initserver.sqf.   Placing it anywhere else would cause it to be duplicated to everyone every time someone connects and your JIP remoteexecs would become excessive.

Remember,  bis_fnc_mp or remoteexecute causes all clients to execute the command, every time its ran.  Remoteexecute with JIP enabled causes a stacking effect.

 

Nach's code in the last reply would work if placed in a vehicle's init, but since vehicle's inits are ran on all clients on connect, it would cause the same issue as Midnighter's.   You could convert it to a regular addaction and paste it in the initplayerlocal.sqf, but not in the character's editor init.

 

Correct me if im wrong guys, just tryin to help!

Edited by wyattwic
Corrected a few explanations and code
  • Like 1

Share this post


Link to post
Share on other sites
11 minutes ago, wyattwic said:

The simplest solution I could find was to execute the below in initPlayerLocal.sqf.  This will also take care of JIP clients.

 


player addaction ["Teleport",{_target setpos (markerpos "marker_Nimitz")},nil,1.5,true,true,"","(_target == _this)"];

This assumes the marker variable name is marker_Nimitz when placed in editor. 

 

If you wanted to use this in the characters editor init, replace "player" with "0 = this".

I also added a condition of "_target == _this".   Without it, if a player looks at another player, they would have two teleport buttons if used in the character's init.

 

 

 

Midnighter's code in his first reply would work if placed in initserver.sqf.   Placing it anywhere else would cause it to be duplicated to everyone every time someone connects and your JIP remoteexecs would become excessive.

Remember,  bis_fnc_mp or remoteexecute causes all clients to execute the command, every time its ran.  Remoteexecute with JIP enabled causes a stacking effect.

 

Nach's code in the last reply would work if placed in a vehicle's init, but since vehicle's inits are ran on all clients on connect, it would cause the same issue as Midnighter's.   You could convert it to a regular addaction and paste it in the initplayerlocal.sqf, but not in the character's editor init.

 

Correct me if im wrong guys, just tryin to help!

It gives me error undefined variable in expression: _target

Share this post


Link to post
Share on other sites

Somehow I missed the second question.

 

To add it to a flagpole or any object, place it in editor and add the below it its init in editor.

 

0 = this addaction ["Teleport",{(_this select 1) setpos (markerpos "marker_Nimitz")}];

 

This code, when added to a flagpole's editor init (I use a map of altis since its easier to target), all clients will see "Teleport" in their action menus when looking at it.

 

Remember, addaction has a local effect - It will only be visible on the machine its ran on.   We get around this by pasting it in a editor object's editor init, witch gets ran on all clients on join.

 

 

 

 

  • Like 1

Share this post


Link to post
Share on other sites
Just now, WurschtBanane said:

It gives me error undefined variable in expression: _target

Yeah, I had a minor error in the code.  Fixed it, try it again.

 

_target and _this are only defined in the condition check.

_this select 0 and _this select 1 represents target and caller respectively in the code section.

Share this post


Link to post
Share on other sites

createunit _soldier

Soldier = _soldier

Publicvariable "soldat"

Mon addaction {soldat etc ...

Share this post


Link to post
Share on other sites
8 minutes ago, Nach said:

_soldier createunit

Soldier = _soldier

Publicvariable "soldier"

My addiction { soldier etc...

 

That doesn't seem to work towards Bananae's goal of allowing his players to teleport to a marker. 

 

What that code seems to be doing is broadcasting a created unit's object over the network.  Not feasible for use with any number of players.  It would work if you are trying to edit a specific AI over the network with local commands.

 

Edit,

Remember, while addaction is local, that only effects where its visible from.  It can effect items globally.

Check its wiki page, look for the red L and G at the top.

  • Like 1

Share this post


Link to post
Share on other sites

@WurschtBanane Something else I remembered, if added to the player it may not stay after respawn.  If thats the case, place it in a respawn event handler as well.

Share this post


Link to post
Share on other sites
1 hour ago, wyattwic said:

 


0 = this addaction ["Teleport",{(_this select 1) setpos (markerpos "marker_Nimitz")}];

 

 

Works, thank you for that.

I have now got a second problem: It teleports me below the USS Nimitz deck. I tried adding "marker_Nimitz" setMarkerPosLocal [markerPos "marker_Nimitz" select 0, markerPos "marker_Nimitz" select 1, 170]; to the init.sqf to set the marker altitude (Which works with respawns) but it does not work with the teleport add action appearantly.

 

 

Share this post


Link to post
Share on other sites
1 minute ago, WurschtBanane said:

Works, thank you for that.

I have now got a second problem: It teleports me below the USS Nimitz deck. I tried adding "marker_Nimitz" setMarkerPosLocal [markerPos "marker_Nimitz" select 0, markerPos "marker_Nimitz" select 1, 170]; to the init.sqf to set the marker altitude (Which works with respawns) but it does not work with the teleport add action appearantly.

 

0 = this addaction ["Teleport",{(_this select 1) setpos [markerPos "marker_Nimitz" select 0, markerPos "marker_Nimitz" select 1, 170]}];

This should work.

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

×