Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Updating Co-Ordinates GUI (https://forums.graalonline.com/forums/showthread.php?t=134263293)

Emera 05-20-2011 10:17 PM

Updating Co-Ordinates GUI
 
I have made a very simple GUI which displays the players X and Y. But, i want it to update every 0.05 seconds. I don't yet know how to set timeouts so any help would be greatly appreciated.

PHP Code:

//#CLIENTSIDE 


function onCreated() {
    
setTimer(0.05);
    new 
GuiWindowCtrl("CoOrds_Window1") {
        
profile GuiBlueWindowProfile;
        
clientrelative true;
        
clientextent "109,56";

        
canclose false;
        
canmaximize false;
        
canminimize false;
        
canmove false;
        
canresize false;
        
closequery false;
        
destroyonhide false;
        
text "Co-Ordinates";
        
1045;
        
596;

        new 
GuiTextCtrl("CoOrds_Text1") {
            
profile GuiBlueTextProfile;
            
height 20;
            
text "player.x";
            
width 40;
            
9;
            
7;
        }
        new 
GuiTextCtrl("CoOrds_Text2") {
            
profile GuiBlueTextProfile;
            
height 20;
            
text "player.y";
            
width 41;
            
58;
            
7;
        }
        new 
GuiTextEditCtrl("CoOrds_TextEdit1") {
            
profile GuiBlueTextEditProfile;
            
height 20;
            
text player.x;
            
width 47;
            
6;
            
26;
        }
        new 
GuiTextEditCtrl("CoOrds_TextEdit2") {
            
profile GuiBlueTextEditProfile;
            
height 20;
            
text player.y;
            
setTimer(0.05);
            
width 47;
            
53;
            
26;
        }
    }



Mark Sir Link 05-20-2011 10:25 PM

why exactly do you want the windows to move? Are you more interested in just actually updating the player x/y text?

if so, just add

PHP Code:

function onTimeout(){
  
Co0rds_TextEdit2.text player.y;
  
Co0rds_TextEdit1.text player.x;
  
setTimer(.05);



Emera 05-20-2011 10:42 PM

This displays a sting of errors in RC.

Emera 05-20-2011 11:04 PM

Hey so i updated the script and it is still not displaying te x and y every .05 seconds.

PHP Code:

//#CLIENTSIDE
function onCreated() {
  new 
GuiWindowCtrl("MyGuiTest_Window1") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "126,98";

    
canclose false;
    
canmaximize false;
    
canminimize false;
    
canmove true;
    
canresize true;
    
closequery false;
    
destroyonhide false;
    
text "Co-Ordinates";
    
1028;
    
554;

    new 
GuiTextEditCtrl("MyGuiTest_TextEdit1") {
      
profile GuiBlueTextEditProfile;
      
height 20;
      
width 80;
      
text player.y;
      
23;
      
26;
    }
    new 
GuiTextEditCtrl("MyGuiTest_TextEdit2") {
      
profile GuiBlueTextEditProfile;
      
height 20;
      
width 80;
      
text player.x;
      
23;
      
67;
    }
    new 
GuiTextCtrl("MyGuiTest_Text1") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Player: X";
      
width 43;
      
39;
      
6;
    }
    new 
GuiTextCtrl("MyGuiTest_Text2") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Player: Y";
      
width 44;
      
42;
      
48;
    }
  }
}
function 
onTimeout(){
  
Co0rds_TextEdit2.text player.y;
  
Co0rds_TextEdit1.text player.x;
  
setTimer(.05);



oo_jazz_oo 05-20-2011 11:15 PM

In the onCreated() event, put
PHP Code:

onTimeout(); 

That will start the timeout loop. The code within the onCreated() event is triggered when the weapon is created (Pretty obvious). However, the onTimeout() event needs to be triggered by either calling it directly, or by setting a specific time with
PHP Code:

setTimer(x); 

http://gscript.graal.net/onTimeout

salesman 05-21-2011 02:52 AM

you should also use the correct gui names

Emera 05-21-2011 10:59 AM

Ok i fixed it thanks guys.

Deas_Voice 05-21-2011 11:00 AM

...or you could just click F5 =p

e; you should start renaming the gui-controls name after you created it with the GUI Editor (or stop using it, and do it manually), such as making "tool_button2" to the relevance it has, such as "tool_closebutton".

Emera 05-21-2011 01:54 PM

I know i could just click f5 lol but im learning slowly. It was just a test really.


All times are GMT +2. The time now is 03:07 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.