Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   trying to close and open a GUI - help (https://forums.graalonline.com/forums/showthread.php?t=134268324)

khortez 06-15-2013 03:23 AM

trying to close and open a GUI - help
 
PHP Code:

 function onKeyPressed(codekey) {
    if (
key == "q") {
      
this.on = !this.on;
      if (
this.on) {
        new 
GuiShowImgCtrl("GUI_Inventory") {
          
position = {
            
300100
          
};
          
extent = {
            
690560
          
};
          
image "c_inventorytest6-13-2013.png";
        }
      } else {
        
player.chat "Menu off!";
      }
    }
  } 

I'm also placing the code here once again for any helpful input. thanks to those who try to help. other then that, as the title says i'm mainly trying to close and open this GUI. but i don't know any way of doing that. so if there is a way, what is it?

Tim_Rocks 06-15-2013 03:36 AM

PHP Code:

//#CLIENTSIDE
//Try creating the GUI first before you actually try modifying/adding to it. 
function onCreated() { 
  if (
isObject("GUI_Inventory")) { 
    
GUI_Inventory.destroy(); 
  } 
  new 
GuiWindowCtrl("GUI_Inventory") { 
    
width 350
    
height 300

    
GraalControl.width - (width 2); 
    
GraalControl.height - (height 2); 

    
hide
  } 


function 
onKeyPressed(codekey) { 
  if (
key == "q") { 
    
this.on = !this.on

    if (
this.on) { 
      
GUI_Inventory.visible true
      
player.chat "I opened my inventory!"
    } else { 
      
GUI_Inventory.visible false
      
player.chat "I closed my inventory!"
    } 

  } 


Good luck buddy, I didn't test it!

khortez 06-15-2013 05:45 AM

thanks though is this necessary?


PHP Code:

function onCreated() { 
  if (
isObject("GUI_Inventory")) { 
    
GUI_Inventory.destroy(); 
  }
    } 


some parts of your script i'm still unfamiliar with. mainly GraalControl, even though it sounds self-explanatory its not something i've gone over very well before.

cbk1994 06-15-2013 06:30 AM

Quote:

Originally Posted by khortez (Post 1719268)
thanks though is this necessary?


PHP Code:

function onCreated() { 
  if (
isObject("GUI_Inventory")) { 
    
GUI_Inventory.destroy(); 
  }
    } 


some parts of your script i'm still unfamiliar with. mainly GraalControl, even though it sounds self-explanatory its not something i've gone over very well before.

No, it's not necessary. All it does is destroy the window if it already exists. Useful during development but should be taken out when you're ready to release it.

GraalControl is basically just a GUI object which contains the game. All he's doing is centering the window.


All times are GMT +2. The time now is 02:11 PM.

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