Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Reset GUI (https://forums.graalonline.com/forums/showthread.php?t=81307)

Switch 08-18-2008 02:30 AM

Reset GUI
 
Just a simple reset GUI I made.
This was what I needed help with for the random strings :p
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 = { 123456789};
  
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";
      
250;
      
250;
      
width 350;
      
height 250;
      
      new 
GuiMLTextCtrl("Reset_Info") {
        
profile GuiBlueMLTextProfile;
        
25;
        
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;
        
25;
        
170;
        
width 70;
        
height 20;
      }
      
      new 
GuiTextEditCtrl("Reset_Reason") {
        
profile GuiBlueTextEditProfile;
        
100;
        
170;
        
width 220;
        
height 20;
      }
      
      new 
GuiButtonCtrl("Reset_Button") {
        
profile GuiBlueButtonProfile;
        
100;
        
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 02:36 AM

Or you could just make them type their account name.

Tigairius 08-18-2008 03:02 AM

Quote:

Originally Posted by Switch (Post 1415375)
PHP Code:

      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:
PHP Code:

function onCreated() {
  
this.list = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  for (
temp.0temp.5temp.++) {
    
this.randomstr @= this.list.charat(int(random(0this.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 05:29 AM

Quote:

Originally Posted by Tigairius (Post 1415385)
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 06:08 AM

Nice script, but what's up with this:

PHP Code:

  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 09:08 AM

Quote:

Originally Posted by cbk1994 (Post 1415430)
Nice script, but what's up with this:

PHP Code:

  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 11:24 AM

Quote:

Originally Posted by xXziroXx (Post 1415440)
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 06:14 PM

PHP Code:

//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 = { 123456789};
  
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";
      
250;
      
250;
      
width 350;
      
height 250;
      
      new 
GuiMLTextCtrl("Reset_Info") {
        
profile GuiBlueMLTextProfile;
        
25;
        
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;
        
25;
        
170;
        
width 70;
        
height 20;
      }
      
      new 
GuiTextEditCtrl("Reset_Reason") {
        
profile GuiBlueTextEditProfile;
        
100;
        
170;
        
width 220;
        
height 20;
      }
      
      new 
GuiButtonCtrl("Reset_Button") {
        
profile GuiBlueButtonProfile;
        
100;
        
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 08:09 PM

Quote:

Originally Posted by TheStan (Post 1415540)
PHP Code:

//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 = { 123456789};
  
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";
      
250;
      
250;
      
width 350;
      
height 250;
      
      new 
GuiMLTextCtrl("Reset_Info") {
        
profile GuiBlueMLTextProfile;
        
25;
        
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;
        
25;
        
170;
        
width 70;
        
height 20;
      }
      
      new 
GuiTextEditCtrl("Reset_Reason") {
        
profile GuiBlueTextEditProfile;
        
100;
        
170;
        
width 220;
        
height 20;
      }
      
      new 
GuiButtonCtrl("Reset_Button") {
        
profile GuiBlueButtonProfile;
        
100;
        
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 08:15 PM

PHP Code:

this.confCode null

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

Switch 08-18-2008 11:37 PM

Quote:

Originally Posted by xXziroXx (Post 1415578)
PHP Code:

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-18-2008 11:40 PM

Quote:

Originally Posted by xXziroXx (Post 1415578)
PHP Code:

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-18-2008 11:53 PM

Quote:

Originally Posted by Crow (Post 1415672)
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:

PHP Code:

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 12:58 AM

Quote:

Originally Posted by xXziroXx (Post 1415674)
I'd rather do something like this:

Gratz! :fro:

Kristi 08-19-2008 01:04 AM

Quote:

Originally Posted by Dan (Post 1415688)
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 05:40 AM

Graal will not explode if you have a few pointless assignments here and there.

xXziroXx 08-19-2008 12:12 PM

Quote:

Originally Posted by Inverness (Post 1415743)
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 12: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 12:24 PM

Well, The Man has spoken, my opinion remains the same though.

Switch 08-19-2008 05:30 PM

Quote:

Originally Posted by stefan (Post 1415768)
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


All times are GMT +2. The time now is 02:43 AM.

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