Holden93 12 Posted May 9, 2014 (edited) Hello, I made two scripts, a timer and an enemy spawner. These two scripts get executed when two objects are destroyed but I was wondering, what happens if the mission is played in MP? These are the scripts: timer.sqf _minutes = 2; _counter = 59; while {_minutes >= 0} do { sleep 1; if(_counter > 9) then { hint format["Enemy arrival in 0%1:%2", _minutes, _counter]; }; if(_counter < 10) then { hint format["Enemy arrival in 0%1:0%2", _minutes, _counter] }; _counter = _counter - 1; if(_counter == -1) then { _counter = 59; _minutes = _minutes - 1; }; if(_counter == 0 && _minutes == 0) then { 0 = execVM "enemyspawn.sqf"; }; }; enemySpawn.sqf _spawnMarker = ["mrk1", "mrk2", "mrk3", "mrk4"] call BIS_Fnc_SelectRandom; hint format["%1", _spawnMarker]; _bombs = ["bomb1", "bomb2", "bomb3", "bomb4", "bomb5", "bomb6", "bomb7", "bomb8", "bomb9", "bomb10"]; _i = 0; while {_i < 8} do { _bombMarker = _bombs select _i; bomb = "Bo_GBU12_LGB" createVehicle getmarkerPos _bombMarker; _i = _i + 1; sleep 0.5; if(_i == 7) exitWith{hint "hello"}; //debug } sleep 5; _side = createCenter EAST; _group1 = [getMarkerPos _spawnMarker, _side, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfSquad")] call BIS_Fnc_spawnGroup; _group1 doMove (getMarkerPos "TOWN_MARKER"); sleep 30; _spawnMarker = ["mrk1", "mrk2", "mrk3", "mrk4"] call BIS_Fnc_SelectRandom; _group2 = [getMarkerPos _spawnMarker, _side, (configfile >> "CfgGroups" >> "East" >> "OPF_F" >> "Infantry" >> "OIA_InfSquad")] call BIS_Fnc_spawnGroup; _group2 doMove (getMarkerPos "TOWN_MARKER"); If there are 4 players, do the scripts get executed 4 times? If yes, how can I prevent that? Thanks! Edited May 9, 2014 by Holden93 Share this post Link to post Share on other sites
mariodu62 5 Posted May 9, 2014 put this line at the beginning of your file. if !(isServer) exitwith {}; Share this post Link to post Share on other sites
Holden93 12 Posted May 9, 2014 Just read more about isServer in the wiki, but to execute the scripts once shouldn't it be if(isServer) ? Share this post Link to post Share on other sites
mariodu62 5 Posted May 9, 2014 Just read more about isServer in the wiki, but to execute the scripts once shouldn't it be if(isServer) ? read the syntax.... Share this post Link to post Share on other sites
alleycat 28 Posted May 9, 2014 (edited) if it is called from the serverside it will only run on the server. Also createvehicle reliably will spawn things and they will appear for all players and not multiply. To be safe do what mario said, or: if (isserver) then { }; isServer fires on both a dedicated server, client hosted server and in the editor. My and marios code do the same thing. His code exits the script if the caller is not a server. While mine runs what is in the bracket if it is a server So if you want to not actually call the script and then exit if its not a server, you can do if (isserver) then { //run your script }; This will skip calling the script if th condition (isserver) is not true All of it said my approach would be a bit more economic, because you dont even have to call a script if it is not a server. Edited May 9, 2014 by alleycat Share this post Link to post Share on other sites