Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-18-2008, 02:30 AM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Reset GUI

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 = { 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
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.

Last edited by Switch; 08-18-2008 at 05:28 AM..
Reply With Quote
  #2  
Old 08-18-2008, 02:36 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Or you could just make them type their account name.
__________________
Reply With Quote
  #3  
Old 08-18-2008, 03:02 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Quote:
Originally Posted by Switch View Post
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.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”

Last edited by Tigairius; 08-18-2008 at 03:16 AM..
Reply With Quote
  #4  
Old 08-18-2008, 05:29 AM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by Tigairius View Post
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.
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #5  
Old 08-18-2008, 06:08 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
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++
__________________
Reply With Quote
  #6  
Old 08-18-2008, 09:08 AM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by cbk1994 View Post
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.
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #7  
Old 08-18-2008, 11:24 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
Quote:
Originally Posted by xXziroXx View Post
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.
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #8  
Old 08-18-2008, 06:14 PM
TheStan TheStan is offline
Stan?
Join Date: May 2008
Location: U.S.
Posts: 100
TheStan is on a distinguished road
Send a message via AIM to TheStan Send a message via MSN to TheStan
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.
Reply With Quote
  #9  
Old 08-18-2008, 08:09 PM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by TheStan View Post
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...
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #10  
Old 08-18-2008, 08:15 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
PHP Code:
this.confCode null
Why are you setting a non-existant variable to NULL in onCreated()?
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #11  
Old 08-18-2008, 11:37 PM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by xXziroXx View Post
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?
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #12  
Old 08-18-2008, 11:40 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by xXziroXx View Post
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.
__________________
Reply With Quote
  #13  
Old 08-18-2008, 11:53 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by Crow View Post
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!

__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #14  
Old 08-19-2008, 12:58 AM
Dan Dan is offline
Daniel
Join Date: Oct 2007
Posts: 383
Dan is an unknown quantity at this point
Send a message via MSN to Dan
Quote:
Originally Posted by xXziroXx View Post
I'd rather do something like this:
Gratz!
__________________
Reply With Quote
  #15  
Old 08-19-2008, 01:04 AM
Kristi Kristi is offline
Bowie's Deciple
Kristi's Avatar
Join Date: Dec 2003
Location: Boston, MA
Posts: 748
Kristi has a spectacular aura aboutKristi has a spectacular aura about
Send a message via AIM to Kristi Send a message via MSN to Kristi
Quote:
Originally Posted by Dan View Post
Gratz!
I have a feeling this was sarcasm, but ziro's doesn't give the compiler something to interpret and create a pointless assignment.
__________________
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 12:46 AM.


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