mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
#108382 19/01/05 05:54 AM
Joined: Mar 2004
Posts: 96
G
Gremel Offline OP
Babel fish
OP Offline
Babel fish
G
Joined: Mar 2004
Posts: 96
I finally got my internet back up and running and was looking at a few scripts I was working on before I got D/C'ed. One was a Random slap script. What it looks like I have is a file called "slap.hsh" which is a hash table. Now this hash table has two types of information in it.

Under the numbers 1-9 there are single words like "slap, cuff, smack, etc". Under the letters A-L there is sentenances like "with a Volvo... that was clamped anyway so the driver doesn't mind."

Now want I was tryign to do was make a script that would allow me to type /slap2 <nick> and it will come up the below:

*Gremel <something from 1-9> <nick> <something from A-L>

Being away for a while, I got a little rusty and would appreaciate the help.

#108383 19/01/05 05:59 AM
Joined: Nov 2004
Posts: 332
R
Fjord artisan
Offline
Fjord artisan
R
Joined: Nov 2004
Posts: 332
umm
you could either use $rand
or $read
if u use read youd have to give up on the hash idea


The Kodokan will move you, one way or another.
#108384 19/01/05 06:01 AM
Joined: Mar 2004
Posts: 96
G
Gremel Offline OP
Babel fish
OP Offline
Babel fish
G
Joined: Mar 2004
Posts: 96
the script I have in my remote window that deals with it is the following:

Code:
 alias newslap {
  /me $hget(slap.hsh, $rand(1,9)) he
} 


As you can tell, its not complete. Could someone help me with this or show me another way of doing it?

#108385 19/01/05 06:15 AM
Joined: Nov 2004
Posts: 332
R
Fjord artisan
Offline
Fjord artisan
R
Joined: Nov 2004
Posts: 332
ill take a crack at it but dont hold it against me

Code:
 alias /slap {
var %first = $hget(slap, $rand(1,10))    
var %second = $hget(slap, $rand(a,z))
describe $chan %first $$?="the person you want to slap? %second $+ .
} 

you could probably do it without assigning them to variables i dont know why i did that i might test this if i have time
you could probably use $$1 rather than $$?.....
the $$? has been tested and does work

Last edited by ricky_knuckles; 19/01/05 06:32 AM.

The Kodokan will move you, one way or another.
#108386 19/01/05 06:22 AM
Joined: Mar 2004
Posts: 96
G
Gremel Offline OP
Babel fish
OP Offline
Babel fish
G
Joined: Mar 2004
Posts: 96
Umm...that code produced the following effect:

* Gararion Gararion = "person to slap"

#108387 19/01/05 06:31 AM
Joined: Nov 2004
Posts: 332
R
Fjord artisan
Offline
Fjord artisan
R
Joined: Nov 2004
Posts: 332
the reason is i misplaced the spacing it should be $$?=" The person you want to slap."
i also provided you a option should u not want the prompt


The Kodokan will move you, one way or another.
#108388 19/01/05 06:34 AM
Joined: Mar 2004
Posts: 96
G
Gremel Offline OP
Babel fish
OP Offline
Babel fish
G
Joined: Mar 2004
Posts: 96
It seems to not want to pull anythign from the hash table. All I get is when I enter Gar in the popup is:

* Gararion Gar

#108389 19/01/05 06:36 AM
Joined: Nov 2004
Posts: 332
R
Fjord artisan
Offline
Fjord artisan
R
Joined: Nov 2004
Posts: 332
sigh*
worked fine for me
must be your hash table
i can handle that for you too
if u need
course that will get into remotes


The Kodokan will move you, one way or another.
#108390 19/01/05 06:39 AM
Joined: Mar 2004
Posts: 96
G
Gremel Offline OP
Babel fish
OP Offline
Babel fish
G
Joined: Mar 2004
Posts: 96
Could it be the file extension being .hsh? I have another hash table that I use and its file extension is .dat

#108391 19/01/05 06:46 AM
Joined: Mar 2004
Posts: 96
G
Gremel Offline OP
Babel fish
OP Offline
Babel fish
G
Joined: Mar 2004
Posts: 96
Well, I was hoping to figure out Hash tables, but if you can do somethign for me in remotes, then feel free to do so, it would be somethign else I would be learnign anew.

#108392 19/01/05 06:50 AM
Joined: Nov 2004
Posts: 332
R
Fjord artisan
Offline
Fjord artisan
R
Joined: Nov 2004
Posts: 332
well i would show you to a tutorial
but mirc.net seems to be down for me
i can send u one if your feeling gutsy


The Kodokan will move you, one way or another.
#108393 19/01/05 06:52 AM
Joined: Mar 2004
Posts: 96
G
Gremel Offline OP
Babel fish
OP Offline
Babel fish
G
Joined: Mar 2004
Posts: 96
Actually, I find I learn very little from reading. I need to have soemthign and tear it apart to figure out how it works confused

#108394 19/01/05 06:56 AM
Joined: Nov 2004
Posts: 332
R
Fjord artisan
Offline
Fjord artisan
R
Joined: Nov 2004
Posts: 332
well given that i had this tutorial and started doing hash a few days ago i highly reccomend it

Last edited by ricky_knuckles; 19/01/05 06:56 AM.

The Kodokan will move you, one way or another.
#108395 19/01/05 06:58 AM
Joined: Mar 2004
Posts: 96
G
Gremel Offline OP
Babel fish
OP Offline
Babel fish
G
Joined: Mar 2004
Posts: 96
You wish me to send you a PM containing my email so you can send it to me?

#108396 19/01/05 07:17 AM
Joined: Nov 2004
Posts: 332
R
Fjord artisan
Offline
Fjord artisan
R
Joined: Nov 2004
Posts: 332
sure


The Kodokan will move you, one way or another.
#108397 19/01/05 07:18 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Quote:
alias newslap { /me $hget(slap.hsh, $rand(1,9)) he}

You seem to be confused about something. A file is not a hash table, it can on the other hand store one though. A hash table is stored in memory, but to be able to load it next time you need it, we store it in a file temporarily, until we load it in memory again.

So the only problem you are facing is: you havent loaded the contents of the file to the hash table yet, which makes it obvious why you don't get results.

Btw the extension .hsh has nothing to do with it, because that is a file, not a hash table. You can use any extension, or even omit it, it does not matter.

Note that you cannot use /me except from the command line.

So try the following, I'm assuming that the file slap.hsh is in your main mIRC folder.

Usage: /slap2 <nick>

alias slap2 {
if !$chan { echo -ac info * /slap2: must be on a channel }
else {
if !$hget(slap) { hmake slap | hload slap slap.hsh }
describe # $hget(slap, $r(1,9)) $$1 $hget(slap,$r(a,l))
}
}

@ricky, you put rand a-z while he only has a-l, and 1-10 while he only has 1-9.


Gone.
#108398 19/01/05 07:23 AM
Joined: Mar 2004
Posts: 96
G
Gremel Offline OP
Babel fish
OP Offline
Babel fish
G
Joined: Mar 2004
Posts: 96
Ah, thanks very much! It worked.

But for my own information, what was the echo portion of the script for?

#108399 19/01/05 07:25 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Well, you can describe to a channel and a nick, though I assumed you wanted it to do in a channel, right? If not let me know.

Basically the echo part is there to inform you that you must be on a channel, because the $chan identifier isn't filled, when you do /slap2 not from a channel.

Greets


Gone.
#108400 19/01/05 07:27 AM
Joined: Mar 2004
Posts: 96
G
Gremel Offline OP
Babel fish
OP Offline
Babel fish
G
Joined: Mar 2004
Posts: 96
Ah, that code is fine. Thanks again.

#108401 19/01/05 07:31 AM
Joined: Nov 2004
Posts: 332
R
Fjord artisan
Offline
Fjord artisan
R
Joined: Nov 2004
Posts: 332
okwell one more shot
im gonna to exactly recount what i did and let you take it from there
/hmake -s pimp 10
/hsave -so pimp pimp.hsh
/hadd -s pimp 1 assaults
/hadd -s pimp 2 violates
/hadd -s pimp 3 bludgeons
/hadd -s pimp 4 beats
/hadd -s pimp 5 pounds
/hadd -s pimp 6 cracks
/hadd -s pimp a fish
/hadd -s pimp b boot
/hadd -s pimp c hammer
/hadd -s pimp d crocodile
/hadd -s pimp e llama
/hadd -s pimp f cox
then in remote i put this

alias pimp {
var %pimp1 = $hget(pimp, $rand(1,5))
var %pimpa = $hget(pimp, $rand(a,e))
describe $chan %pimp1 $$1 %pimpa
}
then i typed /pimp pete
and just keeped reintering it getting various combinations of numbered and lettered entries
.


The Kodokan will move you, one way or another.
Page 1 of 2 1 2

Link Copied to Clipboard