Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #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!";
      
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:
__________________
Reply With Quote
  #2  
Old 09-03-2011, 08:55 PM
ff7chocoboknight ff7chocoboknight is offline
Skyzer Zolderon
ff7chocoboknight's Avatar
Join Date: Dec 2006
Location: New Hampshire, United States
Posts: 725
ff7chocoboknight is a glorious beacon of lightff7chocoboknight is a glorious beacon of lightff7chocoboknight is a glorious beacon of light
Send a message via AIM to ff7chocoboknight Send a message via MSN to ff7chocoboknight
Why are human and troll classes?
__________________
Reply With Quote
  #3  
Old 09-03-2011, 09:00 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
Quote:
Originally Posted by ff7chocoboknight View Post
Why are human and troll classes?
It doesn't really matter.
__________________
Reply With Quote
  #4  
Old 09-03-2011, 10:10 PM
0PiX0 0PiX0 is offline
Coder
0PiX0's Avatar
Join Date: Jan 2011
Posts: 130
0PiX0 is a jewel in the rough0PiX0 is a jewel in the rough
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.
Reply With Quote
  #5  
Old 09-04-2011, 05:26 PM
SoundFreak SoundFreak is offline
Music Artist
SoundFreak's Avatar
Join Date: Aug 2011
Posts: 15
SoundFreak is on a distinguished road
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.
Reply With Quote
  #6  
Old 07-19-2012, 01:34 PM
Vlad1 Vlad1 is offline
Registered User
Join Date: Apr 2012
Posts: 30
Vlad1 can only hope to improve
how do i activate also how could i put in there profile as class: whatever
Reply With Quote
  #7  
Old 07-20-2012, 06:41 AM
Tricxta Tricxta is offline
The Muffin Man
Tricxta's Avatar
Join Date: Oct 2010
Location: Australia
Posts: 563
Tricxta is a jewel in the roughTricxta is a jewel in the rough
Quote:
Originally Posted by Vlad1 View Post
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.
Reply With Quote
  #8  
Old 07-20-2012, 06:51 AM
devilsknite1 devilsknite1 is offline
C:
devilsknite1's Avatar
Join Date: Jul 2006
Location: Florida, USA
Posts: 269
devilsknite1 has a spectacular aura about
Send a message via AIM to devilsknite1 Send a message via MSN to devilsknite1 Send a message via Yahoo to devilsknite1
Quote:
Originally Posted by Tricxta View Post
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
Reply With Quote
  #9  
Old 07-23-2012, 04:32 AM
Vlad1 Vlad1 is offline
Registered User
Join Date: Apr 2012
Posts: 30
Vlad1 can only hope to improve
thanks tricxta
Reply With Quote
  #10  
Old 07-19-2012, 07:12 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
I'd recommend writing your own, because this is horrific.
__________________
Reply With Quote
  #11  
Old 07-19-2012, 08:50 PM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
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.
Reply With Quote
  #12  
Old 07-20-2012, 05:31 AM
devilsknite1 devilsknite1 is offline
C:
devilsknite1's Avatar
Join Date: Jul 2006
Location: Florida, USA
Posts: 269
devilsknite1 has a spectacular aura about
Send a message via AIM to devilsknite1 Send a message via MSN to devilsknite1 Send a message via Yahoo to devilsknite1
Quote:
Originally Posted by scriptless View Post
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 12:46 AM.


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