Jump to content

Recommended Posts

Hi, i was wondering if anyone could help with making a random teleport script ill go over what I've been attempting to do so far.

 

I made a teleport.sqf file within the mission folder and added this to the file.

private _markersArray = ["marker_1", "marker_2", "marker_3"];
private _randomMarker = selectRandom _markersArray;
private _pos = getMarkerPos _randomMarker;
_caller setPosASL _pos;

I then put this script in the init section of the object I'm using to teleport me.

 

this addAction ["Teleport","teleport.sqf",["marker_1","marker_2","marker_3"]];

 

I know its probably very obvious what I'm doing wrong but when it comes to scripting I am more than clueless id appreciate if anyone could explain to me what's wrong and where to put the corrected scripts

  • Like 1

Share this post


Link to post
Share on other sites

1 - Why passing global variables or marker names in an addAction when you could use it straight in your sqf?

2 - on the other hand, your sqf passes embedded parameters of the addAction (see example 2) but you need to define them. In your script _caller is not defined.

 

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

 

your sqf:
 

params ["_tgt","_caller"];
_caller setPos getMarkerPos selectRandom ["marker_1","marker_2","marker_3"];

 

 

  • Like 2

Share this post


Link to post
Share on other sites
37 minutes ago, pierremgi said:

1 - Why passing global variables or marker names in an addAction when you could use it straight in your sqf?

2 - on the other hand, your sqf passes embedded parameters of the addAction (see example 2) but you need to define them. In your script _caller is not defined.

 


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

  

your sqf:
 


params ["_tgt","_caller"];
_caller setPos getMarkerPos selectRandom ["marker_1","marker_2","marker_3"];

 

 

 

Thank you so much this worked perfectly, the other posts i looked at made it so  much more difficult, cheers mate

Share this post


Link to post
Share on other sites

In case you want to add some fancy - but easy! - stuff:

 

  • 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

×