zakiechan 11 Posted January 8, 2015 (edited) Working on a JIP issue. Server spawns a main objective then selects a type of secondary mission and spawns it nearby. My issue is having a JIP-proof firing of a publicVariable to trigger the addpublicvariableeventhandler that creates an addaction to capture the secondary mission upon interaction. I have a global variable that gets defined after the very first time the server publicVariable's. I check its existence as part of JIP analysis code. I have issues where someone will connect before "originalCaptureFired" defined, (thus making me expect the client to be in time to receive the initial publicVariable) but they load in late and miss the firing of the first publicVariable. Thus they dont get the addaction. Im looking for a way to check if the player is actually ingame vs in slot selection etc.. So i can filter it out and make sure I publicvariableClient to the player that needs it. Any help is appreciated! Relevant Code: Init.sqf if(!isServer) then {execVM "EventHandlers.sqf"}; //Runs only on clients CaptureSecondaryMission.sqf //****THIS IS A SNIPPET OF RELEVANT PARTS OF CAPTURE MISSION**** //----SCAN SPAWNED ASSET FOR THE "FLAG" switch(_assetsChosen) do { case "Fuel Depot": {_csatFlag = nearestObjects [_secObjLocation, ["Land_PowerGenerator_F"], 500] select 0}; case "HQ Complex": {_csatFlag = nearestObjects [_secObjLocation, ["Flag_CSAT_F"], 500] select 0}; case "Research Station": {_csatFlag = nearestObjects [_secObjLocation, ["Flag_CSAT_F"], 500] select 0}; case "Detention Facility": {_csatFlag = nearestObjects [_secObjLocation, ["Flag_CSAT_F"], 500] select 0}; case "SAM Site": {_csatFlag = nearestObjects [_secObjLocation, ["Land_SatellitePhone_F"], 500] select 0}; case "Camp": {_csatFlag = nearestObjects [_secObjLocation, ["Land_SatellitePhone_F"], 500] select 0}; case "Listening Post": {_csatFlag = nearestObjects [_secObjLocation, ["Land_PowerGenerator_F"], 500] select 0}; }; playerHitFlag = false; makeAddAction = [_assetsChosen, _csatFlag]; //hintC format["%1", makeAddAction]; removeAddAction = [_csatFlag]; //-------BROADCAST VARIABLE TO ASSIGN CAPTURE ADDACTION publicVariable "makeAddAction"; originalCaptureFired = true; EventHandlers.sqf "makeAddAction" addPublicVariableEventHandler { private ["_assetChosen", "_csatFlag", "_passedContent"]; if (isNull (((_this select 1) select 1))) then { systemChat "making addaction failed";//if csat flag wasnt passed } else { _passedContent = _this select 1; _assetChosen = _passedContent select 0; _csatFlag = _passedContent select 1; _csatFlag addAction[format["<t size='1.5' color='#ffff00'>Capture the %1</t>", _assetChosen], { cutText ["Capturing... Standby","PLAIN",1]; playerHitFlag = true; removeAddAction = [_this select 0]; publicVariableServer "playerHitFlag"; publicVariable "removeAddAction"; (_this select 0) removeAction 0; }, 0, 6]; systemChat format["Capture addAction CREATED"]; }; }; initPlayerServer.sqf //This is what the server does upon client connection private["_didPlayerJIP","_playerID", "_player"]; //get the client id of the player connecting _player = _this select 0; _didPlayerJIP = _this select 1; _playerID = owner _player; systemChat format["%1, %2, %3",_player,_didPlayerJIP, _playerID]; if(_didPlayerJIP) then { systemChat "entered JIP condition"; if(isNil "originalCaptureFired") then { systemChat "Original firing will kick in"; //********THIS IS WHERE THE PROBLEM LIES******* // I believed this was a clean fix but a connection between the server "continue" event and firing of the original public variable (ie originalCaptureFired) // Results in the client not receiving the publicVariable from intial time server sends it (Which is my big problem :s ) } else { //if secondary is on, and mission is capture, and hasn't been captured yet if(!secObjCompleted && secObjMissionType == "Capture" && !playerHitFlag) then { _playerID publicVariableClient "makeAddAction"; //add the action for capture systemChat "PublicVariable Fired"; }; systemChat "End of JIP Code"; }; }; Edited January 8, 2015 by zakiechan (changed to php code for legibility) Share this post Link to post Share on other sites
jshock 512 Posted January 8, 2015 (edited) waitUntil {!isNull player}; //OR waitUntil {time > 0}; //OR use both to ensure player has spawned in Edited January 8, 2015 by JShock Share this post Link to post Share on other sites
zakiechan 11 Posted January 8, 2015 Thanks, that seems to be exactly what I was after! Share this post Link to post Share on other sites