Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Class Selection System (https://forums.graalonline.com/forums/showthread.php?t=134264466)

Emera 09-03-2011 07:11 PM

Class Selection System
 
Thank you everybody who helped me when I was creating this system. You all helped out a great deal to help me get this done

What is it?
This is a very simple class selection GUI for servers starting a medieval server. This is a very very simple class selection GUI that uses client flags to store the information for the classes. You can then base other scripts around the client flags and make NPC's act in a different way depending on the contents of the players class flag. It can very easily be built onto and the classes list edited.

Code
PHP Code:

function onActionServerSide() {
  if (
params[0] == "addclass") {
    
clientr.class = params[1]; //Adds the player flag
  
}
  if (
params[0] == "resetclass") {
    
clientr.class = NULL//Resets class
  
}
}

//#CLIENTSIDE
function onCreated() {
  if (
clientr.class == NULL) { //To prevent multi-class choosing
    
new GuiWindowCtrl("Class_Window1") {
      
profile GuiBlueWindowProfile;
      
clientrelative true;
      
clientextent "320,240";
      
canclose false;
      
canmaximize false;
      
canminimize false;
      
canmove true;
      
canresize false;
      
closequery false;
      
destroyonhide true;
      
text "Choose your class!";
      
517;
      
203;
      
profile.fontstyle "b";

      new 
GuiScrollCtrl("Class_MultiLine1_Scroll") {
        
profile GuiBlueScrollProfile;
        
height 60;
        
hscrollbar "dynamic";
        
vscrollbar "dynamic";
        
visible true;
        
width 316;
        
hscrollbar "alwaysOff";
        
2;
        
2;

        new 
GuiMLTextCtrl("Class_MultiLine1") {
          
profile GuiBlueMLTextProfile;
          
height 51;
          
horizsizing "width";
          
plaintext "<center> Please choose the class below you wish to take on an epic journey and become the greatest warrior in the game! Choose wisely! You can't change it!";
          
text "<center> Please choose the class below you wish to take on an epic journey and become the greatest warrior in the game!";
          
width 291;
        }
      }
      new 
GuiScrollCtrl("Class_TextList1_Scroll") {
        
profile GuiBlueScrollProfile;
        
height 138;
        
hscrollbar "alwaysOff";
        
vscrollbar "dynamic";
        
width 316;
        
2;
        
65;
        
visible true;

        new 
GuiTextListCtrl("Class_TextList1") {
          
profile GuiBlueTextListProfile;
          
height 34;
          
horizsizing "width";
          
sortcolumn 134406400;
          
sortmode "value";
          
width 312;
          
updateclasseslist();
          
profile.fontsize 15;
          
seticonsize(123);
          
profile.fontstyle "b";
          
profile.textshadow true;
        }
      }
      new 
GuiButtonCtrl("Class_Button1") {
        
profile GuiBlueButtonProfile;
        
text "Choose";
        
width 314;
        
3;
        
206;
      }
    }
  }
}

function 
Class_Button1.onAction() {
  
triggerserver("gui"this.name"addclass"Class_TextList1.selected.text);
  
Class_Window1.destroy();
}

function 
UpdateClassesList() {
  
clearrows();
  
addrow(0"Archer");
  
addrow(1"Wizard");
  
addrow(2"Knight");
  
addrow(3"Alchemist");
  
addrow(4"Dark Mage");
  
addrow(5"Light Mage");
  
addrow(6"Elf");
  
addrow(7"Necroshade");
  
addrow(8"Paladin");
  
addrow(9"Troll");
  
addrow(10"Human");
  if (
clientr.isStaff) { //Special classes.
    
addrow(11"Creator");
    
addrow(12"Destroyer");
    
addrow(13"Summoner");
  }
}

function 
onPlayerChats() {
  if (
player.chat == "/resetclass") {
    
//Sets the flag to NULL
    
triggerserver("gui"this.name"resetclass");
    
//Avoid having a NULL class
    
serverwarp(servername);
  }


Image:
http://uploads.graalcenter.org/upload/ClassSelect.PNG

ff7chocoboknight 09-03-2011 08:55 PM

Why are human and troll classes?

Emera 09-03-2011 09:00 PM

Quote:

Originally Posted by ff7chocoboknight (Post 1666887)
Why are human and troll classes?

It doesn't really matter.

0PiX0 09-03-2011 10:10 PM

At the moment, a cheater could send manipulated data to the server, and set their class to be anything, including the staff-only ones. You should make some simple server-side security checks for params[1] and also check if the player is staff for staff only classes.

SoundFreak 09-04-2011 05:26 PM

Well done on completing your code mate! Haven't spoken to you in a while, and who would have though we would meet up online! Seen your tracks in the music gallery too mate. Very smooth. Keep all of this good work up.

Vlad1 07-19-2012 01:34 PM

how do i activate also how could i put in there profile as class: whatever

Emera 07-19-2012 07:12 PM

I'd recommend writing your own, because this is horrific.

scriptless 07-19-2012 08:50 PM

Personally, I am not a fan of such style of selection. I prefer onscreen images of some sort, or something more similar to how GK presents them. Maybe I am just getting tired of the default blue gui being over used.. however nice work, I would only recommend additional security as 0PiX0 stated.

devilsknite1 07-20-2012 05:31 AM

Quote:

Originally Posted by scriptless (Post 1699736)
Personally, I am not a fan of such style of selection. I prefer onscreen images of some sort, or something more similar to how GK presents them. Maybe I am just getting tired of the default blue gui being over used.. however nice work, I would only recommend additional security as 0PiX0 stated.

Check the dates ;)

Tricxta 07-20-2012 06:41 AM

Quote:

Originally Posted by Vlad1 (Post 1699710)
how do i activate also how could i put in there profile as class: whatever

I think there's a string in server options that lets you nominate profile variables called profilevars, just insert clientr.class into that and you're rocking.

devilsknite1 07-20-2012 06:51 AM

Quote:

Originally Posted by Tricxta (Post 1699798)
I think there's a string in server options that lets you nominate profile variables called profilevars, just insert clientr.class into that and you're rocking.

In server options, profilevars=Class:=clientr.class

Vlad1 07-23-2012 04:32 AM

thanks tricxta


All times are GMT +2. The time now is 07:52 AM.

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