mIRC Home    About    Download    Register    News    Help

Print Thread
#173903 31/03/07 07:17 PM
Joined: Sep 2006
Posts: 35
C
chump Offline OP
Ameglian cow
OP Offline
Ameglian cow
C
Joined: Sep 2006
Posts: 35
hi i am working on a script and have a small problem

heres the script



on *:text:*NEW*IN*:#pred: {
var %section = $left($strip($3), $calc($len($strip($3))-1)))
var %rls = $strip($remove($5,[,])))
if (($nick == pre)) && ((bot == $me)) {
if (Wii isin %section) { goto WII }
if (XBOX360 isin %section) { goto XBOX360 }
else { goto end }

:Wii {
if (-RELOADED || -Razor1911 || -DEViANCE || -ADDICTION || -RECHARGED || -GGS || -FASiSO|| -JFKPC || -ViTALiTY || -FLT || -PROCYON || -HATRED || -POSTMORTEM || -OVERDUE || -QUARTEX || -GGS isin %rls) { goto section }
if (DVDR isin %rls) { goto section }
if (MDVDR isin %rls) { goto section }
if (*VCD* iswm %rls) { goto section }
if (NDS isin %rls) { goto section }
if (XBOX360 isin %rls) { goto section }
if (VCD isin %rls) { goto section }
if (MVID isin %rls) { goto section }
if (PS2 isin %rls) { goto section }
if (PDA isin %rls) { goto section }
if (*TV* iswm %rls) { goto section }
if (XVID isin %rls) { goto section }
if (*XXX* iswm %rls) { goto end }
if (CD1 isin %rls) { goto end }
if (CD2 isin %rls) { goto end }
if (sample isin %rls) { goto end }
if (covers isin %rls) { goto end }
if (PS3 isin %rls) { goto section }
if (PSP isin %rls) { goto section }
if (covers isin %rls) { goto end }
var %text = $strip($1-))
var %filename = console.txt
var %filelines = $lines(%filename)
var %found = 0, %foundline, %matched, %i = 1
while (%i <= %filelines) {
var %readfile = $read(%filename,%i)
if (%readfile isin %text) { %found = 1 | %foundline = $readn | %matched = %readfile }
inc %i
}
if (%found == 1) {
msg #pred 4=[0NUKE WARNING4]= 4[CHECK RULES!! NOT ALLOWED IN WII ] =[8 $strip($remove($5,[,]))) 4]= =[0 30 SECONDS TILL NUKE X3 4 ]=
.timer $+ wii-nuke 1 30 msg #pred !nuke $strip($remove($5,[,]))) 3 CHECK.RULES.NOT.ALLOWED
echo -d Nuking WII $strip($remove($5,[,]))) for CHECK RULES NOT ALLOWED at $time on $day
}
if (%found == 0) {
goto end

:section
msg #pred 4=[0NUKE WARNING4]= 4[WRONG SECTION NOT ALLOWED IN %section ] =[8 %rls 4]= =[0 30 SECONDS TILL NUKE X3 4 ]=
.timer $+ section-nuke 1 30 msg #pred !nuke %rls 3 WRONG.SECTION
echo -d 9Nuking %section %rls for :section WRONG SECTION at $time on $day

:end


ok this works pefect with no problems..however when i try to add a new section such as xbox underneath what i ahve ..it automatically goes straight to wrong section when it shouldnt..any ideas would be great thx

Last edited by chump; 31/03/07 07:18 PM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Please use code tags to make code easier to read on the forum. Thanks.

First of all, avoid GOTO. Just use the IF that you already have and put the information into there instead of telling the script to jump somewhere else for no reason.

Code:
if (Wii isin %section) {
  Wii section data
}
elseif (Xbox isin %section) {
  Xbox section data
}


That's a much cleaner way to code and won't have any issues with going into the next section.

Note that this line is invalid:
Code:
if (-RELOADED || -Razor1911 || -DEViANCE || -ADDICTION || -RECHARGED || -GGS || -FASiSO|| -JFKPC || -ViTALiTY || -FLT || -PROCYON || -HATRED || -POSTMORTEM || -OVERDUE || -QUARTEX || -GGS isin %rls) { goto section }

You need to have "isin %rls" in each OR section... not just at the end.

Also, if you want a script to end, instead of GOTO END, just use RETURN.

Finally, for your many IF's that goto section or end, you should use ELSEIF if you want to have them all like that. An easier way to handle that would be either to use tokens or else a temporary hash table so that there is a single IF statement that covers everything. I'm not sure what kind of speed difference that would give you, but it's something to consider. Btw, if you check for DVDR, the following check for MDVDR won't ever happen because it's already been true for the DVDR check. So that check isn't even necessary. And, if you do "*text* iswm" as a check, that's the same as doing "text isin". There's not need to use wildcards unless you only do them on one side, or you're using them inbetween things, or whatever.


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard