PDA

View Full Version : Reset GUI


Switch
08-18-2008, 03:30 AM
Just a simple reset GUI I made.
This was what I needed help with for the random strings :p
//Scripted by Switch
function onActionServerSide() {
if (params[0] == "reset1") {
sendToRC("/reset " @player.account);
savelog2("reset.txt", [email protected] " has reset.");
}
if (params[0] == "reset2") {
sendToRC("/reset " @player.account);
savelog2("reset.txt", [email protected] " 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>
" @[email protected] "</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

Inverness
08-18-2008, 03:36 AM
Or you could just make them type their account name.

Tigairius
08-18-2008, 04:02 AM
triggerserver("gui",name,"reset1",player.account);
else
triggerserver("gui",name,"reset2",player.account,Reset_Reason.text);



That's pretty insecure, could use a memory editor to edit the trigger and basically reset anyone you want. The data of who needs to be reset should be determined serverside, which is just basically changing params[1] to player.account serverside. Other than that, neat.
If it were me I would have probably done something like this:

function onCreated() {
this.list = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN OPQRSTUVWXYZ";
for (temp.i = 0; temp.i < 5; temp.i ++) {
this.randomstr @= this.list.charat(int(random(0, this.list.length())));
}
}

for my way of determining the random string.

Edit:
You could also change the 5 to any number in the for loop and output a random string of alphanumeric characters as large as you specified.

Switch
08-18-2008, 06:29 AM
That's pretty insecure, could use a memory editor to edit the trigger and basically reset anyone you want. The data of who needs to be reset should be determined serverside, which is just basically changing params[1] to player.account serverside. Other than that, neat.
Ah, thanks for pointing that out xD
Edited it to be that.

cbk1994
08-18-2008, 07:08 AM
Nice script, but what's up with this:


this.beg = { "iA", "Pq", "oa", "cQ", "Vu", "zC", "Gd", "jE",
"aT", "fg", "io", "mv" };

?

Why not keep them on the same line?

EDIT:
rep++

xXziroXx
08-18-2008, 10:08 AM
Nice script, but what's up with this:


this.beg = { "iA", "Pq", "oa", "cQ", "Vu", "zC", "Gd", "jE",
"aT", "fg", "io", "mv" };

?

Why not keep them on the same line?

EDIT:
rep++

I do somewhat the same, if the array gets huge, I separate it on several lines to make it readable without hours of side scrolling.

napo_p2p
08-18-2008, 12:24 PM
I do somewhat the same, if the array gets huge, I separate it on several lines to make it readable without hours of side scrolling.

Same here. I normally cut lines at around 80 columns.

TheStan
08-18-2008, 07:14 PM
//Scripted by Switch
function onActionServerSide() {
if (params[0] == "reset") {
temp.text = (params[1] == null)? (player.account @ " has been reset.") : (player.account @ " has been reset because: " @ params[1]);
sendToRC("/reset " @player.account);
savelog2("reset.txt", temp.text);
}
}

//#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>
" @[email protected] "</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) {
triggerserver("gui",name,"reset",Reset_Reason.text);
}
else {
Reset_Button.text = "Wrong Confirmation Code!";
sleep(3);
Reset_Button.text = "Reset Me!";
}
}


Bit bored so I trimmed a lil bit off just for the hell of it. It wasn't necessary for you to have both of those "reset#" arguments when you could have had just a condition.

Switch
08-18-2008, 09:09 PM
//Scripted by Switch
function onActionServerSide() {
if (params[0] == "reset") {
temp.text = (params[1] == null)? (player.account @ " has been reset.") : (player.account @ " has been reset because: " @ params[1]);
sendToRC("/reset " @player.account);
savelog2("reset.txt", temp.text);
}
}

//#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>
" @[email protected] "</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) {
triggerserver("gui",name,"reset",Reset_Reason.text);
}
else {
Reset_Button.text = "Wrong Confirmation Code!";
sleep(3);
Reset_Button.text = "Reset Me!";
}
}


Bit bored so I trimmed a lil bit off just for the hell of it. It wasn't necessary for you to have both of those "reset#" arguments when you could have had just a condition.

Ah that's true, but I just wasn't thinking about that xD
Anyway, it's still just about the exact same thing...

xXziroXx
08-18-2008, 09:15 PM
this.confCode = null;

Why are you setting a non-existant variable to NULL in onCreated()?

Switch
08-19-2008, 12:37 AM
this.confCode = null;

Why are you setting a non-existant variable to NULL in onCreated()?

Incase they're updating it.
But it doesnt matter, does it?

Crow
08-19-2008, 12:40 AM
this.confCode = null;

Why are you setting a non-existant variable to NULL in onCreated()?

I'm actually doing that too, especially in large blocks of code, to quickly see what important variables the script is using.

xXziroXx
08-19-2008, 12:53 AM
I'm actually doing that too, especially in large blocks of code, to quickly see what important variables the script is using.

I'd rather do something like this:


function onCreated()
{
this.var = 1337;
this.array = {"foo", "bar", "baz" };
// Etc.. then:
// this.importantVar1 - used for foo and bar, in the baz block
// this.importantVar2 - used to determinate the level of foo'nes from baz
// Etc!
}

Dan
08-19-2008, 01:58 AM
I'd rather do something like this:


Gratz! :fro:

Kristi
08-19-2008, 02:04 AM
Gratz! :fro:
I have a feeling this was sarcasm, but ziro's doesn't give the compiler something to interpret and create a pointless assignment.

Inverness
08-19-2008, 06:40 AM
Graal will not explode if you have a few pointless assignments here and there.

xXziroXx
08-19-2008, 01:12 PM
Graal will not explode if you have a few pointless assignments here and there.

No, but why add something that serves no purpose? It's just stupid.

Admins
08-19-2008, 01:19 PM
Initializing variables is good for readability even if it might automatically set it to zero on script update (also it makes it easier to copy to other scripts).

xXziroXx
08-19-2008, 01:24 PM
Well, The Man has spoken, my opinion remains the same though.

Switch
08-19-2008, 06:30 PM
initializing variables is good for readability even if it might automatically set it to zero on script update (also it makes it easier to copy to other scripts).

I win!
:D