macusercom 10 Posted January 14, 2015 I'm currently experimenting and reading a lot about the "init.sqf" and wanted to execute an intro script on mission load, but not for JIP. This resulted in having the script being called on mission start and for JIP. If this I say "isDedicated" shouldn't it be only executed by the server once and not for JIP? if (isDedicated) then { [ markerPos "CAMERA", // Target position (replace MARKERNAME) "BLABLA", // SITREP text 200, // m altitude 100, // m radius 40, // 0 degrees viewing angle 1, // Clockwise movement [ // add Icon at player's position ["\a3\ui_f\data\map\markers\nato\b_recon.paa", _colorWest, markerPos "", 1, 1, 0, 0], // add Icon at enemy/target position; ["\a3\ui_f\data\map\markers\nato\o_inf.paa", _colorEast, markerPos "", 1, 1, 0, 0] ] ] spawn BIS_fnc_establishingShot; }; Also this resulted in the same as above, but only "else" so "SECOND THING" was executed on mission start and JIP. if (isDedicated) then { FIRST THING } else { SECOND THING }; What am I doing wrong? :/ Share this post Link to post Share on other sites
jshock 513 Posted January 14, 2015 Execute it in the initServer.sqf. https://community.bistudio.com/wiki/Event_Scripts Executes whatever once on mission start, only on the server. Share this post Link to post Share on other sites
macusercom 10 Posted January 14, 2015 @JShock: Already tried that and it did nothing for any player :S Share this post Link to post Share on other sites
jshock 513 Posted January 14, 2015 Then execute in the initPlayerServer.sqf with the following at the top: if (_this select 1) exitWith {}; Will execute on mission start only, and every JIP will execute the script, but will immediately get kicked out at the start, on the server. Use initPlayerLocal.sqf if you don't want it on the server, same concept. Share this post Link to post Share on other sites
macusercom 10 Posted January 14, 2015 Tried that now too. My sqf looks like this (still no effect for any player). EDIT: Will try initPlayerLocal.sqf. initPlayerServer.sqf if (_this select 1) exitWith {}; [ markerPos "CAMERA", // Target position (replace MARKERNAME) "BLABLA", // SITREP text 200, // m altitude 100, // m radius 40, // 0 degrees viewing angle 1, // Clockwise movement [ // add Icon at player's position ["\a3\ui_f\data\map\markers\nato\b_recon.paa", _colorWest, markerPos "", 1, 1, 0, 0], // add Icon at enemy/target position; ["\a3\ui_f\data\map\markers\nato\o_inf.paa", _colorEast, markerPos "", 1, 1, 0, 0] ] ] spawn BIS_fnc_establishingShot; Share this post Link to post Share on other sites
jshock 513 Posted January 14, 2015 Try it in the initPlayerLocal, cause this seems to need to be run locally not on the server. Beat you to your edit :p. Share this post Link to post Share on other sites
macusercom 10 Posted January 14, 2015 So with "initPlayerLocal.sqf" it actually works only for the first time and then you spawn, it freezes half a second and you don't see any camera script or intro at all. Not completely perfect, but the best solution I've found yet and moreover it's working. So if I have "if (isXYZ)" it only checks if it should execute, is that correct? So if I say "if (isDedicated)" then it seems to execute locally and globally if it is a dedicated server. I'm always reading that it should only run on the server and NOT locally. EDIT: Did they change that in ArmA 3 after introducing the new sqfs like initPlayerLocal and so on? Share this post Link to post Share on other sites
jshock 513 Posted January 14, 2015 I think your misunderstanding what the isDedicated and isServer commands check, they are for locality in terms of where the current code is being executed (clientside or serverside), then the code within the {} will be executed on whatever that condition was (client, server, or dedicated box). For the effect your trying to do, it needs to be run on the client, not the server, because its an effect the client has to see, now for object creation and so forth, yes execute it on the server. https://community.bistudio.com/wiki/isServer https://community.bistudio.com/wiki/isDedicated To fix your not seeing it issue, try the following after the if (_this select 1) line: waitUntil {time > 5}; Share this post Link to post Share on other sites
macusercom 10 Posted January 14, 2015 I know exactly what they are, but I've seen some weird behaviour. I'm now not quite sure if I might have put an "!" in front of it, which would explain why I saw the script executed locally when "isDedicated" was used. I've checked it now again and it works like it should (isDedicated now doesn't execute locally). I guess this mistake started my confusion. Thanks anyway, it works with "initPlayerLocal.sqf" thanks to ArmA 3's new sqf options ;) Share this post Link to post Share on other sites
killzone_kid 1332 Posted January 14, 2015 if (isDedicated) then {...code...}; placed in init.sqf will execute ...code... on dedicated server only once when mission starts, period. Share this post Link to post Share on other sites
GieNkoV 30 Posted January 14, 2015 Put this to init.sqf: runonce = if(isNil "runonce") then {true} else {runonce}; if(runonce) then { YOUR CODE }; sleep 1; runonce = false; publicVariable "runonce"; Let me know if worked. Wysłane z mojego WT19i przy użyciu Tapatalka Share this post Link to post Share on other sites
jshock 513 Posted January 15, 2015 Put this to init.sqf:runonce = if(isNil "runonce") then {true} else {runonce}; if(runonce) then { YOUR CODE }; sleep 1; runonce = false; publicVariable "runonce"; Let me know if worked. I think I get what your doing here, however, with the Event Scripts and the simplicity of using isDedicated/isServer as well, there is not much of a point in doing all this work yourself with the code? Share this post Link to post Share on other sites
killshot 5 Posted January 15, 2015 Another solution to have the intro.sqf not played for JIP-players: init.sqf if (isServer) then { 0 spawn { sleep 30; SkipIntro = true; publicVariable "SkipIntro"; }; }; intro.sqf if (!isNil "SkipIntro") exitWith {}; This worked for me, but I don't know, if it's the best way to do so. Share this post Link to post Share on other sites
fn_Quiksilver 1636 Posted January 15, 2015 The A3 event scripts, put together I believe by Moricky, merely formalized the messy process scenario designers used in 'init.sqf' by doing this stuff: // old A2 example 'init.sqf' if (isServer) then { //server stuff [] spawn { // JIP bool for clients isJIP = FALSE; publicVariable "isJIP"; waitUntil {(time > 15)}; isJIP = TRUE; publicVariable "isJIP"; }; if (isDedicated) then { // dedi only server stuff } else { // non-dedi only server stuff }; } else { // client stuff if (isJIP) then { // join-in-progress only client stuff } else { // join-at-start only client stuff }; }; ---------- Post added at 15:34 ---------- Previous post was at 15:28 ---------- Another solution to have the intro.sqf not played for JIP-players:init.sqf if (isServer) then { 0 spawn { sleep 30; SkipIntro = true; publicVariable "SkipIntro"; }; }; intro.sqf if (!isNil "SkipIntro") exitWith {}; This worked for me, but I don't know, if it's the best way to do so. If it works for your purposes its good enough :) Share this post Link to post Share on other sites
macusercom 10 Posted January 15, 2015 So the thing with "if (!isNil "SkipIntro") exitWith {};" is that I have the same short freeze as before. The ArmA 2 script with all options explained is awesome, that's what I was searching for. However, I have one more question. I'm trying to ungroup all playable units for the mission, but as I want a nice and clean lobby, I have to group them in the mission.sqm. I could just place the code in the init.sqf without checking if multiplayer etc., but I want it to only be activated in multiplayer and not in singleplayer. I have this: if (isMultiplayer) then { _group=createGroup West; [player] join _group; }; However, if I join as OPFOR unit, I still get killed by BLUFOR. Works without "isMultiplayer" on a dedi server. And I don't want to use "isDedicated". Share this post Link to post Share on other sites