Jump to content
Sign in to follow this  
Liamsmith

Need help with a teleport script

Recommended Posts

I`m trying to create a mission file where you fight somewhere. You spawn in and choose your location to fight. You will be fighting with multiple players so i want it so there loads of markers and you spawn on one if their isn't a player with in 10m or something. However, i keep on getting this error message.

I used this is in the character init - this addAction ["Teleport To OG Arms","OG_Arms.sqf"];

 

My Code - https://pastebin.com/KguSKuhf

 

Error Message - https://gyazo.com/0ac25ca29f016f85cbd91812859db70d

 

 

Share this post


Link to post
Share on other sites

Try:

_OG_Arms = ceil(random 2);
if (_OG_Arms == 1) then {  
    OG_Location = getmarkerpos "OG_Arms_1";
    OG_Check = OG_Location nearEntities [[man], 15];
    if (OG_Check isEqualTo []) then {
        player setpos OG_Location;
} else {
    _OG_Arms = 2;
};};
if (_OG_Arms == 2) then {  
    OG_Location = getmarkerpos "OG_Arms_2";
    OG_Check = OG_Location nearEntities [["man"], 15];
    if (OG_Check = []) then {
        player setpos OG_Location;
} else {
    ["All spawns blocked!"] call tankode_fnc_notification_system;
};

No guarantees tho, didn't test it.

Share this post


Link to post
Share on other sites

It works however when i place  an AI by OG_Arms_1 to simulate and player being their and forcing to teleport some where else, nothing happens when i scroll wheel and click.

Share this post


Link to post
Share on other sites

Is "man" a global variable or something? where did you declare it?
I think no. nearEntities needs a typename, so your command should look like this :
OG_Check = OG_Location nearEntities [["man"], 15];

Share this post


Link to post
Share on other sites

 

5 minutes ago, JeyR said:

Is "man" a global variable or something? where did you declare it?
I think no. nearEntities needs a typename, so your command should look like this :
OG_Check = OG_Location nearEntities [["man"], 15];

Done it but it doesnt work.

Share this post


Link to post
Share on other sites

Then show us the next error. I was referencing to bis_wiki, you used the command correctly in the second if, but not the first. 

Share this post


Link to post
Share on other sites

Try using this code (again didn't test it, no guarantees):

OG_Location = getmarkerpos "OG_Arms_1";
OG_Check = OG_Location nearEntities [["man"], 15];

if (OG_Check isEqualTo []) then {
	player setpos OG_Location;
} else {
  OG_Location = getmarkerpos "OG_Arms_2";
  OG_Check = OG_Location nearEntities [["man"], 15];
  if (OG_Check isEqualTo []) then {
  	player setpos OG_Location;
  } else {
  	["All spawns blocked!"] call tankode_fnc_notification_system;
  };
};

 

 

Edited by stanhope
fixed something

Share this post


Link to post
Share on other sites

This is your code here, and I just saw that you were missing { somewhere at the end, 

_OG_Arms = ceil(random 2);
if (_OG_Arms == 1) then 
{  
    OG_Location = getmarkerpos "OG_Arms_1";
    OG_Check = getmarkerpos "OG_Arms_1" nearEntities ["man", 15];
    if (OG_Check isEqualTo []) then 
    {
        player setpos OG_Location;
    } 
    else 
    {
        _OG_Arms = 2;
    };
};
if (_OG_Arms == 2) then 
{  
    OG_Location = getmarkerpos "OG_Arms_2";
    OG_Check = getmarkerpos "OG_Arms_2" nearEntities [["man"], 15];
    if (OG_Check = []) then 
    {
        player setpos OG_Location;
    };
} 
else 
{
    ["All spawns blocked!"] call tankode_fnc_notification_system;
};

 

Share this post


Link to post
Share on other sites

@JeyR: "OG_Check = []" doesn't work in an if (Only just noticed myself too :) )

  • Thanks 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
Sign in to follow this  

×