mIRC Homepage
Posted By: Bundy passcode generator - 01/01/07 04:31 PM
I'm not sure how to do this. I want to get a var passcode every 10 minutes - 12 characters.
The user has to type the password in order to go on with what he/she is doing.

Passcode: H6f8e4A5d2P7 Passcode change in 6:23
Posted By: Riamus2 Re: passcode generator - 01/01/07 06:09 PM
Code:
on *:text:!pass *:?: {
  set %password. $+ $nick $2-
  .timerPassword. $+ $nick 600 ResetPass $nick
}

alias ResetPass {
  unset %password. $+ $1
  .notice $1 You need to enter a new password.  Type /msg $me !pass yourpassword
}


Then, you just want to check -

Code:
if ($($+(%,password.,$nick),2)) { allow stuff to be done }


To display the time remaining, you can use:

Code:
echo -a $timer(Password. $+ $nick).secs
Posted By: Bundy Re: passcode generator - 02/01/07 07:28 AM
Thanks Riamus2, let me explain it a bit better.

I want to get a random passcode every 10 minutes - 12 characters (see example)
The user has to type the password in order to go on with what he/she is doing. - The passcode will be shown somewhere els on the page (all of this is happening in a dcc window)

Passcode: H6f8e4A5d2P7 Passcode change in 6:23

<bot> Please enter passcode now in order to proceed.
<bundy> H6f8e4A5d2P7
<bot> You may proceed.
If incorrect
<bot> Passcode incorrect, please try again.

If the passcode is incorrect, a notice get send out to #mychannel.

It's a game script, and I want it to get halted until passcode is typed - and restored after that.

Thanx a mil!

laugh crazy frown

Posted By: CakerX Re: passcode generator - 02/01/07 01:07 PM
Quote:

I want to get a random passcode every 10 minutes - 12 characters (see example)


this doesn't sound too hard, mind you, you'd probably want to add this to a hash table, but I am going to use variables for simplicities sake.

Code:
alias /auth.code timer -o 0 600 password.change

alias -l password.change {
 var %text
 var %i 1
 var %length 12
 while ( %i <= %length ) {
  %text = %text $+ $chr( $rand(48,122) )
  inc %i 1
 }
 set %authcode %text
}

on *:text:!authcode*:?:{
 if ( $2- == %authcode ) {
  msg $nick You may proceed
  <enter whatever game interface you have here>
 }
 else { msg $nick Passcode incorrect, please try again. }
}


that would include the printable -[],./s the the code,

in a private message, this command works as follows:

<CakerX> !authcode H6f8e4A5d2P7
<bot> You may proceed

incorrect passcode
<bot> Passcode incorrect, please try again
Posted By: Bundy Re: passcode generator - 02/01/07 03:18 PM
Thanx smile - although I think it's not doing exactly what I want. Every 10 minutes it has to halt all process - then give you this.
(All of this happens in a DCC window already open)

<bot> -
<bot> In order to go on with the game please type passcode <code>
<bot> -
<bot> Passcode: H6f8e4A5d2P7
<bot> -
<bot> New Passcode in approx 6:20 mins.
<bot> -
<Bundy> passcode 6j8W9f5L1y3E
<bot> -
<bot> Incorrect Passcode, please try again.

[a warning notice get send to #opschannel - Bundy entered incorrect passcode 6j8W9f5L1y3E]

<bot> -
<bot> In order to go on with the game please type passcode <code>
<bot> -
<bot> Passcode: H6f8e4A5d2P7
<bot> -
<bot> New Passcode in approx 5:47 mins.
<bot> -
<Bundy> passcode H6f8e4A5d2P7
<bot> -
<bot> Thank you for playing. You may proceed.

[a notice get send to #opschannel - Bundy entered correct passcode 6j8W9f5L1y3E in 5mins and 35secs] (Time that it took Bundy to give the passcode)

All other processes get active again.

- If one types anything else during this process you will only get:

<bot> -
<bot> In order to go on with the game please type passcode <code>
<bot> -
<bot> Passcode: H6f8e4A5d2P7
<bot> -
<bot> New Passcode in approx 5:47 mins.
<bot> -

Many thanks!!

Regards,

b


Posted By: Riamus2 Re: passcode generator - 02/01/07 10:50 PM
I think I would put all of the rest of your game script inside a group.
Code:
#ActivePass on
Your game script
#ActivePass end

#ActivePass off
Your password script
#ActivePass end


Then, have a timer that will /disable the ActivePass group after the time limit and send the message about the password. You'll also need it to start another timer to track the time it takes to type the correct password. When the correct password is done, /enable ActivePass to let the game continue.

Alternately, you can just set a variable and check that variable everywhere in your game script that has input from the user. If the variable is set, then the input is accepted, if it's unset, then the password is asked.
© mIRC Discussion Forums