Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 09-03-2011, 07:11 PM
Emera Emera is offline
Delterian Hybrid
Emera's Avatar
Join Date: Mar 2011
Location: Newcastle Upon-Tyne
Posts: 1,704
Emera is a jewel in the roughEmera is a jewel in the rough
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!";
      
x = 517;
      
y = 203;
      
profile.fontstyle = "b";

      new 
GuiScrollCtrl("Class_MultiLine1_Scroll") {
        
profile = GuiBlueScrollProfile;
        
height = 60;
        
hscrollbar = "dynamic";
        
vscrollbar = "dynamic";
        
visible = true;
        
width = 316;
        
hscrollbar = "alwaysOff";
        
x = 2;
        
y = 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;
        
x = 2;
        
y = 65;
        
visible = true;

        new 
GuiTextListCtrl("Class_TextList1") {
          
profile = GuiBlueTextListProfile;
          
height = 34;
          
horizsizing = "width";
          
sortcolumn = 134406400;
          
sortmode = "value";
          
width = 312;
          
updateclasseslist();
          
profile.fontsize = 15;
          
seticonsize(1, 23);
          
profile.fontstyle = "b";
          
profile.textshadow = true;
        }
      }
      new 
GuiButtonCtrl("Class_Button1") {
        
profile = GuiBlueButtonProfile;
        
text = "Choose";
        
width = 314;
        
x = 3;
        
y = 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:
__________________
Reply With Quote
 


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 09:21 AM.


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