Just a simple reset GUI I made.
This was what I needed help with for the random strings
PHP Code:
//Scripted by Switch
function onActionServerSide() {
if (params[0] == "reset1") {
sendToRC("/reset " @player.account);
savelog2("reset.txt", player.account@ " has reset.");
}
if (params[0] == "reset2") {
sendToRC("/reset " @player.account);
savelog2("reset.txt", player.account@ " has reset because:
" @params[1]);
}
}
//#CLIENTSIDE
function onCreated() {
this.beg = { "iA", "Pq", "oa", "cQ", "Vu", "zC", "Gd", "jE",
"aT", "fg", "io", "mv" };
this.mid = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 };
this.end = { "io", "vb", "cH", "pA", "oA", "nb", "ua", "Ac",
"iA", "Co", "Op", "In" };
this.confCode = null;
}
function onPlayerChats() {
if (player.chat == "/reset") {
this.confCode = randomString(this.beg) @ randomString(this.mid) @ randomString(this.end);
new GuiWindowCtrl("Reset_Window") {
profile = GuiBlueWindowProfile;
canClose = true;
canMaximize = false;
canMinimize = false;
canResize = false;
canMove = true;
closeQuery = false;
destroyOnHide = true;
text = "Reset Window";
x = 250;
y = 250;
width = 350;
height = 250;
new GuiMLTextCtrl("Reset_Info") {
profile = GuiBlueMLTextProfile;
x = 25;
y = 25;
width = 300;
text = "<center>If you really wish to be reset, fill in the text box below with the confirmation code in the left text box and click the 'Reset Me!' button. You can also fill out a reason as to why you're reseting if you want to in the right text box.
If not, just close this window.
<b><u>CONFIRMATION CODE:</u></b>
" @thiso.confCode@ "</center>";
}
new GuiTextEditCtrl("Reset_ConfCodeEnter") {
profile = GuiBlueTextEditProfile;
x = 25;
y = 170;
width = 70;
height = 20;
}
new GuiTextEditCtrl("Reset_Reason") {
profile = GuiBlueTextEditProfile;
x = 100;
y = 170;
width = 220;
height = 20;
}
new GuiButtonCtrl("Reset_Button") {
profile = GuiBlueButtonProfile;
x = 100;
y = 200;
width = 150;
height = 40;
text = "Reset Me!";
}
}
}
}
function Reset_Button.onAction() {
if (Reset_ConfCodeEnter.text == this.confCode) {
if (Reset_Reason.text == null)
triggerserver("gui",name,"reset1");
else
triggerserver("gui",name,"reset2",Reset_Reason.text);
}
else {
Reset_Button.text = "Wrong Confirmation Code!";
sleep(3);
Reset_Button.text = "Reset Me!";
}
}
You can add as many strings in this.beg, this.mid, and this.end