belphegor Posted August 26, 2013 Group: Members Topic Count: 2 Topics Per Day: 0.00 Content Count: 23 Reputation: 0 Joined: 08/12/13 Last Seen: September 9, 2013 Share Posted August 26, 2013 (edited) Man, this loop thing is creeping me out. :3 Btw, is this right? EDIT: Oops. Sorry, post's not in the right place for(.@i = 0; .@i < getarraysize(.@names$); .@i + 1) { .@checkcount = .@checkcount + 1; .@currentcheck$ = getcharip(.@names$[.@i]); if(.@currentcheck$ == getcharip(.@names$[.@checkcount])) .@dual = .@dual + 1 } Edited August 26, 2013 by belphegor Quote Link to comment Share on other sites More sharing options...
Capuche Posted August 26, 2013 Group: Developer Topic Count: 10 Topics Per Day: 0.00 Content Count: 2407 Reputation: 613 Joined: 07/05/12 Last Seen: April 15 Share Posted August 26, 2013 if(.@currentcheck$]==getcharip($@names$[.@checkcount])) delete the ] in red replace the $ in blue by . .@dual = .@dual + 1 You forgot ; at the end of this line. for(.@i = 0; .@i < getarraysize(.@names$); .@i + 1) { .@i + 1 doesn't increment .@i variable. It must be .@i += 1 or .@i++ This script check if the ip in array i is the same in array i+1. But it won't check if the ip in array i is the same in array i+2 etc With 2 loops .@size = getarraysize(.@names$); for(.@i = 0; .@i < .@size -1; .@i++ ) { .@ip_in_loop1$ = getcharip(.@names$[.@i]); for( .@j = .@i +1; .@j < .@size; .@j++ ) if( .@ip_in_loop1$ == getcharip(.@names$[.@j]) ) .@dual = .@dual + 1; } With setd/getd + 1 loop .@size = getarraysize(.@names$); for( .@i = 0; .@i < .@size; .@i++ ) { if ( getd( ".@ip_"+ getcharip( .@names$[.@i] ) ) ) .@dual = .@dual + 1; setd ".@ip_"+ getcharip(.@names$[.@i]), 1; } Quote Link to comment Share on other sites More sharing options...
belphegor Posted August 26, 2013 Group: Members Topic Count: 2 Topics Per Day: 0.00 Content Count: 23 Reputation: 0 Joined: 08/12/13 Last Seen: September 9, 2013 Author Share Posted August 26, 2013 Sorry 'bout those errors. I'm kinda new to this whole loop thing and i've been awake for almost two days now. Btw, i never even thought of using 2 loops. Thanks mate. Quote Link to comment Share on other sites More sharing options...
Question
belphegor
Man, this loop thing is creeping me out. :3
Btw, is this right?
EDIT: Oops. Sorry, post's not in the right place
Edited by belphegorLink to comment
Share on other sites
2 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.