mIRC Home    About    Download    Register    News    Help

Print Thread
#257661 03/05/16 10:07 AM
Joined: May 2016
Posts: 4
S
SYD Offline OP
Self-satisified door
OP Offline
Self-satisified door
S
Joined: May 2016
Posts: 4
I need help in socket . I done almost all script work and now just need to parse message from sockread to channel . what to do ??

SYD #257664 03/05/16 02:24 PM
Joined: Sep 2014
Posts: 259
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2014
Posts: 259
Use /msg followed by the channel name which you store in either a global variable or in $sockmark

Joined: May 2016
Posts: 4
S
SYD Offline OP
Self-satisified door
OP Offline
Self-satisified door
S
Joined: May 2016
Posts: 4
Originally Posted By: Sakana
Use /msg followed by the channel name which you store in either a global variable or in $sockmark


I think I know that but my prob is . The value I want is surrounded by other values but not by "space" . then how will I get the data I want ?

Thanks for the answer anyway smile

SYD #257680 05/05/16 01:29 PM
Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
If you want to parse an socket data to an channel just follow the ON SOCKREAD event (/help on sockread)


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Joined: May 2016
Posts: 4
S
SYD Offline OP
Self-satisified door
OP Offline
Self-satisified door
S
Joined: May 2016
Posts: 4
Tried that . but data needed is from an API . not getting the results as usual .

API : http://maxima.e-sim.org/apiCitizenByName.html?name=dazzler

Found this already : http://hawkee.com/snippet/10194/

But I dont know what json is or how to do it . So if you guys please help me by giving me working script of API above using the JSON parser , it will be a lot more great .

Regards,

Last edited by SYD; 08/05/16 07:44 AM.
SYD #257697 08/05/16 12:35 PM
Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
It's not hard, the SReject has already provide some examples in his JSON script of how can you do that but anyway, you can add more by your own it's easy just follow this example:

NOTE: Make sure that you are using the latest mIRC version and the latest JSON script addon version.

Code:
alias get_results {
  var %v = res_ $+ $rand(1,100000)
  var %u = http://maxima.e-sim.org/apiCitizenByName.html?name=dazzler
  JSONOpen -ud %v %u
  if ($JSONError) { echo 4 -a Error: There was an connection problem! - (Error Details: $jsonerror $+ ) | return }
  var %str = $json(%v,strength)
  var %rank = $json(%v,rank)
  echo -a Results are - Strength: %str - Rank: %rank
}


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Joined: Feb 2015
Posts: 243
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Feb 2015
Posts: 243
Hey.. i didn't reloaded to see that westor replied so i made this script which echos all the items and values. SReject's must work better but here's mine too..
Code:
ON *:SOCKOPEN:maxima: { if ($sockerr) { echo -at Error while retrieving maxima info... | sockclose $sockname } | sockwrite -nt $sockname GET /apiCitizenByName.html?name=dazzler HTTP/1.1 | sockwrite -nt $sockname Connection: close | sockwrite -nt $sockname Host: maxima.e-sim.org | sockwrite $sockname $crlf }


ON *:SOCKREAD:maxima: {
  var %m | sockread -f %m 
  if ({"* iswm %M) {
    var %x = 2
    while (%x <= $numtok(%m,34)) {
      var %t = $gettok(%m,%x,34)
      var %t2 = $gettok(%m,$calc(%x + 1),34)
      var %t3 = $gettok(%m,$calc(%x + 2),34)
      if (%t2 == :) {
        var %item = %t
        var %value = $remove(%t3,:,$chr(44))
        echo -at %item > %value
        inc %x 4
      }
      elseif (%t2 != :) {
        var %item = %t
        var %value = $remove(%t2,:,$chr(44))
        echo -at %item > %value
        inc %x 2
      }
      ;;;You can place your if here
      ;;; example if (%item == eqCriticalHit) { echo -at %value } ;;;
    }
    sockclose $sockname
  }
}

Do
/sockopen maxima maxima.e-sim.org 80
to test it

Last edited by OrFeAsGr; 08/05/16 01:28 PM.
Joined: May 2016
Posts: 4
S
SYD Offline OP
Self-satisified door
OP Offline
Self-satisified door
S
Joined: May 2016
Posts: 4
Originally Posted By: OrFeAsGr
Hey.. i didn't reloaded to see that westor replied so i made this script which echos all the items and values. SReject's must work better but here's mine too..
Code:
ON *:SOCKOPEN:maxima: { if ($sockerr) { echo -at Error while retrieving maxima info... | sockclose $sockname } | sockwrite -nt $sockname GET /apiCitizenByName.html?name=dazzler HTTP/1.1 | sockwrite -nt $sockname Connection: close | sockwrite -nt $sockname Host: maxima.e-sim.org | sockwrite $sockname $crlf }


ON *:SOCKREAD:maxima: {
  var %m | sockread -f %m 
  if ({"* iswm %M) {
    var %x = 2
    while (%x <= $numtok(%m,34)) {
      var %t = $gettok(%m,%x,34)
      var %t2 = $gettok(%m,$calc(%x + 1),34)
      var %t3 = $gettok(%m,$calc(%x + 2),34)
      if (%t2 == :) {
        var %item = %t
        var %value = $remove(%t3,:,$chr(44))
        echo -at %item > %value
        inc %x 4
      }
      elseif (%t2 != :) {
        var %item = %t
        var %value = $remove(%t2,:,$chr(44))
        echo -at %item > %value
        inc %x 2
      }
      ;;;You can place your if here
      ;;; example if (%item == eqCriticalHit) { echo -at %value } ;;;
    }
    sockclose $sockname
  }
}

Do
/sockopen maxima maxima.e-sim.org 80
to test it



Thanks but I already found a simple without opening socket smile


Link Copied to Clipboard