Spatsiba 89 Posted September 27, 2018 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
Mr H. 402 Posted September 27, 2018 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 1 Share this post Link to post Share on other sites
Spatsiba 89 Posted September 27, 2018 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
Mr H. 402 Posted September 27, 2018 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
Vauun 5 Posted September 28, 2018 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]; 2 Share this post Link to post Share on other sites
Spatsiba 89 Posted September 28, 2018 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 1 Share this post Link to post Share on other sites