Smart Games 76 Posted August 4, 2019 I´m trying to show the players [x,y,z] with an Ui. The problem? CtrlSetText doesn´t work! init.sqf: [] execVM "Gui\gui_functions.sqf"; cutRsc ["gui1","plain"]; description.ext: class RscTitles { #include "Gui\Gui1\Gui1.hpp" }; gui_functions.sqf: fnc_pos = { while {true} do { sleep 0.5; _display = findDisplay 123; _child = _display displayCtrl 10000; _child ctrlSetText format ["%1", getpos player]; }; }; Gui1.hpp: #include "CustomControlClasses.hpp" class Gui1 { idd = 12345; duration = 999999; class ControlsBackground { class Background { type = 0; idc = -1; x = safeZoneX + safeZoneW * 0.84375; y = safeZoneY + safeZoneH * 0.90925926; w = safeZoneW * 0.14739584; h = safeZoneH * 0.075; style = 0; text = ""; colorBackground[] = {1,1,1,1}; colorText[] = {0,0,0,1}; font = "PuristaMedium"; sizeEx = (((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1); onLoad = ""; }; }; class Controls { class T_1 { type = 0; idc = -1; x = safeZoneX + safeZoneW * 0.84791667; y = safeZoneY + safeZoneH * 0.92870371; w = safeZoneW * 0.04635417; h = safeZoneH * 0.04074075; style = 2; text = "Position:"; colorBackground[] = {0.7569,0.6353,0.298,0}; colorText[] = {0,0,0,1}; font = "PuristaMedium"; sizeEx = (((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1); }; class T_Pos { type = 0; idc = 10000; x = safeZoneX + safeZoneW * 0.90729167; y = safeZoneY + safeZoneH * 0.92870371; w = safeZoneW * 0.06614584; h = safeZoneH * 0.04074075; style = 0; text = "[0,0,1]"; colorBackground[] = {1,1,1,1}; colorText[] = {0,0,0,1}; font = "PuristaMedium"; sizeEx = (((((safezoneW / safezoneH) min 1.2) / 1.2) / 25) * 1); onLoad = "[] spawn fnc_pos"; }; }; }; Any Ideas? Thanks 😄 Share this post Link to post Share on other sites
gc8 970 Posted August 4, 2019 6 minutes ago, Smart Games said: _display = findDisplay 123; Looks like this is the problem because your gui idd is 12345 Share this post Link to post Share on other sites
Smart Games 76 Posted August 4, 2019 i forgot to change it, but that isnt the problem. I also tried it with findDisplay 123 Share this post Link to post Share on other sites
Larrow 2779 Posted August 4, 2019 High chance its just a timing issue. You execVM gui_functions.sqf which holds a definition for fnc_pos, and immediately initiate the ui of which ctrl T_Pos has an event( onLoad ) that calls the defined function. As execVM is scheduled, plus the engine has to load the file, parse the contents and then run it, but gui initialisation happens almost immediately there is a high chance the function has yet to be defined before the ui calls it. Try changing your init.sqf to... //init.sqf [] execVM "Gui\gui_functions.sqf"; //New schedule thread as I have //no idea what else your init.sqf holds h = [] spawn { waitUntil{ !isNil "fnc_pos" }; cutRsc ["gui1","plain"]; }; If the above fixes the issue you may want to look into using CfgFunction to define your functions. This way they will already be defined right from the start of the mission. There is also no need to keep updating the variables _display and _child every 0.5 seconds. Just get the references once out side the loop. You can then use the loop to exit if the display is not present. You can also pass the ctrl straight from the ctrl's onLoad event. onLoad = "_this spawn fnc_pos"; fnc_pos = { disableSerialization; params[ "_ctrl" ]; _display = ctrlParent _ctrl; while {!isNull _display} do { _ctrl ctrlSetText format ["%1", getpos player]; sleep 0.5; }; }; 2 Share this post Link to post Share on other sites
Smart Games 76 Posted August 5, 2019 thank you @Larrow Share this post Link to post Share on other sites