mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2012
Posts: 10
M
ManaPot Offline OP
Pikka bird
OP Offline
Pikka bird
M
Joined: Dec 2012
Posts: 10
Hello everybody. I'm fairly new to IRC scripting, but have the hang of it a bit. I'm having an issue with a couple of my scripts, they aren't returning the information obtained via the socket request. Sometimes it works, sometimes it doesn't. Fairly annoying when users are trying to run the script but it decides not to work for half an hour.

Am I doing something wrong here? Like I said, it works somemtimes but not all of the time. It tends to work for a couple of minutes then stops for 30 minutes or so. I don't understand it...

Code:
; ---------- CHECK MANAPOTS ----------

alias checkmp {
  if ($sock(CheckManaPots)) sockclose CheckManaPots
  set %manapot.check $1 $+ , $+ %manapot.check
  timerCHECKMP off
  timerCHECKMP 1 5 sockopen CheckManaPots d3sanc.com 80
}

on *:TEXT:!mp:#: {
  /checkmp $nick
}

on *:TEXT:!mp *:#: {
  if($nick == manapot) {
    /checkmp $2
  }
}

on *:TEXT:!manapots:#: {
  /checkmp $nick
}

on *:TEXT:!manapot:#: {
  /checkmp $nick
}

on *:sockopen:CheckManaPots: {
  sockwrite -n $sockname GET /db/manabot/manapots.php?id= $+ %manapot.check $+ &action=check HTTP/1.0
  sockwrite -n $sockname User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
  sockwrite -n $sockname Host: d3sanc.com
  sockwrite -n $sockname Accept-Language: en-us
  sockwrite -n $sockname Accept: */*
  sockwrite -n $sockname
}

on *:sockread:CheckManaPots: {
  if ($sockerr) {
    echo -a Error.
    halt
  }
  else {
    var %temp
    sockread -f %temp
    if (ManaPots isin %temp) {
      msg #manapot %temp
      set %manapot.check
    }
  }
}

Joined: Dec 2012
Posts: 10
M
ManaPot Offline OP
Pikka bird
OP Offline
Pikka bird
M
Joined: Dec 2012
Posts: 10
Anyone?

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
I don't see any %r but besides that nothing looks wrong. Why don't you provide some information you've found while debugging, the actual response you're getting?

Joined: Dec 2012
Posts: 10
M
ManaPot Offline OP
Pikka bird
OP Offline
Pikka bird
M
Joined: Dec 2012
Posts: 10
The only issue I have with it, is that it doesn't return the information from the server. It sends the request, and the server does output the information, the MIRC script just doesn't output that information to the chat.
  • User types "!mp"
  • User's name is added to the variable
  • Script sends request to server
  • Servers processes and outputs the information
  • Script *sometimes* returns the information
Again, it only sometimes outputs the information to the server. It seems to be picky and only work for a few minutes, then stop working for 10-20 minutes, then work again for 1-2 minutes.

What does %r do?

Last edited by ManaPot; 24/01/13 05:58 AM.
Joined: Dec 2011
Posts: 22
P
Ameglian cow
Offline
Ameglian cow
P
Joined: Dec 2011
Posts: 22
This works with my testing

Code:
on $*:TEXT:/^!m(p|anapots?)/i:#: {
  sockclose CheckManaPots
  set %manapot.check /db/manabot/manapots.php?id= $+ $iif($2,$2,$nick) $+ &action=check
  sockopen CheckManaPots d3sanc.com 80
}

on *:SOCKOPEN:CheckManaPots: {
  sockwrite -n CheckManaPots GET %manapot.check HTTP/1.1
  sockwrite -n CheckManaPots Host: d3sanc.com
  sockwrite CheckManaPots $crlf
}

on *:SOCKREAD:CheckManaPots: {
  var %x
  sockread %x
  while ($sockbr) {
    if (ManaPots isin %x) || (Content-Length: 0 isin %x) {
      msg #Meta $iif(Content-Length: 0 !isin %x,%x,Manapots request does not exist)
      unset %manapot.check
      sockclose CheckManaPots
      return
    }
    sockread -f %x
  }
}

Joined: Dec 2012
Posts: 10
M
ManaPot Offline OP
Pikka bird
OP Offline
Pikka bird
M
Joined: Dec 2012
Posts: 10
Thank you very much ParadoxDragon! It works perfectly now, thank you thank you thank you!


Link Copied to Clipboard