Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-25-2011, 12:52 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
Adding Server Flags

Hello. I am currently working on a way to add, edit and view server flags via a GUI control and again, I have hit a wall. It is quite hard to explain. I want to add flags by making the GUI read from certain text boxes. This is what I have. I am fairly new to scripting so if you want to help simplify or improve my script, please do help!
PHP Code:
//#CLIENTSIDE
function onCreated() {
  
creategui();
  
getflags();
  }
function 
addrowsys_Button1.onAction() {
  new 
GuiWindowCtrl("addrowsys2_Window1") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "260,60";
    
isexternal true;
    
canmaximize false;
    
canminimize false;
    
canmove true;
    
canresize true;
    
closequery false;
    
destroyonhide true;
    
dockable true;
    
text "Add a row";
    
470;
    
88;

    new 
GuiTextCtrl("addrowsys2_Text1") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "ID";
      
width 12;
      
14;
      
15;
    }
    new 
GuiTextEditCtrl("addrowsys2_TextEdit1") {
      
profile GuiBlueTextEditProfile;
      
height 20;
      
width 24;
      
30;
      
17;
    }
    new 
GuiTextCtrl("addrowsys2_Text2") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "Name";
      
width 34;
      
60;
      
15;
    }
    new 
GuiTextEditCtrl("addrowsys2_TextEdit2") {
      
profile GuiBlueTextEditProfile;
      
height 20;
      
width 153;
      
99;
      
17;
    }
    new 
GuiButtonCtrl("addrowsys2_Button2") {
      
profile GuiBlueButtonProfile;
      
height 18;
      
text "Add Row";
      
width 250;
      
5;
      
45;
    }
  }
}

function 
addrowsys2_Button2.onAction() {
  
addrowsys_TextList1.AddRow( (addrowsys2_TextEdit1.text), addrowsys2_TextEdit2.text );
    
triggerserver("gui",this.name,"createflag",addrowsys2_TextEdit2.text);
  }

  function 
CreateGui() {
    new 
GuiWindowCtrl("addrowsys_Window1") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "367,238";
    
isexternal true;
    
canmaximize false;
    
canminimize false;
    
canmove true;
    
canresize false;
    
closequery false;
    
destroyonhide true;
    
text "Server Flag Editor";
    
480;
    
84;

    new 
GuiButtonCtrl("addrowsys_Button1") {
      
profile GuiBlueButtonProfile;
      
height 24;
      
text "+";
      
width 24;
      
335;
      
3;
      
hint "Add flag";
    }
    new 
GuiButtonCtrl("addrowsys_Button2") {
      
profile GuiBlueButtonProfile;
      
height 24;
      
text "=";
      
width 24;
      
310;
      
3;
      
hint "Switch Mode";
    }
    new 
GuiButtonCtrl("addrowsys_Button3") {
      
profile GuiBlueButtonProfile;
      
height 24;
      
text "?";
      
width 24;
      
285;
      
3;
      
hint "help";
    }
    new 
GuiButtonCtrl("addrowsys_Button4") {
      
profile GuiBlueButtonProfile;
      
height 24;
      
text "^";
      
width 24;
      
260;
      
3;
      
hint "Update";
    }
    new 
GuiButtonCtrl("addrowsys_Button5") {
      
profile GuiBlueButtonProfile;
      
height 24;
      
text "G";
      
width 24;
      
235;
      
3;
      
hint "GUI Style";
    }
    new 
GuiScrollCtrl("addrowsys_TextList1_Scroll") {
      
profile GuiBlueScrollProfile;
      
hscrollbar "alwaysOff";
      
vscrollbar "dynamic";
      
width 354;
      
6;
      
32;

      new 
GuiTextListCtrl("addrowsys_TextList1") {
        
profile GuiBlueTextListProfile;
        
height 34;
        
horizsizing "width";
        
sortcolumn 167550464;
        
width 350;
      }
    }
    new 
GuiTextCtrl("addrowsys_Text1") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "A GUI for addding server flags.";
      
width 305;
      
9;
      
6;
    }
  }
}

function 
addrowsys_Button2.onAction() {
  if (
addrowsys_Window1.isexternal == true) {
    
addrowsys_Window1.isexternal false;
      
addrowsys2_Window1.isexternal false;
   }
   else {
   
addrowsys_Window1.isexternal true;
     
addrowsys2_Window1.isexternal false;
   }
 }

function 
addrowsys_Button4.onAction() {
  
getflags();
}
 function 
addrowsys_Button3.onAction() {
   
say2("You can add rows#bto the GUI by pressing#bthe + button.#bTo switch from external mode,#bpress the = button.");
   }
function 
onWeaponFired() {
  if (
addrowsys_Window1.visible == false) {
    
creategui();
 }
 }
 function 
addrowsys_Button5.onAction() {
   
style();
 }
 function 
GetFlags() {
 
addrowsys_TextList1.clearrows();
   for (
temp.flagserverr.getdynamicvarnames()) {
  
addrowsys_TextList1.addrow(temp.counttemp.flagtemp.value serverr.(@temp.flag));
  
temp.count++;
}
}
function 
Style() {
  
say2("This feature is still being worked on."); //Working on it.
}

function 
onPlayerChats() {
  if (
player.chat == "/flageditor") {
    
creategui(); //Creates the GUI.
    
getflags();
  }

I first tried to do something like this.
PHP Code:
function onActionServerside() {
  if (
params[0] == "createflag"serverr.(params[2]);
}

//#CLIENTSIDE
function onCreated() {
  
//GUI stuff here.
}

function 
addrowsys2_Button2.onAction() {
  
addrowsys_TextList1.AddRow((addrowsys2_TextEdit1.text), addrowsys2_TextEdit2.text);
  
triggerserver("gui"this.name"createflag"addrowsys2_TextEdit2.text);

I knew I was doing something very wrong and now I know you can't add flags by doing something as stupid as that. I was wondering if there was some kind of function to create a server flag. If anybody knows it, please share it. I have scanned the Graal bible and I can't seem to find anything. I have seen it done before in a GUI simpler than mine on Graal Inspiration. Thank you for your help. Images are attached below.
Attached Thumbnails
Click image for larger version

Name:	serverflagedito2.PNG
Views:	354
Size:	14.4 KB
ID:	53549   Click image for larger version

Name:	serverflageditor.PNG
Views:	377
Size:	28.7 KB
ID:	53550  
__________________
Reply With Quote
  #2  
Old 08-25-2011, 01:13 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
No need for a function. You can create server flags dynamically like this:
PHP Code:
serverr.(@ a) = b
Where a is the name and b is the content (duh). You just didn't assign anything to the flag in your example, which resulted in it not being created at all.
Reply With Quote
  #3  
Old 08-25-2011, 01:25 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 Crow View Post
No need for a function. You can create server flags dynamically like this:
PHP Code:
serverr.(@ a) = b
Where a is the name and b is the content (duh). You just didn't assign anything to the flag in your example, which resulted in it not being created at all.
xD Thank you crow <3
__________________
Reply With Quote
  #4  
Old 08-25-2011, 04:47 PM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
Replace the "," with an "=" it looks better :P (In the flag reader GUI)
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote
  #5  
Old 08-25-2011, 04:49 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 Astram View Post
Replace the "," with an "=" it looks better :P (In the flag reader GUI)
There are many "," in my script. Please me specific.
__________________
Reply With Quote
  #6  
Old 08-25-2011, 08:00 PM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
why would you need a server flag editor
Reply With Quote
  #7  
Old 08-25-2011, 08:10 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 Mark Sir Link View Post
why would you need a server flag editor
Haven't got a clue, but it was damn fun making it.
__________________
Reply With Quote
  #8  
Old 08-25-2011, 09:20 PM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
@Emera; I've always kept dynamic things like date, time, etc in DPNPC's just in case I want to update server flags through RC.
Reply With Quote
  #9  
Old 08-25-2011, 09:23 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 Cubical View Post
@Emera; I've always kept dynamic things like date, time, etc in DPNPC's just in case I want to update server flags through RC.
Half the stuff there I didn't create, and has been created through a script. But thanks for the info.
__________________
Reply With Quote
  #10  
Old 08-25-2011, 09:52 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
Quote:
Originally Posted by Cubical View Post
@Emera; I've always kept dynamic things like date, time, etc in DPNPC's just in case I want to update server flags through RC.
That's kind of silly, server flags are useful because they can be sent to the client automatically, which makes them ideal for dynamic information (for example, radio stations, weather conditions, clientside timevar2, ...)
__________________
Reply With Quote
  #11  
Old 08-25-2011, 11:46 PM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
Quote:
Originally Posted by cbk1994 View Post
That's kind of silly, server flags are useful because they can be sent to the client automatically, which makes them ideal for dynamic information (for example, radio stations, weather conditions, clientside timevar2, ...)
yes but if you update them doesn't it update all the flags and not just the one you changed?
Reply With Quote
  #12  
Old 08-26-2011, 12: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
Quote:
Originally Posted by Cubical View Post
yes but if you update them doesn't it update all the flags and not just the one you changed?
Yes, which is why it's probably a good idea to avoid updating them via RC altogether if you have flags which change a lot.
__________________
Reply With Quote
  #13  
Old 08-26-2011, 12:57 AM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Quote:
Originally Posted by cbk1994 View Post
Yes, which is why it's probably a good idea to avoid updating them via RC altogether if you have flags which change a lot.
Just like if people have a clock/weather system on their server using flags
__________________
MEEP!
Reply With Quote
  #14  
Old 08-26-2011, 01:55 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
In regards to serverr flags updating, it would be nice if there was an event on the client-side that we could use rather than using a timeout or similar.

I.e: onServerFlagUpdated(flag, newvalue);
__________________
Quote:
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 01:58 PM.


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