There are several problems with this, also the way you displayed it without any [ code ] & [ /code ] markers sure didnt help you to get any help, makes it real hard to read with it all against one wall.
Anyway, problems i saw.
(1) on *:TEXT:!chkall:?: ~~ event is missing a final close } thus all the other stuff is part of it and not events of there own. the code being in your first event doesnt run since you have an error before that, see problem (2)
(2) while (%count != %total) ~~ this loop does not advance the %count value, it is not incremented at the end of the loop, this normally causes a endless loop, however you dont get one becuase of problem (3)
(3) /sockopen ftpcheck %ftpipaddress %ftpport ~~ wheather problem (2) was fixed or not, you cant sockopen ftpcheck a second time, as your already using it from the first site. This error well stop the script and save you from problem (2) endless loop
(4) Overall ~~ The concept you have attempted is to open all the sites at once, and then process them, This well not work even if u assigned sepearte socket names, since you then refrence %check from the TEXT event, which you have already changed.
I have taken a shoot at fixing this, I dont think it well be perfect, but it might send you in the right direction.
I renamed the socket to "ftpcheck>
$nick>
%check" as a cheap method of passing them values to the socket events and as a way to make unique socket names.
I also remarked up a few lines i noticed.
on *:TEXT:!chkall:?:{
if ($nick isop %channame) {
/set %identchk $readini(%usersfile, $nick, Status)
if (%identchk > 1) || (%identchk == $null) {
.timer $+ $rand(200, 50000) 1 2 /msg $nick Y ou must identify with the bot before using this command.
/halt
}
else {
;if $2 == rewt { /notice $nick Im sorry but that ftp is local to me and cannot be checked. }
;^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----[ this cant happen as there is no $2 in this event ]
/remove downusers
/set %total $ini(%sitesfile, 0)
/set %errorchk 0
/inc %total 1
/set %count 1
while (%count < %total) {
/set %check $ini(%sitesfile, %count)
/set %ftpipaddress $readini(%sitesfile, %check, IP)
/set %ftpport $readini(%sitesfile, %check, Port)
/sockopen $+(ftpcheck>,$nick,>,%check) %ftpipaddress %ftpport
inc %count
}
}
}
}
on 1:sockopen:ftpcheck>*:{
var %nick = $gettok($sockname,2,$asc(>))
var %check = $gettok($sockname,3,$asc(>))
if ($sockerr > 0) {
.timer $+ $rand(200, 50000) 1 2 /msg %nick Connection failed to %check
/set %temp.22 $readini(%sitesfile, %check, Catagory)
/set %temp.22 $readini(%sitesfile, %check, Catagory)
if (Down isin %temp.22) {
/writeini -n %usersfile %check Status 3
}
else {
if ($nick ishop %channame) || ($nick isvoice %channame) {
;-^^^^^----------------------^^^^^--------------------------[ I dont know if this is ment to be $nick which is likely to be $me for this event, or nick ]
/writeini -n %sitesfile %check OldCategory %temp.22
/writeini -n %sitesfile %check Catagory Down
/writeini -n %usersfile %check Status 3
}
}
}
else {
/set %ftpusername $readini(%sitesfile, %check, User)
/set %ftppassword $readini(%sitesfile, %check, Notes)
/set %ftppassword $remove(%ftppassword,Password: )
/sockwrite -n $sockname USER %ftpusername
/sockwrite -n $sockname PASS %ftppassword
}
}
on *:sockread:ftpcheck>*:{
if ($sockerr > 0) return
:nextread
sockread %temp
if ($sockbr == 0) return
if (%temp == $null) %temp = -
if (denied isin %temp) {
.timer $+ $rand(200, 50000) 1 2 /msg %nick returned: %temp
/sockclose $sockname
/set %temp.22 $readini(%sitesfile, %check, Catagory)
if (Down isin %temp.22) {
/writeini -n %usersfile %check Status 3
}
else {
/writeini -n %sitesfile %check OldCategory %temp.22
/writeini -n %sitesfile %check Catagory Down
/writeini -n %usersfile %check Status 3
}
}
if (logged in isin %temp) {
.timer $+ $rand(200, 50000) 1 2 /msg %nick returned: %temp
/sockclose $sockname
.timer $+ $rand(200, 50000) 1 2 /msg %nick %check $+ 's FTP Is Up!
if ($readini(%usersfile, %check, Status) == 3) {
/set %temp.23 $readini(%sitesfile, %check, OldCategory)
/writeini -n %sitesfile %check Catagory %temp.23
/writeini -n %usersfile %check Status 2
}
}
if (incorrect isin %temp) {
.timer $+ $rand(200, 50000) 1 2 /msg %nick returned: %temp
/sockclose $sockname
/set %temp.22 $readini(%sitesfile, %check, Catagory)
if (Down isin %temp.22) {
/writeini -n %usersfile %check Status 3
/halt
} else {
/writeini -n %sitesfile %check OldCategory %temp.22
/writeini -n %sitesfile %check Catagory Down
/writeini -n %usersfile %check Status 3
}
}
if (too many isin %temp) {
.timer $+ $rand(200, 50000) 1 2 /msg %nick returned: %temp
.timer $+ $rand(200, 50000) 1 2 /msg %nick %check $+ 's FTP Is Up!
if ($readini(%usersfile, %check, Status) == 3) {
/set %temp.23 $readini(%sitesfile, %check, OldCategory)
/writeini -n %sitesfile %check Catagory %temp.23
/writeini -n %usersfile %check Status 2
}
/sockclose $sockname
}
echo 4 %temp
goto nextread
}
Some last things...
. you dont need to put / on the front of commands ie: /sockopen and sockopen in a script is the same. / and // are only needed from the mirc command prompt.
. use dont use
set %value 1234 if you dont need that value saved outside the running script use
var %value = 1234 this way it exists only during the running script (note the = in the var usage)
. .timer $+ rand(200,50000) migth as well just be .timer as a timer well create a free number to use, you really should not be using numbers as timer names anyway, if you must do it do this .timer. $+ rand(200,50000) this way the "name" of the timer well be ex .2345 which is not a number.
. I dont really see the purpose of delaying the MSG to the nick for 2 seconds anyway