daskunk 1 Posted August 20, 2013 (edited) I have a timer script which i got from the forums here END_TIME = 3600; //When mission should end in seconds. if (isServer) then { [] spawn { ELAPSED_TIME = 0; START_TIME = diag_tickTime; while {ELAPSED_TIME < END_TIME} do { ELAPSED_TIME = diag_tickTime - START_TIME; publicVariable "ELAPSED_TIME"; sleep 1; }; }; }; if!(isDedicated) then { [] spawn { while{ELAPSED_TIME < END_TIME } do { _time = END_TIME - ELAPSED_TIME; _finish_time_minutes = floor(_time / 60); _finish_time_seconds = floor(_time) - (60 * _finish_time_minutes); if(_finish_time_seconds < 10) then { _finish_time_seconds = format ["0%1", _finish_time_seconds]; }; if(_finish_time_minutes < 10) then { _finish_time_minutes = format ["0%1", _finish_time_minutes]; }; _formatted_time = format ["%1:%2", _finish_time_minutes, _finish_time_seconds]; hintSilent format ["Time left:\n%1", _formatted_time]; sleep 1; }; }; }; This uses the hint dialog which is in the way as I am also using the sectors capture module which displays behind it. i have read the tutorial that Iceman made for making GUI interfaces but im stumped as to how i can add the code for displaying the timer in the frame I have made. //////////////////////////////////////////////////////// // GUI EDITOR OUTPUT START (by -1PARA-DaSkunk, v1.062, #Naluhe) //////////////////////////////////////////////////////// class SK_Frame: RscFrame { idc = 1800; text = "This is the timer"; //--- ToDo: Localize; x = 0.479373 * safezoneW + safezoneX; y = 0.269085 * safezoneH + safezoneY; w = 0.0515678 * safezoneW; h = 0.0219919 * safezoneH; }; //////////////////////////////////////////////////////// // GUI EDITOR OUTPUT END //////////////////////////////////////////////////////// Can someone please help me understand the process of adding the code i need to this frame to display the timer. Skunk Edited August 20, 2013 by DaSkunk typo Share this post Link to post Share on other sites
mindstorm 8 Posted August 20, 2013 (edited) in description.ext: #include "myFile.hpp" myFile.hpp: class RscFrame //Base class for reference { type = 0; idc = -1; style = 64; shadow = 2; colorBackground[] = {0,0,0,0}; colorText[] = {1,1,1,1}; font = "Zeppelin32"; sizeEx = 0.02; text = ""; } //rscTitles is needed if you want to create permantvisible displays (So everything that isn't a dialog). class rscTitles { class myTimerClass { idd = 1800; name = "Timer"; movingEnable = false; enableSimulation = true; onLoad = "uiNamespace setVariable ['myTimerDiag', _this select 0];"; onUnLoad = "uiNamespace setVariable ['myTimerDiag', nil]"; class controls { class SK_Frame: RscFrame { idc = 1801; text = "This is the timer"; //--- ToDo: Localize; x = 0.479373 * safezoneW + safezoneX; y = 0.269085 * safezoneH + safezoneY; w = 0.0515678 * safezoneW; h = 0.0219919 * safezoneH; }; }; }; }; Then from your script: disableSerialization; 20000 cutRsc ["myTimerClass","PLAIN"]; _myTimerGui = uiNamespace getVariable "myTimerDiag"; _timer = _uiObj displayCtrl 1801; //then use this line in your loop _timer ctrlSetText "1"; The 20.000 in front of cutRsc is a custom recourse layers. This way if you fade-out or go spectate or whatever your dialog isn't removed. Edited August 20, 2013 by mindstorm Share this post Link to post Share on other sites
daskunk 1 Posted August 20, 2013 Thanks very much for your reply mindstorm. Could you explain a little more about the lower script PHP code where do I put this, does this go where my timer script is ? which is in my init atm :) sorry I am very raw when it comes to scripting I am trying to learn.. Also I have rsc titles already defined in there for both INS Revive & =BTC=Logistics. skunk Share this post Link to post Share on other sites
mindstorm 8 Posted August 20, 2013 If it's already defined just add the class myTimerClass to it. //This line needs to be added if you do gue magic in scripts. disableSerialization; //This "displays" the display/gui thingy. It basically adds it to the current display. 20000 cutRsc ["myTimerClass","PLAIN"]; //Here you retrieve the display from the uiNamespace. The onload && onunload make sure it's added to the uiNamespace _myTimerGui = uiNamespace getVariable "myTimerDiag"; //Here you specificly select the text control of your display. (A display can have more controls, like text or a image or both). _timer = _uiObj displayCtrl 1801; //Then you change the text of the specific display control _timer ctrlSetText "1"; So you probably want something like this: if!(isDedicated) then { [] spawn { disableSerialization; 20000 cutRsc ["myTimerClass","PLAIN"]; _myTimerGui = uiNamespace getVariable "myTimerDiag"; _timer = _uiObj displayCtrl 1801; while{ELAPSED_TIME < END_TIME } do { _time = END_TIME - ELAPSED_TIME; _finish_time_minutes = floor(_time / 60); _finish_time_seconds = floor(_time) - (60 * _finish_time_minutes); if(_finish_time_seconds < 10) then { _finish_time_seconds = format ["0%1", _finish_time_seconds]; }; if(_finish_time_minutes < 10) then { _finish_time_minutes = format ["0%1", _finish_time_minutes]; }; _formatted_time = format ["%1:%2", _finish_time_minutes, _finish_time_seconds]; _timer ctrlSetText _formatted_time; sleep 1; }; }; }; Share this post Link to post Share on other sites
daskunk 1 Posted August 20, 2013 Well it came up with lods of errors :) And I am now about as much use as a 1 legged man in an arse kicking contest at unravelling the issue hahahaha. Would it be possible for me to send you my mission for you to take a look. ? I will undo what I have done. Share this post Link to post Share on other sites
mindstorm 8 Posted August 20, 2013 Well it came up with lods of errors :)And I am now about as much use as a 1 legged man in an arse kicking contest at unravelling the issue hahahaha. Would it be possible for me to send you my mission for you to take a look. ? I will undo what I have done. sure just pm me a link. Share this post Link to post Share on other sites
daskunk 1 Posted August 21, 2013 get this error m8 on loadup no timer showing :) Warning Message: No entry 'mpmissions\__cur_mp.Stratis\description.ext/RscTitles/myTimerClass.duration'. Warning Message: '/' is not a value Share this post Link to post Share on other sites
mindstorm 8 Posted August 21, 2013 Yeah I can't really test my stuff so some errors you might need to fix. Forgot the fadein, fadeout and duration. class RscTitles { //// Respawn Script - Start //// #include "INS_revive\rsctitles.hpp" #include "=BTC=_Logistic\=BTC=_Lift\=BTC=_Hud.h" //// Respawn Script - End //// class myTimerClass { idd = 1800; name = "Timer"; movingEnable = false; enableSimulation = true; onLoad = "uiNamespace setVariable ['myTimerDiag', _this select 0];"; onUnLoad = "uiNamespace setVariable ['myTimerDiag', nil]"; duration = 9999999; fadeIn = 0; fadeOut = 0; class controls { class SK_Frame: RscFrame { idc = 1801; text = "This is the timer"; //--- ToDo: Localize; x = 0.479373 * safezoneW + safezoneX; y = 0.269085 * safezoneH + safezoneY; w = 0.0515678 * safezoneW; h = 0.0219919 * safezoneH; }; }; }; }; Share this post Link to post Share on other sites
daskunk 1 Posted August 21, 2013 mindstorm your a saint m8. It works :) I'm very grateful for you taking the time to help me. I have no idea how it works, would it be possible for you to explain what is happening here please. Also the frame is not exactly what i need now i can see it working so i had another go in the GUI editor and just made A text only version. //////////////////////////////////////////////////////// // GUI EDITOR OUTPUT START (by -1PARA-DaSkunk, v1.062, #Vytiha) //////////////////////////////////////////////////////// class RscText_1000: RscText { idc = 1000; x = 0.512166; y = 0.0622896; w = 0.1; h = 0.1; }; class SK_Timer: RscText { idc = 1001; text = "timertexthere"; //--- ToDo: Localize; x = 18 * GUI_GRID_W + GUI_GRID_X; y = 1 * GUI_GRID_H + GUI_GRID_Y; w = 4 * GUI_GRID_W; h = 2.5 * GUI_GRID_H; sizeEx = +1 * GUI_GRID_H; }; //////////////////////////////////////////////////////// // GUI EDITOR OUTPUT END //////////////////////////////////////////////////////// I think i see what I would need to change in the code that works Would it be possible for you to explain how it works using this variant. ---------- Post added at 16:04 ---------- Previous post was at 15:09 ---------- lol after about 30 crashes i have managed to get back into my map after trying to edit hahahahahaa All I have now is an outlined box :) ---------- Post added at 16:11 ---------- Previous post was at 16:04 ---------- class RscText //Base class for reference { type = 0; idc = -1; style = 64; shadow = 2; colorBackground[] = {0,0,0,0}; colorText[] = {1,1,1,1}; font = "PuristaMedium"; //Typeface sizeEx = +1; }; class RscTitles { //// Respawn Script - Start //// #include "INS_revive\rsctitles.hpp" #include "=BTC=_Logistic\=BTC=_Lift\=BTC=_Hud.h" //// Respawn Script - End //// class SK_TimerClass { idd = 1800; name = "Timer"; movingEnable = false; enableSimulation = true; onLoad = "uiNamespace setVariable ['SK_TimerDiag', _this select 0];"; onUnLoad = "uiNamespace setVariable ['SK_TimerDiag', nil]"; duration = 9999999; fadeIn = 0; fadeOut = 0; class controls { class SK_Timer: RscText { idc = 1001; text = "timertexthere"; //--- ToDo: Localize; x = 18 * GUI_GRID_W + GUI_GRID_X; y = 1 * GUI_GRID_H + GUI_GRID_Y; w = 4 * GUI_GRID_W; h = 2.5 * GUI_GRID_H; sizeEx = +1 * GUI_GRID_H; }; }; }; }; This is my description.ext code if!(isDedicated) then { [] spawn { disableSerialization; 20000 cutRsc ["SK_TimerClass","PLAIN"]; _SK_TimerGui = uiNamespace getVariable "SK_TimerDiag"; _timer = _SK_TimerGui displayCtrl 1801; while{ELAPSED_TIME < END_TIME } do { _time = END_TIME - ELAPSED_TIME; _finish_time_minutes = floor(_time / 60); _finish_time_seconds = floor(_time) - (60 * _finish_time_minutes); if(_finish_time_seconds < 10) then { _finish_time_seconds = format ["0%1", _finish_time_seconds]; }; if(_finish_time_minutes < 10) then { _finish_time_minutes = format ["0%1", _finish_time_minutes]; }; _formatted_time = format ["%1:%2", _finish_time_minutes, _finish_time_seconds]; //hintSilent format ["Time left:\n%1", _formatted_time]; _timer ctrlSetText _formatted_time; sleep 1; }; }; }; init.sqf code Share this post Link to post Share on other sites
tonic-_- 53 Posted August 21, 2013 If you want just text you can use this: class RscText { x = 0; y = 0; h = 0.037; w = 0.3; type = 0; style = 0; shadow = 1; colorShadow[] = {0, 0, 0, 0.5}; font = "PuristaMedium"; SizeEx = "( ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1)"; text = ""; colorText[] = {1, 1, 1, 1}; colorBackground[] = {0, 0, 0, 0}; linespacing = 1; }; Share this post Link to post Share on other sites
daskunk 1 Posted August 21, 2013 ok sorry man but where do i put this in conjuction with everything else i have :) My heads spinning hahahahaha Share this post Link to post Share on other sites
tonic-_- 53 Posted August 21, 2013 (edited) Basically the code that you have in your Description where you are defining RscText you would replace it with what I sent you. Dialog controls are defined by the Description.ext that is basically the only place outside of mods that controls / resources for gui's can be defined. Obviously with systems like VAS people put most of their resources in a different file and call it via Description.ext But it's good to see that i'm not the only one plagued with crashing all the time. Good ol' Description.ext..... Mess it up and you'll be restarting :P course I do all mine from scratch. Here is another tip if you're getting into GUI's, don't define the same thing twice or you'll crash. You can only define something once, so if you are building something that can be used outside of the mission you are working on always use tag's with your resources / controls that you are defining so that they don't interfere with another persons work that also may be defined as the same thing. Edited August 21, 2013 by Tonic-_- Share this post Link to post Share on other sites
daskunk 1 Posted August 21, 2013 ok were getting close now its displaying TimerText on the screen hahahahaha :) Share this post Link to post Share on other sites
Casio91Fin 31 Posted November 7, 2018 @mindstorm Hi, is this possible also to make hours? Share this post Link to post Share on other sites
HazJ 1288 Posted November 9, 2018 On 11/7/2018 at 7:24 AM, Casio91Fin said: @mindstorm Hi, is this possible also to make hours? See: https://community.bistudio.com/wiki/BIS_fnc_secondsToString Share this post Link to post Share on other sites
Casio91Fin 31 Posted November 9, 2018 @HazJ This would be a model script, because it is CTF. It is quite good but not suitable for this this time. mainly I wonder how to get the hours visible. END_TIME = timelimit; //When mission should end in seconds. ELAPSED_TIME = 0; if (isServer) then { [] spawn { START_TIME = diag_tickTime; while {ELAPSED_TIME < END_TIME} do { ELAPSED_TIME = diag_tickTime - START_TIME; publicVariable "ELAPSED_TIME"; sleep 1; }; }; }; if!(isDedicated) then { [] spawn { while{ELAPSED_TIME < END_TIME} do { _time = END_TIME - ELAPSED_TIME; _finish_time_minutes = floor(_time / 60); _finish_time_seconds = floor(_time) - (60 * _finish_time_minutes); if(_finish_time_seconds < 10) then { _finish_time_seconds = format ["0%1", _finish_time_seconds]; }; if(_finish_time_minutes < 10) then { _finish_time_minutes = format ["0%1", _finish_time_minutes]; }; formatted_time = format ["%1:%2", _finish_time_minutes, _finish_time_seconds]; publicVariable "formatted_time"; sleep 1; }; }; }; Share this post Link to post Share on other sites
Larrow 2800 Posted November 9, 2018 15 hours ago, Casio91Fin said: mainly I wonder how to get the hours visible. As @HazJ already said use BIS_fnc_secondsToString //init.sqf if ( isServer ) then { _timelimit = 2 * 60 * 60; //When mission should end in seconds ( 2 hours ) estimatedTimeLeft _timelimit; _nul = [] spawn { //Wait for estimated time to be updated waitUntil { estimatedEndServerTime > 0 }; //Wait for mission end time waitUntil{ estimatedEndServerTime - serverTime <= 0 }; //End mission globally, server and clients [ "End1" ] call BIS_fnc_endMissionServer; }; }; //Clients and Hosted if ( hasInterface ) then { disableSerialization; //Wait for mission to start waitUntil{ time > 0 }; //Create text control _ctrl = call BIS_fnc_displayMission ctrlCreate [ "RscText", 10001 ]; //Set controls position ( top center ) _ctrl ctrlSetPosition[ (( safeZoneX + ( safeZoneW / 2 )) - ( pixelW * pixelGridNoUIScale * 4 )), ( safeZoneY + ( pixelH * pixelGridNoUIScale * 1 )), ( pixelW * pixelGridNoUIScale * 8 ), ( pixelH * pixelGridNoUIScale * 1 ) ]; //Set controls text height _ctrl ctrlSetFontHeight ( pixelH * pixelGridNoUIScale * 1 ); //Apply control changes _ctrl ctrlCommit 0; _nul = [ _ctrl ] spawn { params[ "_ctrl" ]; //Wait for estimated time to be updated waitUntil { estimatedEndServerTime > 0 }; while { serverTime <= estimatedEndServerTime } do { _timeLeft = [ estimatedEndServerTime - serverTime, "HH:MM:SS" ] call BIS_fnc_secondsToString; _ctrl ctrlSetText format[ "Time Remaining %1", _timeLeft ]; uiSleep 1; }; }; }; 1 Share this post Link to post Share on other sites