Cookieeater 10 Posted March 17, 2013 (edited) I have a script that a player can run that changes a public boolean. Let's refer to this as "scriptisrun". If scriptisrun is true, then I want to execute some code. The problem is that inside multiplayer, the code only runs on the client and not the server. How can I get a client running the script to message the server to change a public boolean? For clarification: I have used publicVariable, maybe I'm doing something wrong... init.sqf: publicVariable "scriptisactive"; scriptisactive = false; waitUntil { scriptisactive}; PlaySound "blah" titleText ["blah"} etc... playeraction.sqf: scriptisactive = true; When the player activates playeraction.sqf, the code underneath "waitUntil {scriptisactive};" only runs for him, and not for the rest of the players in the game. Edited March 17, 2013 by Cookieeater Share this post Link to post Share on other sites
Tuliq 2 Posted March 17, 2013 Hey, I might not fully understand what problem you are having, still I am going to blindly suggest you try using publicVariable and maybe addPublicVariableEventHandler. :p Share this post Link to post Share on other sites
Cookieeater 10 Posted March 17, 2013 I have used publicVariable, maybe I'm doing something wrong... init.sqf: publicVariable "scriptisactive"; scriptisactive = false; waitUntil { scriptisactive}; PlaySound "blah" titleText ["blah"} etc... playeraction.sqf: scriptisactive = true; When the player activates playeraction.sqf, the code underneath "waitUntil {scriptisactive};" only runs for him, and not for the rest of the players in the game. Share this post Link to post Share on other sites
loyalguard 15 Posted March 18, 2013 You are almost there, you just have the order of things wrong. I commented each block to give a breakdown of what is happening. Try this: // init.sqf // Initialize the variable at startup on server and all clients. scriptIsActive = false; // Pause the script only on the server until the variable is true. if (isServer) then { waitUntil {scriptIsActive}; PlaySound "blah"; titleText ["blah"}; etc... }; //playerAction.sqf // Change the value of variable on the client only. scriptIsActive = true; // Broadcast the new value to server and other clients so script can continue on server. publicVariable "scriptIsActive"; Note that is added an isServe check to make sure you only pause the init.sqf on the server (which won't show title texts unless a MP host). Please note there is also a new command in A3 called publicVariableServer that will only broadcast to the server, so in this case I would actually recommend using it instead of publicVariable to reduce network traffic. As stated above, you could also use a public variable event handler on the server to wait for the value of the variable to change instead of the waitUntil. The above code is NOT JIP compatible (it can be but I kept it simple). I hope this helps. Share this post Link to post Share on other sites
Cookieeater 10 Posted March 19, 2013 Thanks a lot, Loyalguard. This script works but turns out my mission is completely broken when running on a dedicated server. Thanks for the help though, I'll remember it when I get to this part again. Share this post Link to post Share on other sites