Incontinentia 339 Posted January 10, 2016 Hi all, I'm trying to add an action to a tent that allows the player to skip ahead a few hours. It works flawlessly on local and hosted servers, but doesn't work on a dedicated. Here's the addaction in the initialisation: this addAction ["Sleep for 2 hours","scripts\sleep2.sqf",[],1,false,true] call BIS_fnc_MP; And in sleep2.sqf, I have the following: if (!isDedicated) then { titleText ["You rested for 2 hours", "BLACK IN",7]; skipTime 2; }; With what I have above, the script runs fine, but the server resets the time after the script is run so it goes back to the original time. I presume it's something to do this the server trying to maintain synchronised time across clients but I have no idea how to override this or to execute it globally. I figured call BIS_fnc_MP would do that but doesn't seem to work. Incidentally, the script works flawlessly on dedi if it's executed by a trigger. Just can't get addaction to work. I'm massively new to this so any help would be appreciated. Cheers! 1 Share this post Link to post Share on other sites
davidoss 552 Posted January 10, 2016 you need to change time on server only remove or change the (!isDedicated) part Look there quite at the bottom what KK says. Share this post Link to post Share on other sites
Incontinentia 339 Posted January 10, 2016 you need to change time on server only remove or change the (!isDedicated) part Look there quite at the bottom what KK says. Thanks for the help. I did actually initially run this without the !isDedicated but the issue was the same. Any idea how I'd execute this on the server? I really am a total newbie in this stuff so may need a bit of handholding! Share this post Link to post Share on other sites
davidoss 552 Posted January 10, 2016 well there are couple ways to achieve this. Do you use CBA mod? 1 Share this post Link to post Share on other sites
Incontinentia 339 Posted January 10, 2016 I do, yes! Share this post Link to post Share on other sites
davidoss 552 Posted January 10, 2016 Try this [0,{ skipTime 2}] call CBA_fnc_globalExecute; or [0,{ skipTime _this},2] call CBA_fnc_globalExecute; https://dev.withsix.com/docs/cba/files/network/fnc_globalExecute-sqf.html 1 Share this post Link to post Share on other sites
R3vo 2654 Posted January 10, 2016 A vanilla way would be 1 remoteExec ["skipTime", 2, false]; // 1 is the time you skip, 2 means server only, false is JIP disabled Share this post Link to post Share on other sites
Belbo 462 Posted January 10, 2016 skipTime has local effects only. By executing this command from an addaction the time will be reverted back to the server time after roughly 5 seconds (as explained here, at the bottom of the page). That way your script can't work without the help of some sort of remote execution by either BIS_fnc_MP or remoteExec. With BIS_fnc_MP I see no reason why it shouldn't work, presumed you deactivated whitelisting in CfgRemoteExec. Syntax would be: titleText ["You rested for 2 hours", "BLACK IN",7]; [[{ skipTime 2; }], "BIS_fnc_call"] call BIS_fnc_MP; Alternatively you could use remoteExec titleText ["You rested for 2 hours", "BLACK IN",7]; 2 remoteExec ["skipTime", 2, false]; 1 Share this post Link to post Share on other sites
Incontinentia 339 Posted January 10, 2016 Thank you for the answers everyone. So just to check, these codes go in the script and do not require changes to the item initialisation? Or is this all within the initialisation? Apologies if this is a dim question, this is effectively day 1 of scripting for me! Edit: It bloody worked! Thank you all so much. In the end I used this in the sleep2.sqf: titleText ["You rested for 2 hours", "BLACK IN",7]; 2 remoteExec ["skipTime", 2, false]; Davidoss, R3vo and belbo, really appreciate your input. Share this post Link to post Share on other sites
Incontinentia 339 Posted January 10, 2016 skipTime has local effects only. By executing this command from an addaction the time will be reverted back to the server time after roughly 5 seconds (as explained here, at the bottom of the page). That way your script can't work without the help of some sort of remote execution by either BIS_fnc_MP or remoteExec. With BIS_fnc_MP I see no reason why it shouldn't work, presumed you deactivated whitelisting in CfgRemoteExec. Syntax would be: titleText ["You rested for 2 hours", "BLACK IN",7]; [[{ skipTime 2; }], "BIS_fnc_call"] call BIS_fnc_MP; Alternatively you could use remoteExec titleText ["You rested for 2 hours", "BLACK IN",7]; 2 remoteExec ["skipTime", 2, false]; Do you know if there's a way to put a random array in there? Say, skip a minimum of 2 hours and a maximum of 4? Share this post Link to post Share on other sites
Belbo 462 Posted January 10, 2016 Do you know if there's a way to put a random array in there? Say, skip a minimum of 2 hours and a maximum of 4? _sleptTime = 2+(round (random 2)); titleText [(format ["You rested for %1 hours",_sleptTime]), "BLACK IN",7]; _sleptTime remoteExec ["skipTime", 2, false]; Should work. 1 Share this post Link to post Share on other sites
Incontinentia 339 Posted January 11, 2016 _sleptTime = 2+(round (random 2)); titleText [(format ["You rested for %1 hours",_sleptTime]), "BLACK IN",7]; _sleptTime remoteExec ["skipTime", 2, false]; Should work. Thanks belbo Share this post Link to post Share on other sites
csk222 23 Posted January 11, 2016 Try a function and if you want you can add multiple options for the time: /* Author: Cobra [BOMSF] 1949-2014 [email protected] - www.bomsf.com You may re-use any of this work as long as you provide credit back to me. Contact [email protected] Edit By CSK222 Mission Time Change */ teg_fnc_1am = { private ["_text","_1","_msg"]; _text = "<t size='1'>" + "1 AM" + "<br />" + "<t size='1.5'>" + "Mission Time Change" + "</t>" + "<br />" + "<img size='4' image='images\bomsf_thor.paa'/>" + "<br />" + "</t>"; _1 =[_text,0.01,0.01,10,-1,0,90]spawn bis_fnc_dynamicText; _date = date; _date set [3,01]; //--- new hour (18) _date set [4,00]; //--- new minute (35) cuttext ["","black out"]; 1 fadesound 0; sleep 1; [[[_date], { setDate (_this select 0) }], "BIS_fnc_spawn"] call BIS_fnc_MP;; 2 fadesound 1; sleep 2; cuttext ["","black in"]; }; teg_fnc_1pm = { private ["_text","_1","_msg"]; _text = "<t size='1'>" + "1 PM" + "<br />" + "<t size='1.5'>" + "Mission Time Change" + "</t>" + "<br />" + "<img size='4' image='images\bomsf_thor.paa'/>" + "<br />" + "</t>"; _1 =[_text,0.01,0.01,10,-1,0,90]spawn bis_fnc_dynamicText; _date = date; _date set [3,13]; //--- new hour (18) _date set [4,00]; //--- new minute (35) cuttext ["","black out"]; 1 fadesound 0; sleep 1; [[[_date], { setDate (_this select 0) }], "BIS_fnc_spawn"] call BIS_fnc_MP;; 2 fadesound 1; sleep 2; cuttext ["","black in"]; }; teg_fnc_2am = { private ["_text","_1","_msg"]; _text = "<t size='1'>" + "2 AM" + "<br />" + "<t size='1.5'>" + "Mission Time Change" + "</t>" + "<br />" + "<img size='4' image='images\bomsf_thor.paa'/>" + "<br />" + "</t>"; _1 =[_text,0.01,0.01,10,-1,0,90]spawn bis_fnc_dynamicText; _date = date; _date set [3,02]; //--- new hour (18) _date set [4,00]; //--- new minute (35) cuttext ["","black out"]; 1 fadesound 0; sleep 1; [[[_date], { setDate (_this select 0) }], "BIS_fnc_spawn"] call BIS_fnc_MP;; 2 fadesound 1; sleep 2; cuttext ["","black in"]; }; teg_fnc_2pm = { private ["_text","_1","_msg"]; _text = "<t size='1'>" + "2 PM" + "<br />" + "<t size='1.5'>" + "Mission Time Change" + "</t>" + "<br />" + "<img size='4' image='images\bomsf_thor.paa'/>" + "<br />" + "</t>"; _1 =[_text,0.01,0.01,10,-1,0,90]spawn bis_fnc_dynamicText; _date = date; _date set [3,14]; //--- new hour (18) _date set [4,00]; //--- new minute (35) cuttext ["","black out"]; 1 fadesound 0; sleep 1; [[[_date], { setDate (_this select 0) }], "BIS_fnc_spawn"] call BIS_fnc_MP;; 2 fadesound 1; sleep 2; cuttext ["","black in"]; }; teg_fnc_3am = { private ["_text","_1","_msg"]; _text = "<t size='1'>" + "3 AM" + "<br />" + "<t size='1.5'>" + "Mission Time Change" + "</t>" + "<br />" + "<img size='4' image='images\bomsf_thor.paa'/>" + "<br />" + "</t>"; _1 =[_text,0.01,0.01,10,-1,0,90]spawn bis_fnc_dynamicText; _date = date; _date set [3,03]; //--- new hour (18) _date set [4,00]; //--- new minute (35) cuttext ["","black out"]; 1 fadesound 0; sleep 1; [[[_date], { setDate (_this select 0) }], "BIS_fnc_spawn"] call BIS_fnc_MP;; 2 fadesound 1; sleep 2; cuttext ["","black in"]; }; teg_fnc_3pm = { private ["_text","_1","_msg"]; _text = "<t size='1'>" + "3 PM" + "<br />" + "<t size='1.5'>" + "Mission Time Change" + "</t>" + "<br />" + "<img size='4' image='images\bomsf_thor.paa'/>" + "<br />" + "</t>"; _1 =[_text,0.01,0.01,10,-1,0,90]spawn bis_fnc_dynamicText; _date = date; _date set [3,15]; //--- new hour (18) _date set [4,00]; //--- new minute (35) cuttext ["","black out"]; 1 fadesound 0; sleep 1; [[[_date], { setDate (_this select 0) }], "BIS_fnc_spawn"] call BIS_fnc_MP;; 2 fadesound 1; sleep 2; cuttext ["","black in"]; }; teg_fnc_4am = { private ["_text","_1","_msg"]; _text = "<t size='1'>" + "4 AM" + "<br />" + "<t size='1.5'>" + "Mission Time Change" + "</t>" + "<br />" + "<img size='4' image='images\bomsf_thor.paa'/>" + "<br />" + "</t>"; _1 =[_text,0.01,0.01,10,-1,0,90]spawn bis_fnc_dynamicText; _date = date; _date set [3,04]; //--- new hour (18) _date set [4,00]; //--- new minute (35) cuttext ["","black out"]; 1 fadesound 0; sleep 1; [[[_date], { setDate (_this select 0) }], "BIS_fnc_spawn"] call BIS_fnc_MP;; 2 fadesound 1; sleep 2; cuttext ["","black in"]; }; teg_fnc_4pm = { private ["_text","_1","_msg"]; _text = "<t size='1'>" + "4 PM" + "<br />" + "<t size='1.5'>" + "Mission Time Change" + "</t>" + "<br />" + "<img size='4' image='images\bomsf_thor.paa'/>" + "<br />" + "</t>"; _1 =[_text,0.01,0.01,10,-1,0,90]spawn bis_fnc_dynamicText; _date = date; _date set [3,16]; //--- new hour (18) _date set [4,00]; //--- new minute (35) cuttext ["","black out"]; 1 fadesound 0; sleep 1; [[[_date], { setDate (_this select 0) }], "BIS_fnc_spawn"] call BIS_fnc_MP;; 2 fadesound 1; sleep 2; cuttext ["","black in"]; }; teg_fnc_5am = { private ["_text","_1","_msg"]; _text = "<t size='1'>" + "5 AM" + "<br />" + "<t size='1.5'>" + "Mission Time Change" + "</t>" + "<br />" + "<img size='4' image='images\bomsf_thor.paa'/>" + "<br />" + "</t>"; _1 =[_text,0.01,0.01,10,-1,0,90]spawn bis_fnc_dynamicText; _date = date; _date set [3,05]; //--- new hour (18) _date set [4,00]; //--- new minute (35) cuttext ["","black out"]; 1 fadesound 0; sleep 1; [[[_date], { setDate (_this select 0) }], "BIS_fnc_spawn"] call BIS_fnc_MP;; 2 fadesound 1; sleep 2; cuttext ["","black in"]; }; teg_fnc_5pm = { private ["_text","_1","_msg"]; _text = "<t size='1'>" + "5 PM" + "<br />" + "<t size='1.5'>" + "Mission Time Change" + "</t>" + "<br />" + "<img size='4' image='images\bomsf_thor.paa'/>" + "<br />" + "</t>"; _1 =[_text,0.01,0.01,10,-1,0,90]spawn bis_fnc_dynamicText; _date = date; _date set [3,17]; //--- new hour (18) _date set [4,00]; //--- new minute (35) cuttext ["","black out"]; 1 fadesound 0; sleep 1; [[[_date], { setDate (_this select 0) }], "BIS_fnc_spawn"] call BIS_fnc_MP;; 2 fadesound 1; sleep 2; cuttext ["","black in"]; }; teg_fnc_6am = { private ["_text","_1","_msg"]; _text = "<t size='1'>" + "6 AM" + "<br />" + "<t size='1.5'>" + "Mission Time Change" + "</t>" + "<br />" + "<img size='4' image='images\bomsf_thor.paa'/>" + "<br />" + "</t>"; _1 =[_text,0.01,0.01,10,-1,0,90]spawn bis_fnc_dynamicText; _date = date; _date set [3,06]; //--- new hour (18) _date set [4,00]; //--- new minute (35) cuttext ["","black out"]; 1 fadesound 0; sleep 1; [[[_date], { setDate (_this select 0) }], "BIS_fnc_spawn"] call BIS_fnc_MP;; 2 fadesound 1; sleep 2; cuttext ["","black in"]; }; teg_fnc_6pm = { private ["_text","_1","_msg"]; _text = "<t size='1'>" + "6 PM" + "<br />" + "<t size='1.5'>" + "Mission Time Change" + "</t>" + "<br />" + "<img size='4' image='images\bomsf_thor.paa'/>" + "<br />" + "</t>"; _1 =[_text,0.01,0.01,10,-1,0,90]spawn bis_fnc_dynamicText; _date = date; _date set [3,18]; //--- new hour (18) _date set [4,00]; //--- new minute (35) cuttext ["","black out"]; 1 fadesound 0; sleep 1; [[[_date], { setDate (_this select 0) }], "BIS_fnc_spawn"] call BIS_fnc_MP;; 2 fadesound 1; sleep 2; cuttext ["","black in"]; }; teg_fnc_7am = { private ["_text","_1","_msg"]; _text = "<t size='1'>" + "7 AM" + "<br />" + "<t size='1.5'>" + "Mission Time Change" + "</t>" + "<br />" + "<img size='4' image='images\bomsf_thor.paa'/>" + "<br />" + "</t>"; _1 =[_text,0.01,0.01,10,-1,0,90]spawn bis_fnc_dynamicText; _date = date; _date set [3,07]; //--- new hour (18) _date set [4,00]; //--- new minute (35) cuttext ["","black out"]; 1 fadesound 0; sleep 1; [[[_date], { setDate (_this select 0) }], "BIS_fnc_spawn"] call BIS_fnc_MP;; 2 fadesound 1; sleep 2; cuttext ["","black in"]; }; teg_fnc_7pm = { private ["_text","_1","_msg"]; _text = "<t size='1'>" + "7 PM" + "<br />" + "<t size='1.5'>" + "Mission Time Change" + "</t>" + "<br />" + "<img size='4' image='images\bomsf_thor.paa'/>" + "<br />" + "</t>"; _1 =[_text,0.01,0.01,10,-1,0,90]spawn bis_fnc_dynamicText; _date = date; _date set [3,19]; //--- new hour (18) _date set [4,00]; //--- new minute (35) cuttext ["","black out"]; 1 fadesound 0; sleep 1; [[[_date], { setDate (_this select 0) }], "BIS_fnc_spawn"] call BIS_fnc_MP;; 2 fadesound 1; sleep 2; cuttext ["","black in"]; }; teg_fnc_8am = { private ["_text","_1","_msg"]; _text = "<t size='1'>" + "8 AM" + "<br />" + "<t size='1.5'>" + "Mission Time Change" + "</t>" + "<br />" + "<img size='4' image='images\bomsf_thor.paa'/>" + "<br />" + "</t>"; _1 =[_text,0.01,0.01,10,-1,0,90]spawn bis_fnc_dynamicText; _date = date; _date set [3,08]; //--- new hour (18) _date set [4,00]; //--- new minute (35) cuttext ["","black out"]; 1 fadesound 0; sleep 1; [[[_date], { setDate (_this select 0) }], "BIS_fnc_spawn"] call BIS_fnc_MP;; 2 fadesound 1; sleep 2; cuttext ["","black in"]; }; teg_fnc_8pm = { private ["_text","_1","_msg"]; _text = "<t size='1'>" + "8 PM" + "<br />" + "<t size='1.5'>" + "Mission Time Change" + "</t>" + "<br />" + "<img size='4' image='images\bomsf_thor.paa'/>" + "<br />" + "</t>"; _1 =[_text,0.01,0.01,10,-1,0,90]spawn bis_fnc_dynamicText; _date = date; _date set [3,20]; //--- new hour (18) _date set [4,00]; //--- new minute (35) cuttext ["","black out"]; 1 fadesound 0; sleep 1; [[[_date], { setDate (_this select 0) }], "BIS_fnc_spawn"] call BIS_fnc_MP;; 2 fadesound 1; sleep 2; cuttext ["","black in"]; }; teg_fnc_9am = { private ["_text","_1","_msg"]; _text = "<t size='1'>" + "9 AM" + "<br />" + "<t size='1.5'>" + "Mission Time Change" + "</t>" + "<br />" + "<img size='4' image='images\bomsf_thor.paa'/>" + "<br />" + "</t>"; _1 =[_text,0.01,0.01,10,-1,0,90]spawn bis_fnc_dynamicText; _date = date; _date set [3,09]; //--- new hour (18) _date set [4,00]; //--- new minute (35) cuttext ["","black out"]; 1 fadesound 0; sleep 1; [[[_date], { setDate (_this select 0) }], "BIS_fnc_spawn"] call BIS_fnc_MP;; 2 fadesound 1; sleep 2; cuttext ["","black in"]; }; teg_fnc_9pm = { private ["_text","_1","_msg"]; _text = "<t size='1'>" + "9 PM" + "<br />" + "<t size='1.5'>" + "Mission Time Change" + "</t>" + "<br />" + "<img size='4' image='images\bomsf_thor.paa'/>" + "<br />" + "</t>"; _1 =[_text,0.01,0.01,10,-1,0,90]spawn bis_fnc_dynamicText; _date = date; _date set [3,21]; //--- new hour (18) _date set [4,00]; //--- new minute (35) cuttext ["","black out"]; 1 fadesound 0; sleep 1; [[[_date], { setDate (_this select 0) }], "BIS_fnc_spawn"] call BIS_fnc_MP;; 2 fadesound 1; sleep 2; cuttext ["","black in"]; }; teg_fnc_10am = { private ["_text","_1","_msg"]; _text = "<t size='1'>" + "10 AM" + "<br />" + "<t size='1.5'>" + "Mission Time Change" + "</t>" + "<br />" + "<img size='4' image='images\bomsf_thor.paa'/>" + "<br />" + "</t>"; _1 =[_text,0.01,0.01,10,-1,0,90]spawn bis_fnc_dynamicText; _date = date; _date set [3,10]; //--- new hour (18) _date set [4,00]; //--- new minute (35) cuttext ["","black out"]; 1 fadesound 0; sleep 1; [[[_date], { setDate (_this select 0) }], "BIS_fnc_spawn"] call BIS_fnc_MP;; 2 fadesound 1; sleep 2; cuttext ["","black in"]; }; teg_fnc_10pm = { private ["_text","_1","_msg"]; _text = "<t size='1'>" + "10 PM" + "<br />" + "<t size='1.5'>" + "Mission Time Change" + "</t>" + "<br />" + "<img size='4' image='images\bomsf_thor.paa'/>" + "<br />" + "</t>"; _1 =[_text,0.01,0.01,10,-1,0,90]spawn bis_fnc_dynamicText; _date = date; _date set [3,22]; //--- new hour (18) _date set [4,00]; //--- new minute (35) cuttext ["","black out"]; 1 fadesound 0; sleep 1; [[[_date], { setDate (_this select 0) }], "BIS_fnc_spawn"] call BIS_fnc_MP;; 2 fadesound 1; sleep 2; cuttext ["","black in"]; }; teg_fnc_11am = { private ["_text","_1","_msg"]; _text = "<t size='1'>" + "11 AM" + "<br />" + "<t size='1.5'>" + "Mission Time Change" + "</t>" + "<br />" + "<img size='4' image='images\bomsf_thor.paa'/>" + "<br />" + "</t>"; _1 =[_text,0.01,0.01,10,-1,0,90]spawn bis_fnc_dynamicText; _date = date; _date set [3,11]; //--- new hour (18) _date set [4,00]; //--- new minute (35) cuttext ["","black out"]; 1 fadesound 0; sleep 1; [[[_date], { setDate (_this select 0) }], "BIS_fnc_spawn"] call BIS_fnc_MP;; 2 fadesound 1; sleep 2; cuttext ["","black in"]; }; teg_fnc_11pm = { private ["_text","_1","_msg"]; _text = "<t size='1'>" + "11 PM" + "<br />" + "<t size='1.5'>" + "Mission Time Change" + "</t>" + "<br />" + "<img size='4' image='images\bomsf_thor.paa'/>" + "<br />" + "</t>"; _1 =[_text,0.01,0.01,10,-1,0,90]spawn bis_fnc_dynamicText; _date = date; _date set [3,23]; //--- new hour (18) _date set [4,00]; //--- new minute (35) cuttext ["","black out"]; 1 fadesound 0; sleep 1; [[[_date], { setDate (_this select 0) }], "BIS_fnc_spawn"] call BIS_fnc_MP;; 2 fadesound 1; sleep 2; cuttext ["","black in"]; }; teg_fnc_12am = { private ["_text","_1","_msg"]; _text = "<t size='1'>" + "12 AM" + "<br />" + "<t size='1.5'>" + "Mission Time Change" + "</t>" + "<br />" + "<img size='4' image='images\bomsf_thor.paa'/>" + "<br />" + "</t>"; _1 =[_text,0.01,0.01,10,-1,0,90]spawn bis_fnc_dynamicText; _date = date; _date set [3,00]; //--- new hour (18) _date set [4,00]; //--- new minute (35) cuttext ["","black out"]; 1 fadesound 0; sleep 1; [[[_date], { setDate (_this select 0) }], "BIS_fnc_spawn"] call BIS_fnc_MP;; 2 fadesound 1; sleep 2; cuttext ["","black in"]; }; teg_fnc_12pm = { private ["_text","_1","_msg"]; _text = "<t size='1'>" + "12 PM" + "<br />" + "<t size='1.5'>" + "Mission Time Change" + "</t>" + "<br />" + "<img size='4' image='images\bomsf_thor.paa'/>" + "<br />" + "</t>"; _1 =[_text,0.01,0.01,10,-1,0,90]spawn bis_fnc_dynamicText; _date = date; _date set [3,12]; //--- new hour (18) _date set [4,00]; //--- new minute (35) cuttext ["","black out"]; 1 fadesound 0; sleep 1; [[[_date], { setDate (_this select 0) }], "BIS_fnc_spawn"] call BIS_fnc_MP;; 2 fadesound 1; sleep 2; cuttext ["","black in"]; }; We call each function from a custom in game tablet: (1 AM Example) in the "action =" you see the function being called class btnD6: mop_RscButton { idc = 6; action = "closeDialog 0;[[],'teg_fnc_1am',true,true] call BIS_fnc_MP;"; text = "0100 (1 AM)"; //--- ToDo: Localize; tooltip = ""; //--- ToDo: Localize; x = 0.3; y = 0.01; w = 0.19; h = 0.05; }; Here's an example: https://youtu.be/4et3TI8K4sk?t=59s This is just an example of what we do. I don't know if you can call a function from an addaction. Someone more advanced can chime in on that. 1 Share this post Link to post Share on other sites
Incontinentia 339 Posted January 11, 2016 Bloody hell, that's incredible, thanks! I'll give it a whirl once I've got my head around it all. Thanks for chiming in. Share this post Link to post Share on other sites