Freddan962 1 Posted March 28, 2013 How do I execute a script once on loadup in the init.sqf? Thank you, Fred. Share this post Link to post Share on other sites
loyalguard 15 Posted March 28, 2013 We might need a little more information to make sure we are giving you what you need. The init.sqf is only run once at mission startup so any script executed from it will also only run once. The only time the script would be run again is if there was a loop that continually executes it or you re-execute it in another script. Now, if your concern is that in MP, every client and the server will execute the script independently, you can limit that by using isServer to only run on the server or use global!public variables to tell machines it has already been run. Share this post Link to post Share on other sites
Freddan962 1 Posted March 28, 2013 (edited) We might need a little more information to make sure we are giving you what you need. The init.sqf is only run once at mission startup so any script executed from it will also only run once. The only time the script would be run again is if there was a loop that continually executes it or you re-execute it in another script. Now, if your concern is that in MP, every client and the server will execute the script independently, you can limit that by using isServer to only run on the server or use global!public variables to tell machines it has already been run. For some reason this is being run multiple times: execVM "mission.sqf"; to a level where it spawns the buildings 8 or more times each so it's impossible moving through the doors. I'm trying to find a way to not make it execute not over and over again. Edit; Could you give me a example with the isServer code? Edited March 28, 2013 by Freddan962 Share this post Link to post Share on other sites
jacmac 2 Posted March 28, 2013 if (! isServer) exitWith {}; Put at the top of your mission.sqf, otherwise every one of the MP clients that connects will execute the code. If there was code in mission.sqf that clients should execute, I would recommend that you take it out of mission.sqf and put it in it's own file like mission_client.sqf and rename mission.sqf to mission_server.sqf. Then it will be really clear which code is for what. Share this post Link to post Share on other sites
nuxil 2 Posted March 28, 2013 also. all info you need is on the biki. many of the commands even got small examples. https://community.bistudio.com/wiki/Category:Scripting_Commands https://community.bistudio.com/wiki/isServer if (isServer || isDedicated) exitwith ( some code) Share this post Link to post Share on other sites
killzone_kid 1326 Posted March 28, 2013 Is it a server script? Got to be, right, otherwise what is the point running it only once on random client PC. if (isServer) then { ...run script here... }; init.sqf runs on the server only once for the 1st person who joins the server hence if (isServer) Share this post Link to post Share on other sites