|
Joined: Jun 2005
Posts: 47
Ameglian cow
|
OP
Ameglian cow
Joined: Jun 2005
Posts: 47 |
hey, hmm im trying to make register command where people can register for a tournament by typing command, -register <user> <nick> but i cant use variables since there will be 16 to 32 registration per tournament, i dont want too much elseif, i thought i could save it to a text file, which i can read too on -list players and read how many lines are in the text file so if there is 16 or 32 players registered, it says, error tournament full, hmm neway, the problem is that i dont know how to save to a text file, or i could save it into another user lsit ? can we have more than 1 user lsit ? eh ty for your help/idea
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
//write textfilename.txt your text to write
|
|
|
|
Joined: Jun 2005
Posts: 47
Ameglian cow
|
OP
Ameglian cow
Joined: Jun 2005
Posts: 47 |
ok, thx it works fine, but can i read and delete from this file ? so i can list and make he 16 or 32 players limit (you receive an error if there is 16 or 32 lines in the txt file
Last edited by Matrix301; 19/07/05 05:56 PM.
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
if ($lines(file.txt) < 16) { write to file stuff } else msg #gamechan game is full $nick please wait for an opening
|
|
|
|
Joined: Jun 2005
Posts: 47
Ameglian cow
|
OP
Ameglian cow
Joined: Jun 2005
Posts: 47 |
oh cool, and to delete ? to see if text match i guess i can do:
if ($lines(file.txt) == $2) { User isn't in game } right ? or line ?
Last edited by Matrix301; 19/07/05 06:49 PM.
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
/help $read //echo $read(info.txt, s, mirc)
Scans the file info.txt for a line beginning with the word mirc and returns the text following the match value.
$readn Returns the line number that was matched in a previous call to $read(). If no match was found, $readn is set to zero.
you might also consider using an ini file so you can track a user and their score, a little more complicated maybe, but more usefull overall /help writeini /help $readini /help $ini
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
READ: $read(file.txt,s,nick) $read(file.txt,w,*nick*)
/help $read
DELETE: /write -dl# file.txt
/help /write
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
You beat me!!! LOL!!
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Jun 2005
Posts: 47
Ameglian cow
|
OP
Ameglian cow
Joined: Jun 2005
Posts: 47 |
oh ok, i tried to use help but couldnt find it :P thx now i know more but eh i still got a problem, when someone register, i want it to check if user is already registered, if yes then it says user is already registered, so i should use:
if ( $read(file.txt, w, $3 ) {
blahblah
}
im not sure about this one, $3 is the username, -<game> register <user> <pass>
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
First of all, "w" is for a wildcard search, so you need wildcards in the search parameters. If you don't want a wildcard search, use "s" instead, as the help file shows. If your text file starts with the nick and then a space and $3 == the nick, you can use:
if ($read(file.txt,s,$3 $+ $chr(32)) {
do whatever
}
Note that I include the space -- $chr(32) -- in that because otherwise it will run into problems with two nicks that are similar (such as Super and Superman... if you look for Super, and Superman is first in the text file, it would stop there... with the space, it won't stop at the wrong one).
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Jun 2005
Posts: 47
Ameglian cow
|
OP
Ameglian cow
Joined: Jun 2005
Posts: 47 |
ew i cant get it to works, can you help me and look at my code plz ?:
########## Register
on *:TEXT:-tanklin register *:?: {
if ( $lines(tanklinplayers.ini) < %tanklinplayers && $read(tanklinplayers.ini,s,$3 $+ $chr(32) $+ $4) {
write tanklinplayers.ini $3 $+ $chr(32) $+ $4
msg $nick 0,1[14««7« 7R0egistration 7S0uccessful ! 7U0ser:7 $3 7P0assword:7 $4 7»14»»0]
}
elseif ( $lines(tanklinplayers.ini) < %tanklinplayers && $cantread(tanklinplayers.ini,s,$3 $+ $chr(32) $+ $4) { ;i want this check if user is already in list
msg $nick 0,1[14««7« 0You already registered ! 7»14»»0]
}
elseif ( $lines(tanklinplayers.ini) >= %tanklinplayers ) {
msg $nick 0,1[14««7« 0Sorry, the tournament is full ! 7»14»»0]
}
}
%tanklinplayers is a variable to set the number of players in tournament (16 or 32) tanklinplayers.ini is my players file (i asked for to save for a file but .ini looked sexier lmao $3 and $4 are <user> and <pass> need pass to avoid being unregistered by someone else without authorization
Last edited by Matrix301; 19/07/05 09:06 PM.
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
if you want to use an .ini file, try this out
on *:TEXT:-tanklin register *:?: {
if ($isfile(tanklinplayers.ini) == $false) { write -c tanklinplayers.ini }
if ($readini(tanklinplayers.ini,players,$nick)) {
msg $nick 0,1[14««7« 0You already registered ! 7»14»»0]
halt
}
var %inicount = $ini(tanklinplayers.ini,players,0)
if (%inicount <= %tanklinplayers) {
if ($readini(tanklinplayers.ini,players,$nick) == $null) {
writeini tanklinplayers.ini players $nick $3
msg $nick 0,1[14««7« 7R0egistration 7S0uccessful ! 7U0ser:7 $nick 7P0assword:7 $3 7»14»»0]
}
}
if (%inicount > %tanklinplayers) {
msg $nick 0,1[14««7« 0Sorry, the tournament is full ! 7»14»»0]
}
}
the user would msg you with -tanklin register <password>the script picks up their nick so they dont have to post that
|
|
|
|
Joined: Jun 2005
Posts: 47
Ameglian cow
|
OP
Ameglian cow
Joined: Jun 2005
Posts: 47 |
oh cool i guess ini are better :P it works fine, your the pro lol, now i have a question i hope it wont scrap it all, i want to list all the user in the tournament, the command ist -list, can i list only user in the .ini file or it will list the password too ? :s
i also need -tanklin unregister <pass> ;it need to verify password, if true then it remove, otherwise then Bad password, im working on this one but not sure if i should wait becuz of list.. if you still there, help would be appreciated :P im kinda a noob, and i never scripted using files and all so im a lil loss but i learn alot :P
Edit: Ok I got the unregister thing working but I don't have any idea on how to see if password match.. im looking how i could list the file but i think i will have problems listing user only without password
Last edited by Matrix301; 20/07/05 01:47 AM.
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
on *:TEXT:-tanklin register *:?: {
if ($isfile(tanklinplayers.ini) == $false) { write -c tanklinplayers.ini }
if ($readini(tanklinplayers.ini,players,$nick)) {
msg $nick 0,1[14««7« 0You already registered ! 7»14»»0]
halt
}
var %inicount = $ini(tanklinplayers.ini,players,0)
if (%inicount <= %tanklinplayers) {
if ($readini(tanklinplayers.ini,players,$nick) == $null) {
writeini tanklinplayers.ini players $nick $3
msg $nick 0,1[14««7« 7R0egistration 7S0uccessful ! 7U0ser:7 $nick 7P0assword:7 $3 7»14»»0]
}
}
if (%inicount > %tanklinplayers) {
msg $nick 0,1[14««7« 0Sorry, the tournament is full ! 7»14»»0]
}
}
on *:TEXT:-list:#: {
var %inicount = $ini(tanklinplayers.ini,players,0)
var %i = 1, %users
while (%i <= %inicount) {
var %users = %users $ini(tanklinplayers.ini,players,%i)
inc %i
}
msg $chan Current Players: %users
}
on *:TEXT:-tanklin unregister *:?: {
var %checkID = $readini(tanklinplayers.ini,players,$nick)
if (%checkID == $3) {
remini tanklinplayers.ini players $nick
msg $nick Your Nick $+(",$nick,") has been removed from the players list.
}
else {
msg $nick 04,01 ERROR! Your password does not match entry for $nick $+ ! Unregister denied!
}
}
try that
|
|
|
|
Joined: Jun 2005
Posts: 47
Ameglian cow
|
OP
Ameglian cow
Joined: Jun 2005
Posts: 47 |
alright, but i need 2 more thing, i used: ########## Player Lists
on *:TEXT:-tanklin list:?: {
var %inicount = $ini(tanklinplayers.ini,players,0)
var %i = 1, %users
while (%i <= %inicount) {
var %users = %users $ini(tanklinplayers.ini,players,%i)
inc %i
}
msg #contests 0,1[14««7« 7T0anklin 7P0layers 7L0ist (7 $lines(tanklinplayers.ini) 0) 7»14»»0]
msg #contests %users
msg #contests 0,1[14««7« 7E0nd 7o0f 7P0layers 7L0ist 7»14»»0]
}
i used: $lines(tanklinplayers.ini) to show how many lines are in the files (so how many user but with the [player] it add an extra line, is there anyway to substract 1 to the number eh or make a count without [player] also, i need a message that say: you aren't registered if user try to unregister when not in the list Edit: oh nice i fixed teh total user in the list by changing the code to the following:
########## Lists
on *:TEXT:-tanklin list:?: {
var %inicount = $ini(tanklinplayers.ini,players,0)
var %i = 1, %users
while (%i <= %inicount) {
var %users = %users $ini(tanklinplayers.ini,players,%i)
inc %i
[color:red] var %totaltanklinplayers = $lines(tanklinplayers.ini)
dec %totaltanklinplayers 1[/color]
}
msg #contests 0,1[14««7« 7T0anklin 7P0layers 7L0ist[color:red] (7 %totaltanklinplayers 0)[/color] 7»14»»0]
msg #contests %users
msg #contests 0,1[14««7« 7E0nd 7o0f 7P0layers 7L0ist 7»14»»0]
}
this post is getting LONG and the thread too lol, ew neway, im checking for the message that say user isnt registered thx to everybody who tooks few mins of their time to help me ! its really appreciated
Last edited by Matrix301; 20/07/05 04:45 AM.
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
$lines isn't the right way to do it. //say $ini(tanklinplayers.ini,players,0) $lines is counting the [topic] line as well and is why you got 1 more thanthere are users you may want to use the ini to do more later and as other data is stored in it $lines would be increasing while the actual user count may not. also, i need a message that say: you aren't registered if user try to unregister when not in the list
take some time to look at the code and read the help file. /help $readini
|
|
|
|
Joined: Jun 2005
Posts: 47
Ameglian cow
|
OP
Ameglian cow
Joined: Jun 2005
Posts: 47 |
hehe i know, but i made a var for the total user, and i just did dec 1, so it get the right number :P it works fine, everything works fine now except the unregistration, i fixed the thing to say not register but if someone type: -tanklin unregister (a space after unregister) it says unregister user but it doesnt becuz it dont exist eh :P
also, i was wondering, when i list, it list user like this:
User1, User2, User 3
is there anyway to list them like this: User1 User2 User3
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
Try: on *:TEXT:-tanklin unregister &:?: {
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
yup
on *:TEXT:-tanklin register *:?: {
if ($isfile(tanklinplayers.ini) == $false) { write -c tanklinplayers.ini }
if ($readini(tanklinplayers.ini,players,$nick)) {
msg $nick 0,1[14««7« 0You already registered ! 7»14»»0]
halt
}
var %inicount = $ini(tanklinplayers.ini,players,0)
if (%inicount <= %tanklinplayers) {
if ($readini(tanklinplayers.ini,players,$nick) == $null) {
writeini tanklinplayers.ini players $nick $3
msg $nick 0,1[14««7« 7R0egistration 7S0uccessful ! 7U0ser:7 $nick 7P0assword:7 $3 7»14»»0]
}
}
if (%inicount > %tanklinplayers) {
msg $nick 0,1[14««7« 0Sorry, the tournament is full ! 7»14»»0]
}
close -m $nick
}
on *:TEXT:-tanklin unregister *:?: {
var %checkID = $readini(tanklinplayers.ini,players,$nick)
if (%checkID == $null) {
msg $nick 04,01 ERROR! $+(",$nick,") Not in database.
halt
}
if (%checkID == $3) {
remini tanklinplayers.ini players $nick
msg $nick Your Nick $+(",$nick,") has been removed from the players list.
}
else {
msg $nick 04,01 ERROR! Your password does not match entry for $nick $+ ! Unregister denied!
}
close -m $nick
}
on *:TEXT:-list:#: {
write -c tanklinplayers.txt
write tanklinplayers.txt 0,1[14««7« 7T0anklin 7P0layers 7L0ist (7 $ini(tanklinplayers.ini,players,0) 0) 7»14»»0]
var %inicount = $ini(tanklinplayers.ini,players,0)
var %i = 1, %users
while (%i <= %inicount) {
write tanklinplayers.txt $ini(tanklinplayers.ini,players,%i)
inc %i
}
write tanklinplayers.txt 0,1[14««7« 7E0nd 7o0f 7P0layers 7L0ist 7»14»»0]
.play # tanklinplayers.txt
}
|
|
|
|
|