dlegion 98 Posted April 8, 2017 hi all ! i wish to have a sort of "on screen constant scoreboard", that constantly displays a variable (in my case lets name it: "_Gcredits") i really have no idea how do this, any help will be appreciated, thanks guys ! ( i need it works on dedicated server, JIP and respawn) Share this post Link to post Share on other sites
BlacKnightBK 47 Posted April 8, 2017 Just now, dlegion said: hi all ! i wish to have a sort of "on screen constant scoreboard", that constantly displays a variable (in my case lets name it: "_Gcredits") i really have no idea how do this, any help will be appreciated, thanks guys ! ( i need it works on dedicated server, JIP and respawn) Check out tutorials on how to create a GUI. Or you can do it using a hint that stays in loop to make sure it stays on screen. Cheers Share this post Link to post Share on other sites
Nikander 123 Posted April 8, 2017 Hello @dlegion, maybe you're looking for something like this missionNamespace setVariable ["Gcredits", 0, true]; with uiNamespace do { [] spawn { waitUntil {!isNull findDisplay 46}; disableSerialization; _ctrl = findDisplay 46 ctrlCreate ["RscStructuredText", -1]; _ctrl ctrlSetPosition [safeZoneX, safeZoneY + safeZoneH * 0.5, safeZoneW, safeZoneH * 0.04]; _ctrl ctrlCommit 0; while {true} do { _ctrl ctrlSetStructuredText parseText format[ "<t color='#8f8f8f' align='center' size='0.7'> Score:%1</t>", Gcredits ]; }; }; }; I hope this helps 1 Share this post Link to post Share on other sites
dlegion 98 Posted April 9, 2017 probably yeah! where i have to put this code ? thanks man !! EDIT: i tried adding it to "init.sqf" and then on "onPlayerRespawn.sqf", and i tried to define my variable with : Gcredits = Garsenal getVariable "R3F_LOG_CF_credits"; but still dont work, it gives an error about "undefined Gcredits". and i see a message: "score any" at aiming poin in center of screen. any way to move the display in the upper-right corner ? thanks!! Share this post Link to post Share on other sites
Lucullus 71 Posted April 9, 2017 Your variable "Gcredits" is in missionNamespace not uiNamespace. ask your variable with > missionNamespace getVariable "Gcredits" <. Move your #control with ctrlSetPosition Share this post Link to post Share on other sites
dlegion 98 Posted April 9, 2017 i'm sorry...but i dont understand where to put :( Share this post Link to post Share on other sites
BlacKnightBK 47 Posted April 9, 2017 @Nikander Dude, what does he do with the script you gave him?? Neither of us knows :( Share this post Link to post Share on other sites
Lucullus 71 Posted April 9, 2017 Its player-based and resistent, so put it in "initPlayerLocal.sqf". Share this post Link to post Share on other sites
dlegion 98 Posted April 9, 2017 setvariable....set the variable or am i wrong ? i need to read a variable, display on screen constantly, and when this variable changes, update the display! Share this post Link to post Share on other sites
Lucullus 71 Posted April 9, 2017 8 hours ago, dlegion said: Gcredits = Garsenal getVariable "R3F_LOG_CF_credits"; Variable is global, so its in your missionNamespace. 21 hours ago, Nikander said: with uiNamespace do {... The script is running in uiNamespace, so "Gcredits" is unknown. change this 21 hours ago, Nikander said: while {true} do { _ctrl ctrlSetStructuredText parseText format[ "<t color='#8f8f8f' align='center' size='0.7'> Score:%1</t>", Gcredits ]; }; to 21 hours ago, Nikander said: while {true} do { _ctrl ctrlSetStructuredText parseText format[ "<t color='#8f8f8f' align='center' size='0.7'> Score:%1</t>", missionNamespace getVariable "Gcredits" ]; }; and it works 1 Share this post Link to post Share on other sites
Nikander 123 Posted April 10, 2017 22 hours ago, BlacKnightBK said: @Nikander Dude, what does he do with the script you gave him?? Neither of us knows :( Hello @BlacKnightBK, i'm not a clairvoyant but I recommed writing missionNamespace setVariable ["Gcredits", 0, true] in initServer.sqf if the variable is not player-based or missionNamespace setVariable ["Gcredits", 0], in initPlayerLocal.sqf if it is player-based or single-player. Insert the rest , as corrected by Lucullus, in initPlayerLocal.sqf if nothing else comes to mind. Share this post Link to post Share on other sites
dlegion 98 Posted April 10, 2017 ok...if i understand correctly: initServer.sqf :missionNamespace setVariable ["Gcredits", 0, true] ; initPlayerLocal.sqf : missionNamespace setVariable ["Gcredits", 0, true]; with uiNamespace do { [] spawn { waitUntil {!isNull findDisplay 46}; disableSerialization; _ctrl = findDisplay 46 ctrlCreate ["RscStructuredText", -1]; _ctrl ctrlSetPosition [safeZoneX, safeZoneY + safeZoneH * 0.5, safeZoneW, safeZoneH * 0.04]; _ctrl ctrlCommit 0; while {true} do { _ctrl ctrlSetStructuredText parseText format[ "<t color='#8f8f8f' align='center' size='0.7'> Score:%1</t>", missionNamespace getVariable "Gcredits" ]; }; }; }; is it correct? if not...i beg you, can you write the code please ? thanks guys !! 1 Share this post Link to post Share on other sites
dlegion 98 Posted April 10, 2017 maybe i'm doing something wrong, but sadly it display a "score 0" message in the middle of screen :( i wish to have it displayed in the upper right corner of screen (or at least in a corner) and display the actual value of my variable (was not set at 0 and will change during game) Share this post Link to post Share on other sites
Lucullus 71 Posted April 11, 2017 On 9.4.2017 at 0:17 PM, Lucullus said: Move your #control with ctrlSetPosition On 8.4.2017 at 7:06 PM, Nikander said: _ctrl ctrlSetPosition [safeZoneX, safeZoneY + safeZoneH * 0.5, safeZoneW, safeZoneH * 0.04]; Move your #control whereever you want. Try and learn is better as ask for finished scripts. 1 Share this post Link to post Share on other sites
pierremgi 4889 Posted April 11, 2017 Just to help at little bit, all the screens are scaled by safeZone (more here) from 0 to 1, from upper left corner to lower right corner, regardless of dimension or ratio. so, a display (control) will start at the middle of the screen with _ctrl ctrlSetPosition [x, y, w, h] format. The coordinate system seems to be hard, but test the 4 and 5 samples in my link. If you want your variable updated with a whatever score, you need to make it "alive" by some script (for example, Gcredits= Gcredits + 1 for some condition). As you can see Gcredits here, is a global variable, not a local one as _Gcredits could be. Remark: the syntax: missionNamespace setVariable ["Gcredits", 0, true]; is the same as: Gcredit = 0, publicVariable "Gcredit"; missionNameSpace is the space (variable recipient/context) by default. It makes sense to precise it when called from another name space (like UI). So, the good question is: what is Gcredits? A personal score for a player >> you don't want to publicVariable it on each screens; or a global variable, common and readable for everyboby >> you have to publicVariable it (or add true as 3rd argument of setVariable). 1 Share this post Link to post Share on other sites
dlegion 98 Posted April 11, 2017 thanks man ! that help me understand !! actually Gcredits is a global variable for a (side, G is for GUER side) factory, that has credits added at every "round win" by its side. i already update it in another script called by a trigger, and when you open the factoary you already see how many credits are left, but i wished to have them constantly displayed (and updated at least at every round win), so players can have an idea of credits of theyr faction and enemy faction at any given moment (i have also a Bcredits for BLUE side). i'm sorry, i really do my best to learn, but i work 9-10 hours a day and have also other real life problems, and invest the few time left in learning this would mean finish a simple script in 2020...and i've already edited many others like R3F_LOG, SMS explosives and Zorylias 3D explosives and many others...its a too time consuming task :( thanks for your understanding guys ! 1 Share this post Link to post Share on other sites