Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-21-2008, 02:53 AM
cyan3 cyan3 is offline
Registered User
cyan3's Avatar
Join Date: Nov 2005
Location: England
Posts: 2,919
cyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant future
Server Select GUI

I've been trying to teach myself some GS2 and I thought GUI scripting would be an easy place to start. So i messed around with some GUI Controls and come up with this.

PHP Code:
//Made by Felix Lionheart (cyan3)
//#CLIENTSIDE

function onKeyPressed(keycharcharacter)

  if (
character == "9"){
   
show();
}
 public function 
show()

  new 
GuiWindowCtrl("ServerSelect_Window") {
    
profile GuiWindowProfile;
    
clientrelative true;
    
clientextent "320,240";
    
extent "230 425";

    
canclose true;
    
canmaximize false;
    
canminimize true;
    
canmove true;
    
canresize false;
    
closequery false;
    
destroyonhide true;
    
text "Server Select -" SPC servername;
    
5;
    
100;

//Gold Servers
    
new GuiTextCtrl("ServerSelect_GoldServers") {
      
profile GuiTextProfile;
      
profile.fontsize 15;   
      
text "Gold Servers";
      
position "5 0";
}
    new 
GuiButtonCtrl("ServerSelect_GraalKingdoms") {
      
profile GuiButtonProfile;
      
text "Graal Kingdoms";
      
width 100;
      
5;
      
25;
}
    new 
GuiButtonCtrl("ServerSelect_Zone") {
      
profile GuiButtonProfile;
      
text "Zone";
      
width 100;
      
5;
      
60;
}
    new 
GuiButtonCtrl("ServerSelect_Games") {
      
profile GuiButtonProfile;
      
text "Graal Skills";
      
width 100;
      
110;
      
60;
}
    new 
GuiButtonCtrl("ServerSelect_KingdomsDebug") {
      
profile GuiButtonProfile;
      
text "Kingdoms Debug";
      
width 100;
      
110;
      
25;
}
//Classic Servers
    
new GuiTextCtrl("ServerSelect_ClassicServers") {
      
profile GuiTextProfile;
      
profile.fontsize 15;
      
text "Classic Servers";
      
position "5 90";

    new 
GuiButtonCtrl("ServerSelect_Zodiac") {
      
profile GuiButtonProfile;
      
text "Zodiac";
      
width 100;
      
5;
      
115;
}
    new 
GuiButtonCtrl("ServerSelect_Era") {
      
profile GuiButtonProfile;
      
text "Era";
      
width 100;
      
5;
      
150;
}
    new 
GuiButtonCtrl("ServerSelect_Classic") {
      
profile GuiButtonProfile;
      
text "Classic";
      
width 100;
      
5;
      
185;
}
    new 
GuiButtonCtrl("ServerSelect_Valikorlia") {
      
profile GuiButtonProfile;
      
text "Valikorlia";
      
width 100;
      
110;
      
115;
}
    new 
GuiButtonCtrl("ServerSelect_Atlantis") {
      
profile GuiButtonProfile;
      
text "Atlantis";
      
width 100;
      
110;
      
150;
}
    new 
GuiButtonCtrl("ServerSelect_Delteria") {
      
profile GuiButtonProfile;
      
text "Delteria";
      
width 100;
      
110;
      
185;
}
    new 
GuiButtonCtrl("ServerSelect_NPulse") {
      
profile GuiButtonProfile;
      
text "N-Pulse";
      
width 100;
      
5;
      
220;
}   
    new 
GuiButtonCtrl("ServerSelect_UnholyNation") {
      
profile GuiButtonProfile;
      
text "Unholy Nation";
      
width 100;
      
110;
      
220;
}

//Hosted Servers
    
new GuiTextCtrl("ServerSelect_HostedServers") {
      
profile GuiTextProfile;
      
profile.fontsize 15;
      
text "Hosted Servers";
      
position "5 250";
}
    new 
GuiButtonCtrl("ServerSelect_Aeon") {
      
profile GuiButtonProfile;
      
text "Aeon";
      
width 100;
      
5;
      
275;
}   
    new 
GuiButtonCtrl("ServerSelect_OlWest") {
      
profile GuiButtonProfile;
      
text "Ol' West";
      
width 100;
      
110;
      
275;
}
    new 
GuiButtonCtrl("ServerSelect_Atrius") {
      
profile GuiButtonProfile;
      
text "Atrius";
      
width 100;
      
5;
      
310;
}

//Other Servers
    
new GuiButtonCtrl("ServerSelect_Reconnect") {
    
profile GuiButtonProfile;
    
text "Reconnect";
    
width 100;
    
110;
    
310;
}
    new 
GuiButtonCtrl("ServerSelect_Disconnect") {
      
profile GuiButtonProfile;
      
text "Disconnect";
      
width 100;
      
5;
      
345;
}
    new 
GuiButtonCtrl("ServerSelect_Close") {
      
profile GuiButtonProfile;
      
text "Close";
      
width 70;
      
145;
      
360;
     }
    }

//Gold Servers
function ServerSelect_GraalKingdoms.onAction() {
  
serverwarp("Graal Kingdoms");
 }

function 
ServerSelect_KingdomsDebug.onAction() {
  
serverwarp("Kingdoms Debug");
 }
 
function 
ServerSelect_Zone.onAction() {
  
serverwarp("Zone");
  }

function 
ServerSelect_Games.onAction() {
  
serverwarp("Games");
 }
 
//Classic Servers
function ServerSelect_Zodiac.onAction() {
   
serverwarp("Zodiac");
  }
  
function 
ServerSelect_Era.onAction() {
  
serverwarp("Era");
 }
 
function 
ServerSelect_Classic.onAction() {
  
serverwarp("Classic");
 }

function 
ServerSelect_Valikorlia.onAction() {
  
serverwarp("Valikorlia");
 }

function 
ServerSelect_Atlantis.onAction() {
  
serverwarp("Atlantis");
 }

function 
ServerSelect_Delteria.onAction() {
  
serverwarp("Delteria");
 }
 
function 
ServerSelect_NPulse.onAction() {
  
serverwarp("N-Pulse");
 }

//Hosted Servers
function ServerSelect_Aeon.onAction() {
  
serverwarp("AEON");
 }

function 
ServerSelect_OlWest.onAction() {
  
serverwarp("Ol' West");
 }

function 
ServerSelect_Atrius.onAction() {
  
serverwarp("Atrius");
  }

//Other Servers
function ServerSelect_Reconnect.onAction() {
  
serverwarp(servername);
 }

function 
ServerSelect_Disconnect.onAction() {
  
serverwarp("Login1");
 }

function 
ServerSelect_Close.onAction() {
  
ServerSelect_Window.destroy();

Attached Thumbnails
Click image for larger version

Name:	graal_1227230204.png
Views:	422
Size:	257.7 KB
ID:	46555  

Last edited by cyan3; 11-21-2008 at 04:21 AM..
Reply With Quote
  #2  
Old 11-21-2008, 03:17 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Cool
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #3  
Old 11-21-2008, 05:25 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Nice. For future note, completed scripts to share go in the Code Gallery.
__________________
Reply With Quote
  #4  
Old 11-21-2008, 10:04 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
I really hate your styling, but good job
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #5  
Old 11-21-2008, 01:43 PM
cyan3 cyan3 is offline
Registered User
cyan3's Avatar
Join Date: Nov 2005
Location: England
Posts: 2,919
cyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant future
Quote:
Originally Posted by cbk1994 View Post
Nice. For future note, completed scripts to share go in the Code Gallery.
I'll try and get this thread moved and remember to post in the gallery in future.

Quote:
Originally Posted by xXziroXx View Post
I really hate your styling, but good job
I've just started learning GS2 and my styling has not developed yet.
Reply With Quote
  #6  
Old 11-21-2008, 03:50 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
Quote:
Originally Posted by cyan3 View Post
I've just started learning GS2 and my styling has not developed yet.
You could apply any other C-style-syntax language's styling and it would look better than this.

I recommend the Java style guidelines at Sun's Java site, apart from the java/javadoc specific stuff.
Reply With Quote
  #7  
Old 11-21-2008, 11:11 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
There doesn't really seem to be any "styling". It's inconsistent throughout the script.

I recommend picking up a form of styling as soon as you can, otherwise you're going to have to start later, which is a pain.
__________________
Reply With Quote
  #8  
Old 11-21-2008, 11:15 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Not to mention styling helps you out when you're scripting. It's a lot easier to know where a function starts and ends, what's part of a function, what's part of this if statement and not that one... so on and so forth. You a lot less likely to make errors and get lost in your own script.

And if you ever need help, it'll be a lot easier for the helper when they can understand it because of good styling.
Reply With Quote
  #9  
Old 11-24-2008, 09:50 AM
[email protected] sid.gottlieb@googlemail.com is offline
Banned
Join Date: Mar 2008
Posts: 861
sid.gottlieb@googlemail.com will become famous soon enough
cool, but try using a loop
Reply With Quote
  #10  
Old 11-24-2008, 09:15 PM
Programmer Programmer is offline
Coder
Programmer's Avatar
Join Date: Jan 2008
Location: -78.464422, 106.837328
Posts: 449
Programmer has a spectacular aura aboutProgrammer has a spectacular aura about
Send a message via AIM to Programmer Send a message via MSN to Programmer Send a message via Yahoo to Programmer
I'm surprised that this doesn't produce an error. I've never seen functions declared like so:

PHP Code:
function onKeyPressed(keycharcharacter)

  if (
character == "9"){
   
show();

When I first looked at this, it looked like you defined show() inside of onKeyPressed(). I suggest using braces where you can. This would make it a lot clearer:

PHP Code:
function onKeyPressed(keycharcharacter)
// Added a brace here ...
     
if (character == "9")
     {
          
show();
     }
// .. and here 
__________________
- Iᴀɴ Zɪᴍᴍᴇʀᴍᴀɴ
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:47 AM.


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