mIRC Homepage
Posted By: spermis Points system with top5 - 27/02/07 08:31 PM
I need a snippet so a admin can type !addpoint nick 3 and it will add 3 points to a user.. also for !addpoint nick 2 and !addpoint nick 1 .. More i need !delpoint nick 3 !delpoint nick 2 and !delpoint nick 1 or !delpoint nick all - then it deletes all points.. also !delpoints - clears all points.. And when some user types !top5 it shows.

1. nick is 1/204 with 23 points(204 is number of total users that have any point)
2. nick is 2/204 with 22 points
3. nick is 3/204 with 21 points
4. nick is 4/204 with 20 points
5. nick is 5/204 with 19 points
Posted By: Kardafol Re: Points system with top5 - 27/02/07 08:33 PM
This isn't a script request forum. We help you making a script, we don't usually make them for you.
Try /help, /help if, /help set, /help on text. That should be enough to get you started.
Posted By: spermis Re: Points system with top5 - 27/02/07 11:26 PM
maybe you can say web page where i can request scripts? but i still hope someone will help here
Posted By: RusselB Re: Points system with top5 - 28/02/07 12:12 AM
The Hawkee website has a script request forum, however, it is best if you try to write the script yourself. The help file really is of help (unlike some I've seen).

Also please note that requests like yours have been done before, so you'd be smart to search the site and/or the internet (I suggest using Google) for scripts like yours.
Posted By: Riamus2 Re: Points system with top5 - 28/02/07 04:44 AM
Since I feel like being generous, here's a simple one for you.

Code:
on *:start: {
  hmake TopScores 100
  if ($isfile($scriptdir\topscores.hsh)) { hload TopScores $qt($scriptdir\topscores.hsh) }
}

on *:text:!addpoint & &:#: {
  if ($nick isop $chan && $3 isnum) {
    hadd TopScores $2 $calc($hget(TopScores,$2) + $3)
    .notice $nick Added $3 points to $2 $+ .
  }
  hsave TopScores $qt($scriptdir\topscores.hsh)
}

on *:text:!delpoint & &:#: {
  if ($nick isop $chan) {
    if ($3 isnum) {
      hadd TopScores $2 $iif($calc($hget(TopScores,$2) - $3) >= 0,$v1,0)
      .notice $nick Subtracted $3 points from $2 $+ .
    }
    elseif ($3 == all) {
      hadd TopScores $2 0
      .notice $nick Removed ALL points from $2 $+ .
    }
    hsave TopScores $qt($scriptdir\topscores.hsh)
  }
}

on *:text:!top5:#: {
  if (%Top5.fld) { return }
  set -u10 %Top5.fld On
  filter -ffcuten 2 32 hash.tmp
  var %cnt = 1
  while (%cnt <= 5) {
    var %data = $read(hash.tmp,%cnt)
    msg $chan $hget(TopScores,$gettok(%data,1,32)).item is 1/ $+ $hget(TopScores,0).item with $gettok(%data,2,32) points
    inc %cnt
  }
  .remove hash.tmp
}


This allows all ops or higher to use the add/del commands. If you want only admins to use it, you'll need to put them into your userlist and then make the script work from the userlist instead.

Keep in mind that 5 lines displayed all at once *could* get you flooded off the server. It's set up to not allow more than 1 Top5 display every 10 seconds (-u10), but just displaying the 5 may be too much on certain networks. Just try and you'll know.

I didn't bother adding error messages. It checks to prevent errors, but it won't tell the user that there was an error. If you want that and can't add it yourself, just say so and I or someone else will do it.
Posted By: spermis Re: Points system with top5 - 28/02/07 07:17 AM
when typing !top5 nothing happens.. i added 5 users with !addpoints nick points but still nothing happens.
Ok i got another script
Posted By: Riamus2 Re: Points system with top5 - 28/02/07 02:19 PM
Typo thanks to copying part from another script of mine...

Code:
on *:start: {
  hmake TopScores 100
  if ($isfile($scriptdir\topscores.hsh)) { hload TopScores $qt($scriptdir\topscores.hsh) }
}

on *:text:!addpoint & &:#: {
  if ($nick isop $chan && $3 isnum) {
    hadd TopScores $2 $calc($hget(TopScores,$2) + $3)
    .notice $nick Added $3 points to $2 $+ .
  }
  hsave TopScores $qt($scriptdir\topscores.hsh)
}

on *:text:!delpoint & &:#: {
  if ($nick isop $chan) {
    if ($3 isnum) {
      hadd TopScores $2 $iif($calc($hget(TopScores,$2) - $3) >= 0,$v1,0)
      .notice $nick Subtracted $3 points from $2 $+ .
    }
    elseif ($3 == all) {
      hadd TopScores $2 0
      .notice $nick Removed ALL points from $2 $+ .
    }
    hsave TopScores $qt($scriptdir\topscores.hsh)
  }
}

on *:text:!top5:#: {
  if (%Top5.fld) { return }
  set -u10 %Top5.fld On
  hsave TopScores hash.tmp
  filter -ffcuten 2 32 hash.tmp
  var %cnt = 1
  while (%cnt <= 5) {
    var %data = $read(hash.tmp,%cnt)
    msg $chan $hget(TopScores,$gettok(%data,1,32)).item is 1/ $+ $hget(TopScores,0).item with $gettok(%data,2,32) points
    inc %cnt
  }
  .remove hash.tmp
}
Posted By: spermis Re: Points system with top5 - 28/02/07 05:54 PM
still doesnt work
Posted By: DuXxXieJ Re: Points system with top5 - 28/02/07 06:06 PM
With my mIRC (i've tested it) it works.
Maybe you need to paste it in a new file, or maybe is your remote off? (/remote on)
Posted By: spermis Re: Points system with top5 - 28/02/07 07:16 PM
i pasted in new file, typed /remote on.. still dont work

i created a .mrc file and typed /load -rs points.mrc also. but dont work. it adds points and removes them but when i type top5 it just dont show..
Posted By: Riamus2 Re: Points system with top5 - 28/02/07 10:10 PM
Check for any error messages (status window and active). Even if it wasn't working correctly, you would still see something messaged to the channel. You *are* typing !top5 from somewhere other than the client running the script, right? I assume you are because you said the adding/subtracting works, but I have to ask.

If nothing else, put an ECHO line as the first line after the on TEXT in the !top5 part. Something simple, such as:

echo -a WORKS

Try the trigger (!top5) and see if it echoes. If it does, move the line down one line and test. Keep doing this until you don't get an echo. This will tell you where the problem is located.

And, just double check that you are in fact using the latest version I posted.

As another option, install a clean copy of mIRC in another folder and test it there. Then you can see if perhaps it's because of a conflict with another script that you have.
Posted By: LonDart Re: Points system with top5 - 28/02/07 10:38 PM
Using mIRC v6.16, I got an error msg /filter: invalid parameters

and just had to change
Code:
filter -ffcuten 2 32 hash.tmp

to
Code:
filter -ffcuten 2 32 hash.tmp hash.tmp


(I was curious about that, as Duxxie said it worked.)
Posted By: Riamus2 Re: Points system with top5 - 01/03/07 03:17 AM
You're right. I copy/pasted and yet somehow didn't copy that twice. frown
Posted By: spermis Re: Points system with top5 - 01/03/07 10:38 AM
I checked that im using last version about 5 times. now checking
filter -ffcuten 2 32 hash.tmp hash.tmp

EDIT:
YAY! Thanks. It works

EDIT2:
is 1/8 with 1000 points
nick is 1/8 with 998 points
nick2 is 1/8 with 997 points
nick3 is 1/8 with 996 points
is 1/8 with 995 points

See - it shows all 1/8 and first and last place dont show nick
Posted By: Riamus2 Re: Points system with top5 - 01/03/07 02:23 PM
Ok, figured it out now that I could test it. Sorry for the inconvenience.

Code:
on *:start: {
  hmake TopScores 100
  if ($isfile($scriptdir\topscores.hsh)) { hload TopScores $qt($scriptdir\topscores.hsh) }
}

on *:text:!addpoint & &:#: {
  if ($nick isop $chan && $3 isnum) {
    hadd TopScores $2 $calc($hget(TopScores,$2) + $3)
    .notice $nick Added $3 points to $2 $+ .
  }
  hsave TopScores $qt($scriptdir\topscores.hsh)
}

on *:text:!delpoint & &:#: {
  if ($nick isop $chan) {
    if ($3 isnum) {
      hadd TopScores $2 $iif($calc($hget(TopScores,$2) - $3) >= 0,$v1,0)
      .notice $nick Subtracted $3 points from $2 $+ .
    }
    elseif ($3 == all) {
      hadd TopScores $2 0
      .notice $nick Removed ALL points from $2 $+ .
    }
    hsave TopScores $qt($scriptdir\topscores.hsh)
  }
}

on *:text:!top5:#: {
  if (%Top5.fld) { return }
  set -u10 %Top5.fld On
  hsave -n TopScores hash.tmp
  filter -ffcuten 2 32 hash.tmp hash.tmp
  var %cnt = 1, %points
  var %total = $hget(TopScores,0).item
  while (%cnt <= %total) {
    inc %points $hget(TopScores,%cnt).data
    inc %cnt
  }
  var %cnt = 1
  while (%cnt <= 5) {
    var %data = $read(hash.tmp,%cnt)
    msg $chan $hget(TopScores,$gettok(%data,1,32)).item is 1/ $+ %points with $gettok(%data,2,32) points
    inc %cnt
  }
  .remove hash.tmp
}
Posted By: spermis Re: Points system with top5 - 01/03/07 03:11 PM
now it shows all places 1/9999 or 1/9900 but i have about 10 users added
Posted By: Riamus2 Re: Points system with top5 - 01/03/07 06:52 PM
Try removing the hash data as it's working fine here. Go into your script's folder and find TopScores.hsh and delete it. Then, either restart mIRC or else type:

/hfree TopScores
/hmake TopScores 100

Then add your people and scores and try the !top5 listing.

Also, make sure that you don't have the hash.tmp file in your mIRC folder.
Posted By: spermis Re: Points system with top5 - 01/03/07 07:43 PM
|| 21:42:32 || <@tram> riitmm is 1/1188 with 992 points
|| 21:42:32 || <@tram> hashdshd is 1/1188 with 93 points
|| 21:42:32 || <@tram> ahahs is 1/1188 with 92 points
|| 21:42:32 || <@tram> triljalja is 1/1188 with 9 points
|| 21:42:32 || <@tram> aahhs is 1/1188 with 2 points

dont showing place but at least it shows 992 on first place and 2 points on last
Posted By: Riamus2 Re: Points system with top5 - 01/03/07 08:26 PM
Oh, I see what you're saying. I have *no* idea why I didn't see that or why I did that. I hardcoded "1" as the rank. frown

Change:
Code:
    msg $chan $hget(TopScores,$gettok(%data,1,32)).item is 1/ $+ %points with $gettok(%data,2,32) points



To:
Code:
    msg $chan $hget(TopScores,$gettok(%data,1,32)).item is %cnt $+ / $+ %points with $gettok(%data,2,32) points

Posted By: LonDart Re: Points system with top5 - 01/03/07 08:30 PM
change
Code:
msg $chan $hget(TopScores,$gettok(%data,1,32)).item is 1/ $+ %points with $gettok(%data,2,32) points

back to
Code:
msg $chan $hget(TopScores,$gettok(%data,1,32)).item is 1/ $+ $hget(TopScores,0).item with $gettok(%data,2,32) points

Posted By: Riamus2 Re: Points system with top5 - 01/03/07 08:37 PM
Sheesh. I changed that because I "remembered" that it was the total points instead of the total users. I need to stop coding when I'm tired.

Here is the entire !top5 event that should be used:

Code:
on *:text:!top5:#: {
  if (%Top5.fld) { return }
  set -u10 %Top5.fld On
  hsave -n TopScores hash.tmp
  filter -ffcuten 2 32 hash.tmp hash.tmp
  var %cnt = 1
  while (%cnt <= 5) {
    var %data = $read(hash.tmp,%cnt)
    msg $chan $hget(TopScores,$gettok(%data,1,32)).item is %cnt $+ / $+ $hget(TopScores,0).item with $gettok(%data,2,32) points
    inc %cnt
  }
  .remove hash.tmp
}
Posted By: spermis Re: Points system with top5 - 01/03/07 09:24 PM
great. it works.. VERY big thx.
Posted By: spermis Re: Points system with top5 - 01/03/07 09:49 PM
oh yeah and the 11 line save line should be

hsave TopScores topscores.hsh - or it shows
* /hsave: insufficient parameters (line 11, top999.mrc
Posted By: Riamus2 Re: Points system with top5 - 02/03/07 02:42 AM
It shouldn't give an error, but if you're putting it all in your mIRC folder and not subfolders, then that's fine to do it that way.
Posted By: spermis Re: Points system with top5 - 02/03/07 08:15 AM
yes because i couldn find the scriptsdir.. and it was giving error then if scriptsdir was there
Posted By: Riamus2 Re: Points system with top5 - 02/03/07 02:07 PM
$scriptdir (available only from within a script file and not from the command line) is the path to where your script is saved. It's an internal mIRC identifier and shouldn't ever give errors. $scriptdir\TopScores.hsh just says to go to the script's location and find/save the hash table there. The $qt part puts quotes around it so you don't have issues with spaces in the path. So there is no reason that I can see for why it won't work.

It's fine to remove that and just save it in mIRC's main folder. Just remember to change ALL $scriptdir parts dealing with that filename (including the /hsave and /hload commands) or you'll have problems later on.
Posted By: hixxy Re: Points system with top5 - 02/03/07 06:10 PM
It would also give that error if $qt (which is a relatively new identifier) doesn't exist. To solve that, just add a local alias to the top of the script:

Code:
alias -l qt { return " $+ $1" }
Posted By: Riamus2 Re: Points system with top5 - 03/03/07 02:06 PM
Good point. I forgot that $qt was new. I should have just stuck with the old method of $+(",$scriptdir\TopScores.hsh") instead.
© mIRC Discussion Forums