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!