Jump to content

Code Help


Dippy

Recommended Posts

Hello Can anyone help I have this piece of code but it seems to freeze up script and make it fall out alot

What do you think please Help :o)

 

raw 353:*:{
 var %looptext $remove($3-,:,',.,@,$chr(37),+)
 var %x $numtok(%looptext,32)
 while (%x) { whois $gettok(%looptext,%x,32) | dec %x }
}

 

 

Thanks :)

Link to comment
Share on other sites

This code would flood you out of a moderately full room.

 

A whois command makes the server send you several raw messages. So sending 10+ of these request to the server at the speed of a while loop will flood you out.

 

What about who $chan?

 

What information are you hoping to gather?

Link to comment
Share on other sites

I have been warned by many to always avoid any 'loop' commands. The script may not be able to keep up of the computer is older and maybe slow. The script will try and read, and not kep up and the actual PC will crash.

Again this is just an 'opinion' ans subject to bashing. ( though it can be "Googled" ).

:angry:

Link to comment
Share on other sites

while (%x)

use...

while (%x > 0)

Just for structure i guess. If not, if it's floods out, as in, if you get kicked off the server, it is because the use of /whois on ALL nicknames is causing you to flood the server. As in, you send too many commands to the server at once.

Edited by The Gate Keeper
Link to comment
Share on other sites

I have been warned by many to always avoid any 'loop' commands. The script may not be able to keep up of the computer is older and maybe slow. The script will try and read, and not kep up and the actual PC will crash.

Again this is just an 'opinion' ans subject to bashing. ( though it can be "Googled" ).

:angry:

 

*Attempts to Bash Wiley*

:offtopic:

 

No seriously, Im not trying to bash. Thinking about this issue I can't agree. Granted I haven't tested, BUT!!!

 

If I ask mirc to perform a while loop.

 

While (%x) {

if ($hget(table,%x)) { msg $chan Yayy!! }

dec %x

}

 

My computer is going to handle it as fast as it can. If I have a slow computer, then it will just be slower to go through this while loop. I don't see how it would miss anything.

 

Im looking at it on a step by step basis.

 

step 1: evaluate while and variable

step 2: variable = 5, evaulate comparison, run command if matches

step 3:dec %x, evaluate while loop. if %x > 0? if so continue, if not halt.

 

step4: evaluate comparison, run command if matches

step5:dec %x, evaluate while loop

 

step 6: evaluate comparison, run command if matches

step 7: dec %x evaluate while loop

 

etc.

 

See, mIRC is going to go through these steps one at a time. If your computer is slow, it is still going to go through each step, just slower. This is my opinion just going over the idea "logically".

 

 

"while (%x > 0)"

Yes David is correct, this would probably be more stable.

If the %x == 0, then !%x is true.

(This is why it may be best to say if (%x == $null) if dealing with numbers in the variable. Since !5x will be true if %x == 0)

 

I just wanted to be clear about using the while loop as such. Both ways are correct. David's suggestion would technically be more stable but not neccesary and I don't see that it would fix your issue with flooding out.

 

 

If you really want to whois everyone in the room with a while loop use timers. It gets a little tricky though. You may want to use a queu code like the ss alias David and Petertje provide.

 

The issue is if I set a 1 second timer on every pass through the while loop, it will still perform the command just as fast, only a second later. Instead I have had to add a little bit of time every time it passes through.

 

Example:

%x = 5 /timer 1 1 /command (waits one second)

%x = 4 wait 1 second

%x = 3 wait 1 second

%x = 2 wait 1 second

 

These command will execute just as fast, only one second after.

 

So I need to make the timers different. This way here will execute the commands once every 500 ms.

 

%x = 5 wait 1 second before command

%x = 4 wait 1.5 seconds before command

%x = 3 wait 2 seconds before command

%x = 2 wait 2.5 seconds before command

%x = 1 wait 3 seconds before command

 

This way it actually spaces the commands out.

 

( I typically just use the ss alias!! Thanks David and Petertje!)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...