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";
x = 470;
y = 88;
new GuiTextCtrl("addrowsys2_Text1") {
profile = GuiBlueTextProfile;
height = 20;
text = "ID";
width = 12;
x = 14;
y = 15;
}
new GuiTextEditCtrl("addrowsys2_TextEdit1") {
profile = GuiBlueTextEditProfile;
height = 20;
width = 24;
x = 30;
y = 17;
}
new GuiTextCtrl("addrowsys2_Text2") {
profile = GuiBlueTextProfile;
height = 20;
text = "Name";
width = 34;
x = 60;
y = 15;
}
new GuiTextEditCtrl("addrowsys2_TextEdit2") {
profile = GuiBlueTextEditProfile;
height = 20;
width = 153;
x = 99;
y = 17;
}
new GuiButtonCtrl("addrowsys2_Button2") {
profile = GuiBlueButtonProfile;
height = 18;
text = "Add Row";
width = 250;
x = 5;
y = 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";
x = 480;
y = 84;
new GuiButtonCtrl("addrowsys_Button1") {
profile = GuiBlueButtonProfile;
height = 24;
text = "+";
width = 24;
x = 335;
y = 3;
hint = "Add flag";
}
new GuiButtonCtrl("addrowsys_Button2") {
profile = GuiBlueButtonProfile;
height = 24;
text = "=";
width = 24;
x = 310;
y = 3;
hint = "Switch Mode";
}
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 = 260;
y = 3;
hint = "Update";
}
new GuiButtonCtrl("addrowsys_Button5") {
profile = GuiBlueButtonProfile;
height = 24;
text = "G";
width = 24;
x = 235;
y = 3;
hint = "GUI Style";
}
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 = "A GUI for addding server flags.";
width = 305;
x = 9;
y = 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.flag: serverr.getdynamicvarnames()) {
addrowsys_TextList1.addrow(temp.count, temp.flag, temp.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.