Code:
on *:SockRead:Game*: {
  set -u0 %Bytes 800
  sockread %Bytes &newdata
  if ($SockName == GameStats) {
    bwrite $+( $SockName, .html) -1 -1 &newdata
    if ( $gettok( $bvar(&newdata, 1, %Bytes).text, 1, 13) == HTTP/1.1 302 Found ) {
      $iif( %GameMsgInfo == on, msg %GameSetChan, echo -s) You need to make the login $+ $chr(44) Automatic redirect to do it.
      Sockclose Game*
      SockOpen GameGetCookie xxxxxxx.xxx.xx 80
    }
    else {
      window @Status 1 1 1135 200
      window @OutputData 1 201 1135 200
      ; This if is the add the incomplete code missing that canĀ“t be correct read btween the Sockread
      if ($hget(DataIncomplecta, Estatisticas)) {
        bset &data 1 $hget(DataIncomplecta, Estatisticas)
        bcopy &data $bvar(&data, 0) &newdata 1 -1
        hfree DataIncomplecta
      }
      else {
        bcopy &data 1 &newdata 1 -1
      }
      var %open = 1
      ; While the beginning text "<td" is found
      while ($bfind(&data, %open, <td)) {
        %open = $v1
        ; If the final text "</td>" is found, then the output sentence is complete
        if ($bfind(&data, %open, </td>)) {
          var %close = $v1
          var %len = $calc( %close + 5 - %open)
          ;This is where the output text is showed including all the html code, beguining in the "<td" search until the final "</td>" 
          var %celldata = $remove( $bvar( &data, %open, %len).text, $chr(9), $chr(10), $chr(13))
          aline -p @Status 12 %TimeCount 3Complet %celldata 4<td in 12 %open and 4</td> in12 %close
          aline -p @OutputData 12 %TimeCount  %celldata
          TextoSaida %celldata
          inc %TimeCount
        }
        ; If the final text "</td>" is NOT found, them the output sentence is NOT complete
        else {
          ; Once the final text was not found, it will be necessary keep the rest of the sentence somewhere, in this case in hash tables
          ; It will keep all text from the beginning "<td" search until the end of sockread data
          bcopy &incomplete 1 &data %open -1
          hmake DataIncomplecta 10
          noop $hget(DataIncomplecta, Estatisticas, &incomplete)
          aline -p @Status 12 %TimeCount 4Incomplete $bvar( &incomplete, %open -).text 4<td in 12 %open
        }
        inc %open
      }
    }
  }
}


I did a lot of chopping and changing in the code so there's a slight chance I've removed some things and forgotten to put them back in. It should be about right though - at least enough to test whether the bug is still present.

I also renamed some of the variables to make it easier for me to work on the code so you might want to rename them (%x is now %open, %y is now %len). I also added a few variables which cut down on a lot of redundant re-evaluating. Even if you rename the variables you should consider keeping them - they make the code more efficient.


Spelling mistakes, grammatical errors, and stupid comments are intentional.