Jump to content
Jordan Booth

Random Flagpole Teleport

Recommended Posts

I have a basic flagpole teleporter with 4 markers. How would you make it so that it randomly chooses one of the spawn points and send you there rather than choosing one yourself? 

 

Flagpole init:

 

this addaction ["Rock1","Rock1.sqf"]; this addaction ["Rock2","Rock2.sqf"]; this addaction ["WindmillRock","WindmillRock.sqf"]; this addaction ["Other","Other.sqf"];

 

Rock1.sqf:

 

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

_caller setPos (getpos (Rock1));

Share this post


Link to post
Share on other sites

this addaction ["Teleport","teleport.sqf"];

and in teleport.sqf

 

params ["","_caller"];   // same as  _caller = _this #1;

_caller setpos getmarkerPos selectRandom ["yourmarker1", "yourmarker2","yourmarker3","yourmarker4"];

 

CORRECTED

  • Like 4

Share this post


Link to post
Share on other sites

Yep, there's a typo in pierremgi's snippet.

 

He writes

params ["",_caller"];   // same as  _caller = _this #1; 

where it should be

params ["","_caller"];   // same as  _caller = _this #1; -> MISSING ONE " BEFORE _CALLER

Haven't tested it, but it is simple enough to be able to say that it SHOULD work now.

 

Please don't hesitate to ask again if you encounter any other issues.

  • Like 3

Share this post


Link to post
Share on other sites

 

Thanks that works now. I put the " before the _ at first because i'm stupid and thought it still didn't work but after moving it to before the _ it works.

 

EDIT:   After trying it a few times it doesn't teleport me to the correct position and teleports me into the sea.

Share this post


Link to post
Share on other sites
20 minutes ago, Jordan Booth said:

 

Thanks that works now. I put the " before the _ at first because i'm stupid and thought it still didn't work but after moving it to before the _ it works.

 

EDIT:   After trying it a few times it doesn't teleport me to the correct position and teleports me into the sea.

Make sure there are no typos and upper/lower case errors in your marker array or editor placed markers.

Also post the snippet that didn't work.

 

Cheers

  • Like 3

Share this post


Link to post
Share on other sites

Flagpole:

 

this addaction ["OG Castle","hmm.sqf"]; 
 

hmm.sqf:

 

params ["","_caller"];
_caller setpos getmarkerPos selectRandom ["Rock", "Stone","Corner","Main"];

 

 

Are these compatible i am having problems. I have double checked there are no spelling mistakes or typos but could some please check. Thnx

Share this post


Link to post
Share on other sites
2 hours ago, Jordan Booth said:

Flagpole:

 

this addaction ["OG Castle","hmm.sqf"]; 
 

hmm.sqf:

 

params ["","_caller"];
_caller setpos getmarkerPos selectRandom ["Rock", "Stone","Corner","Main"]; 

 

 

Are these compatible i am having problems. I have double checked there are no spelling mistakes or typos but could some please check. Thnx

What kind of problems? Besides a missing closing bracket?

Always check the wiki for syntax and enable -showScriptErrors as startup parameter.

Also good to use a text editor that supports .sqf syntax highlighting.

 

Alternatively you could get rid of the .sqf file and put this into the objects init field:

this addaction ["OG Castle","_this#1 setpos getmarkerPos selectRandom ['Rock', 'Stone','Corner','Main']"];

 

Cheers

  • Like 1

Share this post


Link to post
Share on other sites
58 minutes ago, Grumpy Old Man said:

 


this addaction ["OG Castle","_this#1 setpos getmarkerPos selectRandom ['Rock', 'Stone','Corner','Main']"];

 

This also teleports my into the ocean in the bottom left corner of the map.

Share this post


Link to post
Share on other sites

Have you tried with parenthesis?

this addaction ["OG Castle","_this#1 setpos (getmarkerPos (selectRandom ['Rock', 'Stone','Corner','Main']))"];

 

Are "Rock, Stone, Corner, Main" markers?

 

Share this post


Link to post
Share on other sites

All these solutions work. So check your markers. I guess you wrote "rock", "stone"... in the init field of markers. That's not correct. You must write the name without quote in these fields: rock, stone, ...  as any object's name in editor. Then in script you need to refer at the quoted name "rock", "stone" because that's markers (with specific getMarkerPos apply to the marker string,  instead of getPos for an object (not stringed))

  • Like 2

Share this post


Link to post
Share on other sites

Hey @Jordan Booth, would care to share your solution for other people to benefit from it in the future?

 

In the end of the day this is one of the many purposes of the forums, for people to exchange information and benefit from it.

  • Like 2

Share this post


Link to post
Share on other sites
On 7/19/2019 at 9:09 PM, Jordan Booth said:

Solved, sorry for wasting everyone's time. 

How did you do it ??

 

  • 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

×