This is a bulky but relatively simple script that uses hash tables to allow your users to register with you and then create a simple profile that includes their name, age, sex, and a place to put "personal information" or whatever you want to change that to. It has numerous things to insure that the data types for each field are correct (you can only enter numbers as your age, etc)
You will need to place this in its own script file if you already have an on Start or on Exit event.
Also includes the command /pinfo that will show you all of the specified nick's profile information, as well as their password and place it in a minimized @ window.
Note: When you want a space in the personal info field, use _'s. They will be evaluated into spaces later.
Commands: /ctcp YOURNICK register {password} registers account
/ctcp YOURNICK login {password} logs you in
!profile {set|nick} {name} [age] [sex] [info] sets your profile info or looks up profile info for another user.
on *:START: {
hload Accounts Accounts.dat
hload Info Info.dat
hmake Logins 100
}
on *:EXIT: {
hsave -o Accounts Accounts.dat
hfree Accounts
hsave -o Info Info.dat
hfree Info
}
ctcp *:LOGIN: {
if ( !$2 ) {
ctcpreply $nick LOGIN Failed
notice $nick Syntax: /ctcp $me LOGIN <password>
halt
}
if ( $2 != $hget(Accounts,$nick) ) {
ctcpreply $nick LOGIN Failed
notice $nick You do not have an account, or you put an invalid password
halt
}
hadd Logins $nick True
ctcpreply $nick LOGIN Accepted
notice $nick You are now logged in.
}
ctcp *:register: {
if ( $hget(Accounts,$nick) != $null ) {
notice $nick You are already registered!
halt
}
if ( $hget(Accounts,Exists) == $null ) {
hmake Accounts 50
hmake Info 100
hmake Logins 20
hadd Accounts Exists True
hadd Logins $nick True
}
if ( !$2 ) {
notice $nick Syntax: REGISTER <password>
halt
}
if ( $2 !isalnum ) {
notice $nick Your password can only contain alphanumeric keys
halt
}
hadd Accounts $nick $2
msg $chan Account Created!
notice $nick Your password is $2
}
on *:TEXT:!profile*:#happy: {
if ( !$2 ) {
msg $chan Syntax: !profile <set|nick> <name|nick> [age] [sex] [info]
halt
}
if ( $2 == set ) {
if ( $hget(Logins,$nick) != True ) {
msg $chan You are not logged in!
halt
}
if ( !$3 ) {
msg $chan Syntax: !profile <set|nick> <name> [age] [sex] [info]
halt
}
if ( $3 !isalpha ) {
msg $chan Your name entry can contain only alphabetical keys!
halt
}
if ( $4 !isnum ) {
msg $chan Your age entry can contain only numeric keys!
halt
}
if ( $5 != m ) && ( $5 != f ) {
msg $chan Your sex entry must be either M or F!
halt
}
if ( $7 != $null ) {
msg $chan Your personal interests field cannot have spaces; use _'s instead
halt
}
hadd Info $nick $+ _ $+ name $3
hadd Info $nick $+ _ $+ age $4
hadd Info $nick $+ _ $+ sex $upper($5)
hadd Info $nick $+ _ $+ nfo $6
msg $chan Successfully updated profile!
halt
}
else {
if ( !$hget(Info,$2 $+ _ $+ name) ) {
msg $chan $2 is not registered or has not entered info for his/her profile!
halt
}
msg $chan Info for $2 $+ : NAME= $+ $hget(Info,$2 $+ _ $+ name) AGE= $+ $hget(Info,$2 $+ _ $+ age) SEX= $+ $hget(Info,$2 $+ _ $+ sex) INFO: $replace($hget(Info,$2 $+ _ $+ nfo),$chr(95),$chr(32))
}
}
alias pinfo {
if ( !$1 ) {
echo $colour(info) -a * SYNTAX: /info <nick>
halt
}
if ( !$hget(Accounts,$1) ) {
echo $colour(info) -a * $1 No Such Account
halt
}
var %w = @Info: $+ $1
window -nd %w
aline %w $1 PASSWORD: $hget(Accounts,$1)
aline %w $1 NAME: $hget(Info,$1 $+ _ $+ name)
aline %w $1 AGE: $hget(Info,$1 $+ _ $+ age)
aline %w $1 SEX: $hget(Info,$1 $+ _ $+ sex)
aline %w -
aline %w $1 Personal Info: $hget(Info,$1 $+ _ $+ nfo)
}
huh? I did remake them on start and save them on exit...what are you talking about darthreven. And yoinx, yeah, I\'ll remake it to have the register command in CTCP; wasn\'t thinking at the time. And I know I could do it with one hash table, I just get confused and it doesn\'t really slow anything down or anything having 2 so yeah...