|
Joined: Jan 2007
Posts: 280
Fjord artisan
|
OP
Fjord artisan
Joined: Jan 2007
Posts: 280 |
Hi, a while ago I've requested on this forum board an login script, which works fine, but now I want to make other scripts ONLY work when they are logged in (within my login script). So, when I use the trigger ".totalscripts" it may only work when I am logged in. Here are the 2 scripts, the ".totalscripts" script, and the login script (which contains all the vars etc..) ON 1:TEXT:*:#:{
if $1 == .totalscripts {
msg $chan TOTAL SCRIPTS: $script(0)
}
} on *:text:*:?: {
if ($1 == .login) {
var %nick = $findtok(%admin,$nick,32)
if (%nick) {
if ($gettok(%admincode,%nick,164) == $2-) {
if ($gettok(%adminstatus,%nick,32) == Off) {
msg $nick LOGIN: You are now logged in as $nick $+ .
set %adminstatus $puttok(%adminstatus,On,%nick,32)
}
else {
msg $nick LOGIN: You are already logged in.
}
}
else {
msg $nick LOGIN: Invalid password or nickname (your current nickname).
}
}
else {
msg $nick LOGIN: You aren't an admin or user.
}
}
elseif ($1 == .logout) {
var %nick = $findtok(%admin,$nick,32)
if (%nick) {
if ($gettok(%admincode,%nick,164) == $2-) {
if ($gettok(%adminstatus,%nick,32) == On) {
msg $nick LOGOUT: You are now logged out.
set %adminstatus $puttok(%adminstatus,Off,%nick,32)
}
else {
msg $nick LOGOUT: You aren't logged in.
}
}
else {
msg $nick LOGOUT: Invaled password or nickname (your current nickname)
}
}
else {
msg $nick LOGOUT: You aren't an admin or user.
}
}
elseif ($1 == .add-admin) {
if ($nick == %owner || $nick == %secondowner) {
if (!$3) { msg $nick ADD: Invalid format: .add-admin nick passcode | return }
var %nick = $findtok(%admin,$2,32)
if (%nick) {
msg $nick ADD: $2 is already added.
msg $nick ADD: $2's password is $gettok(%admincode,%nick,164) $+ .
return
}
else {
set %admin $instok(%admin,$2,0,32)
set %admincode $instok(%admincode,$3-,0,164)
set %adminstatus $instok(%adminstatus,Off,0,32)
msg $nick ADD: New admin named " $+ $2 $+ ".
msg $nick ADD: Password of $2 is $3- $+ .
}
}
else {
msg $nick ADD: You aren't my owner, or otherwise you aren't an admin or user
}
}
Squee whenever a squee squee's. Squee whenever a squee does not squee.
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
ON 1:TEXT:*:#:{
if ($gettok(%adminstatus,%nick,32) == On) {
if $1 == .totalscripts {
msg $chan TOTAL SCRIPTS: $script(0)
}
}
}
|
|
|
|
Joined: Mar 2009
Posts: 74
Babel fish
|
Babel fish
Joined: Mar 2009
Posts: 74 |
var %nick = $findtok(%admin,$nick,32) That line was used to give %nick a value. Because /var was used, the variable is local, and is deleted after any actions with in the login part of the script. With out adding that line, %nick will return as $null. $gettok(%adminstatus,$null,32) will result in an error message as a result. On 1:TEXT:*:#:{
var %nick = $findtok(%admin,$nick,32)
if ($gettok(%adminstatus,%nick,32) == On) {
if $1 == .totalscripts {
msg $chan TOTAL SCRIPTS: $script(0)
}
}
}
Last edited by KageNoOni; 21/08/09 04:56 AM.
|
|
|
|
Joined: Jan 2007
Posts: 280
Fjord artisan
|
OP
Fjord artisan
Joined: Jan 2007
Posts: 280 |
And if I'm not logged in, how do I add an else that it msg's me that I'm not logged in? EDIT: Both of them don't work
Last edited by DuXxXieJ; 21/08/09 11:01 AM.
Squee whenever a squee squee's. Squee whenever a squee does not squee.
|
|
|
|
Joined: Oct 2003
Posts: 3,918
Hoopy frood
|
Hoopy frood
Joined: Oct 2003
Posts: 3,918 |
How do you add an else?
Why, with an else, of course
/help /if should show you how if-then-else is structured, of course you have plenty of examples in the very code you pasted.
- argv[0] on EFnet #mIRC - "Life is a pointer to an integer without a cast"
|
|
|
|
Joined: Jul 2008
Posts: 236
Fjord artisan
|
Fjord artisan
Joined: Jul 2008
Posts: 236 |
The second code pasted may appear to "not work" because it will only trigger for channel messages. If the rest of your code works, then that will work. If your ".login" displays "You are already logged in", then you need to think about initialising %adminstatus because it might evaluate (return isn't quite the right word) to $null. In this case you're also likely to recieve "You aren't logged in" when you try to ".logout".
edit: read /help moar, and manually iterate over each branch putting "echo" code around the place if you want to debug it quickly.
Last edited by s00p; 03/09/09 11:25 AM.
|
|
|
|
|