Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-26-2011, 04:33 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
Server Flag Adder

I have finally completed my code! Thank you to everybody who contributed towards the completion of the code by helping me out on various threads I have created about the development of this tool.

The Tool
The Server Flag Adder is a tool for displaying all of the current server flags in a nice GUI menu. Within the menu, you have the option to add flags to the server without creating them through a script. It displays the flags you already have present on your server with a Text List control in a nice little interface. I myself like to use GUI's as much as I can as it makes whatever you are developing nice and tidy (if you design the GUI properly!)

To open the GUI, all the player has to do is chat "/flagadder". Obviously, you can change that command to whatever you prefer or even allow it to open after a certain key has been pressed.

CODE
PHP Code:
function onCreated() {
  
this.allowed = {
    
"McChucken", "Other community name"
  
};
}
function 
onActionServerside() {
  if (
params[0] == "addflags")  { 
    if (
player.communityname in this.allowed) {
      
serverr.(@params[1]) = params[2];
    }  
  }
}

//#CLIENTSIDE
function addrowsys_Button1.onAction() {
  new 
GuiWindowCtrl("Extent_Window1") {
    
profile = GuiBlueWindowProfile;
    
clientrelative = true;
    
style = $pref::Video::defaultguistyle;
    
clientextent = "176,118";
    
canmaximize = false;
    
canminimize = false;
    
canmove = true;
    
canresize = true;
    
closequery = false;
    
destroyonhide = true;
    
text = "Add a flag";
    
x = 517;
    
y = 209;
    new 
GuiTextEditCtrl("Extent_TextEdit1") {
      
profile = GuiBlueTextEditProfile;
      
height = 20;
      
width = 80;
      
x = 7;
      
y = 19;
    }
    new 
GuiTextEditCtrl("Extent_TextEdit2") {
      
profile = GuiBlueTextEditProfile;
      
height = 20;
      
width = 80;
      
x = 7;
      
y = 59;
    }
    new 
GuiTextCtrl("Extent_Text1") {
      
profile = GuiBlueTextProfile;
      
height = 20;
      
text = "Flag Content";
      
width = 73;
      
x = 92;
      
y = 58;
    }
    new 
GuiTextCtrl("Extent_Text2") {
      
profile = GuiBlueTextProfile;
      
height = 20;
      
text = "Title / Name";
      
width = 69;
      
x = 93;
      
y = 18;
    }
    new 
GuiButtonCtrl("Extent_Button1") {
      
profile = GuiBlueButtonProfile;
      
height = 22;
      
text = "Add Flag";
      
width = 164;
      
x = 6;
      
y = 90;
    }
  }
}

function 
CreateGui() {
  new 
GuiWindowCtrl("addrowsys_Window1") {
    
profile = GuiBlueWindowProfile;
    
clientrelative = true;
    
clientextent = "367,238";
    
isexternal = false;
    
style = $pref::Video::defaultguistyle;
    
canmaximize = false;
    
canminimize = false;
    
canmove = true;
    
canresize = false;
    
closequery = false;
    
destroyonhide = true;
    
text = "Server Flag Editor";
    
x = 480;
    
y = 84;
    new 
GuiControl("Border1") {
      
useownprofile = true;
      
profile.border = 0;
      
profile.opaque = true;
      
profile.fillColor = {
        
163, 194, 212, 120
      
};
      
width = 367;
      
height = 238;
      
x = 0;
      
y = 0;
    }
    new 
GuiButtonCtrl("addrowsys_Button1") {
      
profile = GuiBlueButtonProfile;
      
height = 24;
      
text = "+";
      
width = 24;
      
x = 335;
      
y = 3;
      
hint = "Add flag";
    }
    new 
GuiButtonCtrl("addrowsys_Button3") {
      
profile = GuiBlueButtonProfile;
      
height = 24;
      
text = "?";
      
width = 24;
      
x = 285;
      
y = 3;
      
hint = "help";
    }
    new 
GuiButtonCtrl("addrowsys_Button4") {
      
profile = GuiBlueButtonProfile;
      
height = 24;
      
text = "^";
      
width = 24;
      
x = 310;
      
y = 3;
      
hint = "Update";
    }
    new 
GuiScrollCtrl("addrowsys_TextList1_Scroll") {
      
profile = GuiBlueScrollProfile;
      
hscrollbar = "alwaysOff";
      
vscrollbar = "dynamic";
      
width = 354;
      
x = 6;
      
y = 32;
      new 
GuiTextListCtrl("addrowsys_TextList1") {
        
profile = GuiBlueTextListProfile;
        
height = 34;
        
horizsizing = "width";
        
sortcolumn = 167550464;
        
width = 350;
      }
    }
    new 
GuiTextCtrl("addrowsys_Text1") {
      
profile = GuiBlueTextProfile;
      
height = 20;
      
text = "Server Flag Adder.";
      
width = 305;
      
x = 9;
      
y = 6;
    }
  }
}

function 
addrowsys_Button4.onAction() {
  
getflags();
}

function 
Extent_Button1.onAction() {
  
addflags();
}

function 
addrowsys_Button3.onAction() {
  
say2("You can add rows#bto the GUI by pressing#bthe + button.#bYou can update the flag#bscreen by pressing the ^ button.");
}

function 
GetFlags() {
  
addrowsys_TextList1.clearrows();
  for (
temp.flag: serverr.getdynamicvarnames()) {
    
addrowsys_TextList1.addrow(temp.count, temp.flag, temp.value = serverr.(@temp.flag));
    
temp.count++;
  }
}

function 
AddFlags() {
  
triggerserver("gui", this.name, "addflags", Extent_TextEdit1.text, Extent_TextEdit2.text);
  
getflags();
}

function 
OpenGui() {
  
creategui();
  
addflags();
}

function 
ChatBar.onAction() {   
  if (
ChatBar.text.trim() == "/flagadder") {   
    
OpenGui(); //Opens the GUI. 
    
ChatBar.text = ""; // Clear the chatbar so /flagadder isn't chatted out loud. 
  
}   
} 
The Graal Pastebin file can be found here.
Have fun!
Attached Thumbnails
Click image for larger version

Name:	emeraserverflagadder.PNG
Views:	316
Size:	17.3 KB
ID:	53560   Click image for larger version

Name:	serverflagadder.PNG
Views:	322
Size:	42.0 KB
ID:	53563  
__________________

Last edited by Emera; 08-27-2011 at 01:31 AM..
Reply With Quote
 

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 09:04 PM.


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