mIRC Home    About    Download    Register    News    Help

Print Thread
#135325 10/11/05 02:41 PM
Joined: Sep 2005
Posts: 53
C
Babel fish
OP Offline
Babel fish
C
Joined: Sep 2005
Posts: 53
I need a script that allows only 4 or less people to type !Enter and activate my script.
Code:
On *:TEXT:!Enter:#: {
  if ($exist("Naruto_RPG\,$nick,.stats,.txt") = $true(("Naruto_RPG\,$nick,.stats,.txt"))) {
    if ($nick isin (Naruto_RPG/Game.dat) {
      set %player1 $nick
      msg $chan $nick Has Entered The Arena
      mode $chan +v $nick
    }
    else { msg You Are Already In The Arena }
  }
}

Err, this doesnt work at all. But I need to set the %player1 to 4 according to who type it first, second, etc.
Code:
  if ($exist("Naruto_RPG\,$nick,.stats,.txt") = $true(("Naruto_RPG\,$nick,.stats,.txt"))) {

Doesnt work..... and I tried
Code:
if ($nick isin ("Naruto_RPG\,$nick,.stats,.txt"))

That didnt work.
The whole script is kinda messed up. If anyone can do it over for me I would be very thankful.

#135326 10/11/05 03:03 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Ok, first of all... for checking number of players, just use this in your code:
Code:
  if (%player.number == 4) { .notice $nick Maximum players reached.  Try again later. | return }
  inc %player.number


Be sure to unset %player.number or /dec it when you complete the game or a player leaves.

Second:

Code:
if ($exist("Naruto_RPG\,$nick,.stats,.txt") = $true(("Naruto_RPG\,$nick,.stats,.txt"))) {


Some errors are:

"Naruto_RPG\,$nick,.stats,.txt"

You cannot put things together like that without using $+ (you also don't need a comma between .stats and .txt):

$+(Naruto_RPG\,$nick,.stats.txt)

Next:
Code:
$true(("Naruto_RPG\,$nick,.stats,.txt")))


You need a space after $true. Also, you have an extra set of parentheses there for some reason. They don't hurt anything, but are not needed (and still use $+):

$true $+(Naruto_RPG\,$nick,.stats.txt))

So, your final line would look like:

Code:
if ($exist($+(Naruto_RPG\,$nick,.stats.txt)) = $true $+(Naruto_RPG\,$nick,.stats.txt)) {


Now, the only remaining problem with that is what is after the $true... Are you trying to set a variable with that data? Or what are you doing with it? If the file is there, then what are you trying to do? Perhaps you don't even mean to have that there at all?

Code:
if ($exist($+(Naruto_RPG\,$nick,.stats.txt)) = $true) {


That's probably what you mean.

For setting the player number:

set $+(%,player,%player.number) $nick

That requires that you set %player.number the way I mentioned at the beginning of this post.

Final output:
Code:
On *:TEXT:!Enter:#: {
  if ($exist($+(Naruto_RPG\,$nick,.stats.txt)) = $true) {
    if ($nick isin (Naruto_RPG/Game.dat) {
      if (%player.number == 4) { .notice $nick Maximum players reached.  Try again later. | return }
      inc %player.number
      set $+(%,player,%player.number) $nick
      msg $chan $nick Has Entered The Arena
      mode $chan +v $nick
    }
    else { msg You Are Already In The Arena }
  }
}


There is one final error, but until I know the format of game.dat, I can't give you the fix.

Code:
    if ($nick isin (Naruto_RPG/Game.dat) {


You can't use isin like that. Post how game.dat is formatted and we can fix that part.


Invision Support
#Invision on irc.irchighway.net
#135327 10/11/05 08:58 PM
Joined: Sep 2005
Posts: 53
C
Babel fish
OP Offline
Babel fish
C
Joined: Sep 2005
Posts: 53
When someone types !Start they register their nick in my Naruto_RPG\,$nick,.stats.txt . It also writes their nick in Game.dat - im trying to make it so If their nick is in the Game.dat then it voices them and sets them as player 1, 2 ,3 ,or 4.
Code:
if ($exist($+(Naruto_RPG\,$nick,.stats.txt)) = $true) {

Yea, thats what I meant.
-
Game Dat.
nick
other nick
another nick
etc.

#135328 10/11/05 09:38 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Use this:
Code:
if ($read(Naruto_RPG/Game.dat,nwt,$nick) != $null) {

That will search for a line that is exactly the same as $nick.


Oh, and one more fix... I missed it when editing what you had.

Change:
Code:
if ($exist($+(Naruto_RPG\,$nick,.stats.txt)) = $true) {


To:
Code:
if ($exist($+(Naruto_RPG\,$nick,.stats.txt)) == $true) {


Using a single = is acceptable, but could potentially cause problems, so it's better to use ==. smile


Invision Support
#Invision on irc.irchighway.net
#135329 10/11/05 09:55 PM
Joined: Sep 2005
Posts: 53
C
Babel fish
OP Offline
Babel fish
C
Joined: Sep 2005
Posts: 53
Im using ChanBot to test my script. When it says !Enter it doesnt work. This is the code after your help:
Code:
On *:TEXT:!Enter:#: {
  if ($exist($+(Naruto_RPG\,$nick,.stats.txt)) == $true) {
    if ($read(Naruto_RPG/Game.dat,nwt,$nick) != $null) {
      if (%player.number == 4) { .notice $nick Maximum players reached.  Try again later. | return }
      inc %player.number
      set $+(%,player,%player.number) $nick
      msg $chan $nick Has Entered The Arena
      mode $chan +v $nick
    }
    else { msg You Are Already In The Arena }
  }
}

I have ChanBot.stats in Naruto_RPG folder. And it says ChanBot on the first line of the Game.Dat - Should I try using some other kind of file such as ini or txt?

#135330 11/11/05 03:38 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Does it give any messages (any of the notice/msg that are in the script)? Or are there any error messages on the bot itself (usually in the status window)?

Btw, you should have ChanBot.stats.txt. I assume that's what you meant?


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard