Jump to content
Spatsiba

EndMission if slot not selected

Recommended Posts

Hey! 

 

I've been trying to make a mission which requires a certain slot to be selected.

I can't figure out a smart way to check if there's a player present in the slot. 

What I want is for the mission to end if there's no one in the team leader slot. 

 

if (isNull EOD_TL) then {endmission "end7"};

_playerList = [];
{_playerList pushBack _x;} forEach allPlayers;
if !(EOD_TL in _playerList) then {endMission "end7"}; 

I've tried a few things like that but nothing works. It just says EOD_TL is an undefined object. The fix isn't as easy as to add quotations around it neither. 

Share this post


Link to post
Share on other sites

if no one is occupying the slot it will return true for isNil
so:
 

waitUntil {time > 20}; //(give time for players to load)
if (isNil "EOD_TL") exitWith {endMission "end7"};
if !(isPlayer EOD_TL) then {endMission "end7"}; // end if and AI is in the slot

 

  • Thanks 1

Share this post


Link to post
Share on other sites
1 hour ago, Mr H. said:

if no one is occupying the slot it will return true for isNil
so:
 


waitUntil {time > 20}; //(give time for players to load)
if (isNil "EOD_TL") exitWith {endMission "end7"};
if !(isPlayer EOD_TL) then {endMission "end7"}; // end if and AI is in the slot

 

 

Ok I'm not the most knowledgable but what's the difference betwene isNil and isNull? Should you ever use isNull instead of isNil since it seems like a broader command? 

Share this post


Link to post
Share on other sites
Quote

THE DIFFERENCE BETWEEN NIL AND NULL VALUES

NULL - a null variable, is a valid variable name, that is either empty (like if you did 'anchor3 = objNull') or it was referring to an object that has since been delete (like in 'deleteVehicle anchor3')

NIL - a 'nil' value is a scripting variable name, that has never been created. so until you do either 'anchor3 = objNull;' or 'anchor3 = "classname" createVehicle [param, param, param]' the variable will be nil because the variable has never before been set or initialized. You can check if this is the case with isNil

source: https://forums.bohemia.net/forums/topic/169161-isnull-and-undefined-variable-issue/

If you place a playable entity and no one (including AI) is slotted on it at mission start it won't be created, and no variable will be created. So isNull won't work that's why you have to use isNil instead. that's also why I use the exitWith on the second line. I exit the scope because if the variable is Nil, the following line with !(isPlayer EOD_TL) will throw an error.

Share this post


Link to post
Share on other sites

I also suggest you use BIS_fnc_endMissionServer rather than just endMission -- The way you current have this set up, only the local machine will get the end mission. You seem to be executing this on the server, so I highly suggest you read the documentation for endMission -- Running endMission on just the server and not the clients will produce some very strange results. If you're insistent on using that command in particular, you can use the following code:

"End7" remoteExec ["endMission", 0];

 

  • Thanks 2

Share this post


Link to post
Share on other sites
29 minutes ago, Vauun said:

I also suggest you use BIS_fnc_endMissionServer rather than just endMission -- The way you current have this set up, only the local machine will get the end mission. You seem to be executing this on the server, so I highly suggest you read the documentation for endMission -- Running endMission on just the server and not the clients will produce some very strange results. If you're insistent on using that command in particular, you can use the following code:


"End7" remoteExec ["endMission", 0];

 

 

Yeah thanks! I've got it executing on server and all clients because reasons so I'm good :) I just didn't know the difference betwene isNull and isNil

  • 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

×