citazenman 10 Posted May 13, 2015 I have a bit of brain melter today.(at least for me it is) I have an issue trying to set up repeatable, randomly generated side missions for a Firing Range/Bootcamp mission I'm making for ACE . Players will be able to walk over to a Mission Board(filled with addactions for each mission type) and start missions. I have a system in place so that only one of the missions can be active at once and a reset option to clear the active mission. In single player testing the mission is great. There are no loops or heavy weight scripting at all. However, it doesn't transition well into MP(not much ever does for a learning scripter). Hopefully the code will explain itself. I've tried all sorts of varieties of IsServer and BIS_FNC_MP but I can never get a result that will work for all the different missions. I'm just going to show an example of one of the side missions in singleplayer form. Init Reveal hidden contents MissionIsGo = 0; publicVariable "MissionIsGo"; missionNoGo = 0.5; publicVariable "missionNoGo"; specopMission = missionBoard addAction ["Spec Op Mission", "specopmission.sqf", "", 0, false]; specopmission.sqf Reveal hidden contents if (MissionIsGo < missionNoGo) then { MissionIsGo = 1; publicVariable "MissionIsGo"; missionlocations = [ml1,ml2,ml3,ml4,ml5,ml6,ml7,ml8,ml9,ml10,ml11,ml12,ml13,ml14,ml15,ml16,ml17,ml18,ml19,ml20] call bis_fnc_selectrandom; specop = [missionlocations, 3, true, 2, 10, 100, 1, nil, nil, 7] execVM "LV\fillHouse.sqf"; hint "Mission Started"} else {hint "A Mission Is Already In Progress"}; LV\fillHouse.sqf is from here http://www.armaholic.com/page.php?id=19832 <- Probably not the problem or solution If you have any optimizations or ways I can get this functioning in MP I would be very grateful. Thanks. Share this post Link to post Share on other sites
austin_medic 109 Posted May 13, 2015 (edited) addAction can have a condition for it to check in order for the action to appear instead of this in init.sqf: specopMission = missionBoard addAction ["Spec Op Mission", "specopmission.sqf", "", 0, false]; you can use this: missionBoard addaction ["Spec Op Mission","specopmission.sqf","",1,False,True,"",' missionIsGo == 0 ']; As for randomization, all of that should be done by the server only, then use publicVariable to broadcast results to clients, your mission is going to need something to send the updated info to all players that join later as well. You should also use a check before you define variables that are sent across the network in init.sqf or anywhere else to see if it is already defined (since the information might make it before the script sets the default value, and thus ends up overwriting the value you just gave it. You will probably also have problems with the script being duped by one times the amount of clients connected as they all run that same script, and create the objects. As a theory you could simply name all objects then do a check on each client to see if it already exists in the gameworld (though once again time might come into play and interfere, so sleep might be needed to alleviate the problem, and even then thats not a fool-proof solution). Edited May 14, 2015 by austin_medic Share this post Link to post Share on other sites
jshock 513 Posted May 13, 2015 Make the condition in austin's code with "==" not a single "=". Share this post Link to post Share on other sites
dale0404 5 Posted May 15, 2015 Hi CitazenMan, hope you don't mind but I am going to slightly hijack your thread because we are both having the same problem. As the OP has stated, I am also having an issue with locality. The script I am using works perfectly when I host the mission but when I put it onto a dedi nothing happens. I have tried everything I can think of, same as what the OP says tbh. Here is the script: endmissionstate.sqf: if (isDedicated) then { ["task2", "Succeeded"] call FHQ_TT_setTaskState; if (["task1"] call FHQ_TT_isTaskCompleted) then { ["BlueWin",true,7] call BIS_fnc_endMission; } else { if (["task2"] call FHQ_TT_isTaskCompleted) then { ["task1", "Failed"] call FHQ_TT_setTaskState; sleep 10; ["BlueLoose",false,7] call BIS_fnc_endMission; }; }; }; As you can I see I am using FHQTT for tasks but I do not believe this is the problem. I am calling the script via addAction on an AI. Share this post Link to post Share on other sites
neokika 62 Posted May 15, 2015 Hi Dale, Quote I am calling the script via addAction on an AI. if (isDedicated) then This is the issue. When a player clicks an action (addAction) the code which get's executed is run in the player's computer, the player which clicked the action. So the code is never run on the dedicated server, because dedicated server has no player. So: ["task2", "Succeeded"] call FHQ_TT_setTaskState; if (["task1"] call FHQ_TT_isTaskCompleted) then { ["BlueWin",true,7] call BIS_fnc_endMission; } else { if (["task2"] call FHQ_TT_isTaskCompleted) then { ["task1", "Failed"] call FHQ_TT_setTaskState; sleep 10; ["BlueLoose",false,7] call BIS_fnc_endMission; }; }; Never get's executed. If you remove this part: if (isDedicated) then { }; Then it should work. Share this post Link to post Share on other sites
Larrow 2823 Posted May 22, 2015 Quick example mission based off of the OP's description.. TEST MISSION Share this post Link to post Share on other sites