Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-22-2011, 06:56 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
Question Server Flag Reader

I was working on an easy way to edit, add and read from the server flags using a TextList. I have hit a wall. I have the interface finished and know how to add rows to the text list using the GUI, but don't know how to read from the server flags and show them in the text list.

Code
PHP Code:
findplayerbycommunityname("Chelterrar").addweapon(this.name);

//#CLIENTSIDE
function onCreated() {
  
creategui(); //Creates the GUI Interface
}

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); //Adds the rows to the Text List
}

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 Reader";
    
480;
    
84;

    new 
GuiButtonCtrl("addrowsys_Button1") {
      
profile GuiBlueButtonProfile;
      
height 24;
      
text "+";
      
width 24;
      
335;
      
3;
    }
    new 
GuiButtonCtrl("addrowsys_Button2") {
      
profile GuiBlueButtonProfile;
      
height 24;
      
text "=";
      
width 24;
      
310;
      
3;
    }
    new 
GuiButtonCtrl("addrowsys_Button3") {
      
profile GuiBlueButtonProfile;
      
height 24;
      
text "?";
      
width 24;
      
285;
      
3;
    }
    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() { //Changes the GUI to external or not
  
if (addrowsys_Window1.isexternal == true) {
    
addrowsys_Window1.isexternal false;
    
addrowsys2_Window1.isexternal false;
  } else {
    
addrowsys_Window1.isexternal true;
    
addrowsys2_Window1.isexternal false;
  }
}

function 
addrowsys_Button3.onAction() { //Provides help
  
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(); //Creates the GUI.
  
}

Any help will be greatly appreciated. Thank you.


Styled using FP4's GS2 Beautifier
__________________
Reply With Quote
  #2  
Old 08-22-2011, 07:03 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by Emera View Post
I was working on an easy way to edit, add and read from the server flags using a TextList. I have hit a wall. I have the interface finished and know how to add rows to the text list using the GUI, but don't know how to read from the server flags and show them in the text list.
In order to obtain a list of all the different serverr variable names you can do:

PHP Code:
temp.vars serverr.getdynamicvarnames(); 
Then you can simply loop through that array and add serverr.(@ array value) as a list entry.
Reply With Quote
  #3  
Old 08-22-2011, 07:05 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 ffcmike View Post
In order to obtain a list of all the different serverr variable names you can do:

PHP Code:
temp.vars serverr.getdynamicvarnames(); 
Then you can simply loop through that array and add serverr.(@ array value) as a list entry.
Thank you very much.
How would I implement this into my script. I get what you are saying, but not how to add it.
__________________
Reply With Quote
  #4  
Old 08-22-2011, 07:23 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
HTML Code:
for (temp.flag: serverr.getdynamicvarnames()) {
  addrowsys_TextList1.addrow(temp.count, temp.flag);
  temp.count++;
}
__________________
Reply With Quote
  #5  
Old 08-23-2011, 12:40 AM
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
Question

Hey, thanks for that. Here is what I have.

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);
}

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 "GUI addrow(); System";
    
480;
    
84;
    new 
GuiButtonCtrl("addrowsys_Button1") {
      
profile GuiBlueButtonProfile;
      
height 24;
      
text "+";
      
width 24;
      
335;
      
3;
    }
    new 
GuiButtonCtrl("addrowsys_Button2") {
      
profile GuiBlueButtonProfile;
      
height 24;
      
text "=";
      
width 24;
      
310;
      
3;
    }
    new 
GuiButtonCtrl("addrowsys_Button3") {
      
profile GuiBlueButtonProfile;
      
height 24;
      
text "?";
      
width 24;
      
285;
      
3;
    }
    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_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 
GetFlags() {
  
addrowsys_TextList1.clearrows();
  for (
temp.flagserverr.getdynamicvarnames()) {
    
addrowsys_TextList1.addrow(temp.counttemp.flag);
    
temp.count++;
  }

Slight issue, it returns the flag name, but not the value X_X
How do I get it to do that?
__________________
Reply With Quote
  #6  
Old 08-23-2011, 12:52 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
Quote:
Originally Posted by Emera View Post
Slight issue, it returns the flag name, but not the value X_X
How do I get it to do that?
That's the point of it. You then do the following to get the value:

temp.value = serverr.(@temp.flag);
__________________
Quote:
Reply With Quote
Reply


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 06:45 PM.


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