mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2014
Posts: 79
N
Newbie Offline OP
Babel fish
OP Offline
Babel fish
N
Joined: Nov 2014
Posts: 79
I keep hearing that hash tables are a faster and more efficient way of storing information that does not need to be stored. However my question is whether a key can have multiple values or only one? From what I've seen you can only have one value per key meaning that I would have to make 2+ hash tables.

Code:
on *:TEXT:!bet *: {
  if ($2 isnum) {
     msg # /me To bet type --> !bet boss dinocoins <--
  }
  else {
     hmake $2 
     hadd $nick $3 
     msg # $nick has wagered $3 on boss $2.  
  }
}


So when someone types !bet (boss name) (points) it will make a hash table for that boss. But is it possible to make a key with several people instead of having to make a new hash table for every option?

Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
Yep, just use $gettok on the key wink

Joined: Nov 2014
Posts: 79
N
Newbie Offline OP
Babel fish
OP Offline
Babel fish
N
Joined: Nov 2014
Posts: 79
But the key can't have more than one item? For example, instead of what I have I want it to be

Code:
hmake bets
hadd bets $3 $nick 


Where $3 would be the boss. So in the end I would have one key $3 which is equal to multiple $nicks. Is that possible?

Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
Oops, I meant $gettok on the value/item :-p

Yeah, they cant hold more than 1 value, but a string is still just 1 value

Joined: Nov 2014
Posts: 79
N
Newbie Offline OP
Babel fish
OP Offline
Babel fish
N
Joined: Nov 2014
Posts: 79
Oh, so I would basically go,

Code:
var %included $hget(bets,boss_name)
$hadd bets %included $+ ,$nick
$gettok($hget(bets,boss_name),N,44)

Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
Your hadd line seems wrong. Something like this?

Code:
hadd bets $nick $2-
$gettok($hget(bets,$nick),N,32)

Joined: Nov 2014
Posts: 79
N
Newbie Offline OP
Babel fish
OP Offline
Babel fish
N
Joined: Nov 2014
Posts: 79
Ok, and the 32 simply means space if I remember correctly


Link Copied to Clipboard