mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
#125584 19/07/05 05:11 PM
Joined: Jun 2005
Posts: 47
M
Ameglian cow
OP Offline
Ameglian cow
M
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

#125585 19/07/05 05:22 PM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
//write textfilename.txt your text to write

#125586 19/07/05 05:55 PM
Joined: Jun 2005
Posts: 47
M
Ameglian cow
OP Offline
Ameglian cow
M
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.
#125587 19/07/05 06:19 PM
Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
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

#125588 19/07/05 06:48 PM
Joined: Jun 2005
Posts: 47
M
Ameglian cow
OP Offline
Ameglian cow
M
Joined: Jun 2005
Posts: 47
oh cool, and to delete ?
to see if text match i guess i can do:

Code:
if ($lines(file.txt) == $2) { User isn't in game }  right ? or line ?

Last edited by Matrix301; 19/07/05 06:49 PM.
#125589 19/07/05 06:56 PM
Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
/help $read

Quote:

//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

#125590 19/07/05 06:57 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
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
#125591 19/07/05 06:59 PM
Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
cool

#125592 19/07/05 07:01 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
You beat me!!! mad

LOL!! grin


Invision Support
#Invision on irc.irchighway.net
#125593 19/07/05 07:34 PM
Joined: Jun 2005
Posts: 47
M
Ameglian cow
OP Offline
Ameglian cow
M
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:

Code:
if ( $read(file.txt, w,  $3 ) {
blahblah
}


im not sure about this one, $3 is the username, -<game> register <user> <pass>

#125594 19/07/05 07:51 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
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:

Code:
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
#125595 19/07/05 09:04 PM
Joined: Jun 2005
Posts: 47
M
Ameglian cow
OP Offline
Ameglian cow
M
Joined: Jun 2005
Posts: 47
ew i cant get it to works, can you help me and look at my code plz ?:

Code:
########## Register

on *:TEXT:-tanklin register *:?: {
  if ( $lines(tanklinplayers.ini) &lt; %tanklinplayers &amp;&amp; $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) &lt; %tanklinplayers &amp;&amp; $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) &gt;= %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.
#125596 19/07/05 11:43 PM
Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
if you want to use an .ini file, try this out
Code:
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 &lt;= %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 &gt; %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

#125597 20/07/05 12:07 AM
Joined: Jun 2005
Posts: 47
M
Ameglian cow
OP Offline
Ameglian cow
M
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.
#125598 20/07/05 01:54 AM
Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
Code:
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 &lt;= %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 &gt; %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 &lt;= %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

#125599 20/07/05 04:30 AM
Joined: Jun 2005
Posts: 47
M
Ameglian cow
OP Offline
Ameglian cow
M
Joined: Jun 2005
Posts: 47
alright, but i need 2 more thing, i used:

########## Player Lists

Code:
on *:TEXT:-tanklin list:?: {
  var %inicount = $ini(tanklinplayers.ini,players,0)
  var %i = 1, %users
  while (%i &lt;= %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:

Code:
########## Lists

on *:TEXT:-tanklin list:?: {
  var %inicount = $ini(tanklinplayers.ini,players,0)
  var %i = 1, %users
  while (%i &lt;= %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.
#125600 20/07/05 05:13 AM
Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
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.
Quote:

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

#125601 20/07/05 06:23 AM
Joined: Jun 2005
Posts: 47
M
Ameglian cow
OP Offline
Ameglian cow
M
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

#125602 20/07/05 12:37 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Try:
on *:TEXT:-tanklin unregister &:?: {


Invision Support
#Invision on irc.irchighway.net
#125603 20/07/05 02:47 PM
Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
yup
Code:
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 &lt;= %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 &gt; %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 &lt;= %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
}

Page 1 of 2 1 2

Link Copied to Clipboard