mIRC Home    About    Download    Register    News    Help

Print Thread
#49823 17/09/03 03:56 AM
Joined: Aug 2003
Posts: 136
M
Vogon poet
OP Offline
Vogon poet
M
Joined: Aug 2003
Posts: 136
I wrote a cheap lil high low game and I am trying to include points. It seems the best and easiest way is to use hash tables, Yet I never can get them to work would I simply
/hmake -s points 10
then I know i would /hadd but thats where i get comfused, I know then to add points /hinc, but how would I tell if the that nick is already added or not?

#49824 17/09/03 04:00 AM
Joined: Jan 2003
Posts: 2,973
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Jan 2003
Posts: 2,973
Short answer is i believe mirc creates a new hash entry if it doesnt exists when you use /hadd, just as /inc or /dec would create a new variable when used.

I have a simple .rtf (wordpad) tutorial on hash tables if youd like it. Just PM me, and we can work something out laugh

#49825 17/09/03 04:26 AM
N
Naz
Naz
N
Yes, hadd and hinc will create the entry if it does not already exist.
If an entry does exist, hadd will overwrite the existing info with the new info.

#49826 17/09/03 05:24 AM
Joined: Feb 2003
Posts: 2,737
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,737
For my "hilo game" I simply save scores to a text file, and /play the last 5 winners or the top 5 scores (last 5 people to guess it in 1 guess).

For something as low volume as this, I think the effort of hash tables would be unnecessary.

You can play my version at EFNet #botsex


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
#49827 17/09/03 05:28 AM
Joined: Aug 2003
Posts: 136
M
Vogon poet
OP Offline
Vogon poet
M
Joined: Aug 2003
Posts: 136
This is what I have so far, it is storing the scores and adding, but I get retrive, Ive tried everything I can find in tutorials,
Code:
 on 1:text:*:#usa: {
  if $1 !isnum { halt }
  {
    elseif ($1 == %rand) {
      msg #usa $nick guessed right, the random number was4 %rand 
      /hinc -m points $nick
      /hsave -o points points.hsh
      set %rand $rand(0,100)
    }
    {
      elseif ($1 < %rand) msg #usa Guess higher $nick
      {
        elseif ($1 > %rand) msg #usa Guess lower $nick
      }
    }
  }
}
 

I have stat and exit parts to load and save
----------
Im trying hash tables, just for the reason I want to learn them fianlly.

#49828 17/09/03 12:30 PM
Joined: Jan 2003
Posts: 2,973
K
Hoopy frood
Offline
Hoopy frood
K
Joined: Jan 2003
Posts: 2,973
Code:
if $1 !isnum { halt }
{


needs to be

Code:
if $1 !isnum { halt }
[color:Red]else[/color] {


or

Code:
if ($1 isnum) {


Try not to have "useless" comparasins like

if (condition) halt

just do

if (!condition)


Link Copied to Clipboard