mIRC Home    About    Download    Register    News    Help

Print Thread
#208950 01/02/09 01:18 PM
Joined: Feb 2009
Posts: 8
A
ahbb Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
A
Joined: Feb 2009
Posts: 8
Hi,

I wonder if some1 can help please, iv made a hash table script with the name s_hit.hsh.

I have a cmd that users use to add nicks to the shit list so that they can see who is shit makers in there channels. The adding work 100% but my problem comes in when i want the channel ops to see the all the entry's in the s_hit.hsh table.

I cant seem to get the coding right for that, all the info that i get off google is only for a single entry to search fore but not to see the whole list.

The cmd that the channel ops going to use to see the list must be !s_hitlist then it must show all the data in the ops channel?

I would be very greatful if I can get some help on this.

Thanks

Andrew

Last edited by ahbb; 01/02/09 01:19 PM.
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Code:
on *:text:!s_hitlist:*:{
  .hsave s_hit.hsh s_hit.hsh.tmp
  .play #ops_channel s_hit.hsh.tmp
}
on *:playend:{
  if $filename == s_hit.hsh.tmp {
    .remove s_hit.hsh.tmp
  }
}

You could also do this using a loop, but if there are a lot of entries, then the code could flood the channel or server.
Using a timer can get around the flooding problem, but then you can have a very long wait if you have a lot of entries.

Eg: If you had 1000 entries, most networks would kick you off for flooding since my experiments show about 1.5 seconds for 1000 entries (I tested this on a special network where I can not be kicked from the network).
Therefore 1000 lines in 1.5 seconds is far faster than most networks will allow.
Using a timer to get around this, makes the delay about 1000 seconds by the time you get to the last entry. That's 16 minutes 40 seconds from the 999th entry to the 1000th entry.
Far too long for most people to want to wait.

The code I have suggested, will show the information with a 1 second delay between messages.
Please change #ops_channel to the actual name of the channel, and ensure that your hash table is called s_hit.hsh

It is common for a scripter to use s_hit.hsh as the saved file name for a table called s_hit, so please double check this before using my code, as that will also have to be changed if it doesn't match.


Joined: Feb 2009
Posts: 8
A
ahbb Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
A
Joined: Feb 2009
Posts: 8
hi,

Thank you so much that coded of your work 100%, well if the lines get more and more then ill look @ the time that you said.

This is the code that iv put in for the ops to add to the database.

this is working fine i just wanted to know if it can be better coded or is it fine as is. Then how do i del it, if they want to del a enty?

Once again thanks for the help. laugh

on 500:text: !adds_hitlist *:#ops_only: {
/hadd s_hit.hsh $2 $2- ( added by $nick on $- $day $time $- $date )
/hsave s_hit.hsh s_hit.hsh
/msg #ops_only Ok $nick
}


Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
The code I provided you with will work equally well with 5 or 5,000,000 entries.
I was just mentioning that a loop and a timer can be used for smaller numbers.

As to your code, I would suggest changing
Code:
/hadd s_hit.hsh $2 $2- ( added by $nick on $- $day $time $- $date )
to
Code:
/hadd -m s_hit.hsh $2 $2- ( added by $nick on $- $day $time $- $date )


The -m switch allows items to be added to a hash table, even if the table hasn't been created using then /hmake command.
I usually put a /hmake into a ON START event, but use the -m switch as well, just to be safe.

For deleting an entry, you want to look at /hdel

/help /hdel

P.S.: Please remember to use code tags around code. The code tag button looks like the # character.

Last edited by RusselB; 01/02/09 05:40 PM.
Joined: Feb 2009
Posts: 8
A
ahbb Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
A
Joined: Feb 2009
Posts: 8
Russel,

i want to thank you for all your help, iv it's so little code but iv learnt alot.

just to let you know that the del function is working very nicely as well.

Thanks again.

Andrew

Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
if the table is named s_hit,

$hget(s_hit,0).item

This will give you the total number of items in the hash table. Then you can use a while loop to go through and list each item's data.

I'm not saying Russel's isn't a good idea, I'm just trying to answer your question.


Link Copied to Clipboard