Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Shop Menu (https://forums.graalonline.com/forums/showthread.php?t=73445)

killerogue 04-12-2007 10:45 AM

Shop Menu
 
Heyo guys, I had never really scripted anything using Gui Controls before, so I decided to try something tonight.

Had a bit of help from Twinny, on the "button.onAction()" functions.

Anyway, here's a basic menu class that is brought up once you enter the level containing the class (preferably a shop ;)). I left the some space inbetween the buttons and chat. You can put your icons or whatever there, or even rearrange it. Just so you have something to start you off/help you out!

Class:
PHP Code:

//#CLIENTSIDE
function onPlayerEnters() {

  new 
GuiWindowCtrl(Stan_Window) {
    
profile "GuiBlueWindowProfile";
    
extent "300 300";
    
50;
    
50;
    
text "Shop Window";
    
visible true;
    
canResize false;

    new 
GuiScrollCtrl(Stan_Window_Scroll) {
      
profile "GuiBlueScrollProfile";
      
extent "250 100";
      
Stan_Window.width 275;
      
Stan_Window.height 110;
      
visible true;
      
hscrollbar "alwaysOff";
      
vscrollbar "dynamic";
    }

    new 
GuiButtonCtrl(Stan_Window_Buy) {
      
profile "GuiBlueButtonProfile";
      
extent "97 25";
      
position "5 23";
      
text "Buy";
    }

    new 
GuiButtonCtrl(Stan_Window_Sell) {
      
profile "GuiBlueButtonProfile";
      
extent "98 25";
      
position "101 23";
      
text "Sell";
    }

    new 
GuiButtonCtrl(Stan_Window_Leave) {
      
profile "GuiBlueButtonProfile";
      
extent "97 25";
      
position "198 23";
      
text "Leave";
    }

    new 
GuiMLTextCtrl(Stan_WindowText) {
      
profile "GuiBlueMLTextProfile";
      
Stan_Window.width 265;
      
Stan_Window.height 100;
      
text "Welcome to my store!";
    }
  }
}

function 
Stan_Window_Buy.onAction()
Stan_WindowText.setText("What would you like to buy?");

function 
Stan_Window_Sell.onAction()
Stan_WindowText.setText("What would you like to sell?");

function 
Stan_Window_Leave.onAction()
Stan_WindowText.setText("Leaving so soon? Come back again!"); 


Twinny 04-12-2007 04:21 PM

You don't actually have anything in that scroll control. If you wanted to add a control to it, you would do
PHP Code:

new GuiScrollCtrl("blah")
{
  
//vars
  
  
new GuiTextCtrl("blah2")
  {
    
//vars
  
}


Currently you just have a control over it.

Why not add a way to easily add items to be sold? Make an inventory system? So far it's just an empty gui control.

shadowjones 04-12-2007 04:34 PM

you should put this on your examples for GUI controls. Its a super simple script to just read and understand (of course add some //Purpose, after each line


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

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