mIRC Homepage
Posted By: Gremel Random Slap Script - 19/01/05 05:54 AM
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.
Posted By: ricky_knuckles Re: Random Slap Script - 19/01/05 05:59 AM
umm
you could either use $rand
or $read
if u use read youd have to give up on the hash idea
Posted By: Gremel Re: Random Slap Script - 19/01/05 06:01 AM
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?
Posted By: ricky_knuckles Re: Random Slap Script - 19/01/05 06:15 AM
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
Posted By: Gremel Re: Random Slap Script - 19/01/05 06:22 AM
Umm...that code produced the following effect:

* Gararion Gararion = "person to slap"
Posted By: ricky_knuckles Re: Random Slap Script - 19/01/05 06:31 AM
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
Posted By: Gremel Re: Random Slap Script - 19/01/05 06:34 AM
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
Posted By: ricky_knuckles Re: Random Slap Script - 19/01/05 06:36 AM
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
Posted By: Gremel Re: Random Slap Script - 19/01/05 06:39 AM
Could it be the file extension being .hsh? I have another hash table that I use and its file extension is .dat
Posted By: Gremel Re: Random Slap Script - 19/01/05 06:46 AM
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.
Posted By: ricky_knuckles Re: Random Slap Script - 19/01/05 06:50 AM
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
Posted By: Gremel Re: Random Slap Script - 19/01/05 06:52 AM
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
Posted By: ricky_knuckles Re: Random Slap Script - 19/01/05 06:56 AM
well given that i had this tutorial and started doing hash a few days ago i highly reccomend it
Posted By: Gremel Re: Random Slap Script - 19/01/05 06:58 AM
You wish me to send you a PM containing my email so you can send it to me?
Posted By: ricky_knuckles Re: Random Slap Script - 19/01/05 07:17 AM
sure
Posted By: FiberOPtics Re: Random Slap Script - 19/01/05 07:18 AM
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.
Posted By: Gremel Re: Random Slap Script - 19/01/05 07:23 AM
Ah, thanks very much! It worked.

But for my own information, what was the echo portion of the script for?
Posted By: FiberOPtics Re: Random Slap Script - 19/01/05 07:25 AM
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
Posted By: Gremel Re: Random Slap Script - 19/01/05 07:27 AM
Ah, that code is fine. Thanks again.
Posted By: ricky_knuckles Re: Random Slap Script - 19/01/05 07:31 AM
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
.
Posted By: ricky_knuckles Re: Random Slap Script - 19/01/05 07:33 AM
well he does have a semi functioning brain
i assumed he would work that out for himself
Posted By: Gremel Re: Random Slap Script - 19/01/05 07:36 AM
thanks
Posted By: ricky_knuckles Re: Random Slap Script - 19/01/05 07:37 AM
didnt know you could use $r
Posted By: ricky_knuckles Re: Random Slap Script - 19/01/05 07:38 AM
if u still want that tutorial let me know
or just wait till www.mirc.net is back up and go look for it there
i dont have the url
Posted By: FiberOPtics Re: Random Slap Script - 19/01/05 07:40 AM
Well you can use $r, but to be honest it's best for readability to use $rand, also $r is an old identifier, not mentioned in the help file anymore, it might be gone some day.

I only put it because I know what I'm doing (and I like shorter code), though perhaps I should start using $rand.

Greets
Posted By: Gremel Re: Random Slap Script - 20/01/05 05:36 AM
I switched it to $rand though, so no worries. Thanks once again.
Posted By: DaveC Re: Random Slap Script - 20/01/05 09:51 PM
Quote:
Well you can use $r, but to be honest it's best for readability to use $rand, also $r is an old identifier, not mentioned in the help file anymore, it might be gone some day.

I only put it because I know what I'm doing (and I like shorter code), though perhaps I should start using $rand.

Greets


Do u know if it just happned to br $r or if it might have been shortened on purpose to let you get the max out of a $($str($!r(...) $!+ $chr(32),N),2) ? Becuase thats where i first saw a $r used to build a 20 letter random text values
Posted By: FiberOPtics Re: Random Slap Script - 20/01/05 10:00 PM
I have no idea why it was added, only Khaled knows. The fact that it's shorter is probably the only reason for being added, and at the same time the reason for being depreciated. Since $r doesn't really indicate what the identifier does, in comparison with other built-in identifiers.

I looked in the full versions.txt, and the first mention of $r is:

24/10/95 - mIRC v3.72
24.Added $r(v1,v2) identifier, returns random number
or letter between v1 and v2.

The first mention of $rand is:

08/01/99 - mIRC v5.5
124.Fixed freeze bug in $rand().

It's very doubtful that Khaled will have read this thread, though perhaps if he does he can give us some more info smile

Greets
Posted By: DaveC Re: Random Slap Script - 21/01/05 12:30 AM
just wondered as I dont know of any other single letter identifiers, and this one would be something i could see used often in a $str
Posted By: FiberOPtics Re: Random Slap Script - 21/01/05 11:22 AM
Yeah exactly, it is handy in $str, I've used it often, and we both used it in that Generating thread.
© mIRC Discussion Forums