mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2004
Posts: 10
M
MRic3 Offline OP
Pikka bird
OP Offline
Pikka bird
M
Joined: Aug 2004
Posts: 10
My first post on this forum. I really learned a lot but i'm stuck with this one....

I am a beginner in scripting and so far it has been a strugle to get things going but it is working.
I'm experimenting with sockets because i can see the potential..

I got this script running on our clan channel. I don't understand all of it but most of the time it works
Code:
on 1:text:!ip*:#:{ 
  set %codquery.source $chan
codquery 213.189.10.42 28960 }
on 1:text:* ip *:#:{ 
  set %codquery.source $chan
codquery 213.189.10.42 28960 }


alias codquery { 
  if ($sock(codquery)) { 
    sockclose codquery 
  } 
  sockudp -k codquery $1 $2 $str($chr(255),4) $+ getstatus 
} 

on *:udpread:codquery:{ 
  sockread &cod 
  var %cod.return = $bvar(&cod,1,$bvar(&cod,0)).text 
  var %x = 1 
  while (%x <= $numtok(%cod.return,92)) { 
    var %cod.current = $gettok(%cod.return,%x,92) 
    if (mapname isin %cod.current) { 
      var %cod.map $gettok(%cod.return,$calc(%x + 1),92) 
    } 
    if (sv_hostname isin %cod.current) { 
      var %cod.name $gettok(%cod.return,$calc(%x + 1),92) 
    } 
    if (sv_maxclients isin %cod.current) { 
      var %cod.maxplayers = $gettok(%cod.return,$calc(%x + 1),92) 
    } 
    inc %x 
  } 
  msg %codquery.source Servernaam: %cod.name 
  msg %codquery.source IP adres: 213.189.10.42:28960  Players: $int($calc($numtok(%cod.return,34) / 2)) $+ / $+ %cod.maxplayers  Current map: %cod.map 
  unset %codquery.source
  if ($sock(codquery)) { 
    sockclose codquery 
  } 
} 


It works allmost perfect but there is 1 problem...

When there are 11 players or more on the server i get an error line 18
Code:
var %cod.return = $bvar(&cod,1,$bvar(&cod,0)).text 
mIRC echo's "* String too long: $bvar (line 18, codquery.mrc)"

What can i do about this?

Last edited by MRic3; 13/08/04 01:14 PM.
Joined: Dec 2002
Posts: 788
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 788
It depends really WHERE in the string you are recieving is the data you need.. try.

var %cod.return = $bvar(&cod,1,1000).text

If the bit you need isnt there, increase it some more.

If the required data in the string or if you require it all, then use several variables.

var %cod.return1 = $bvar(&cod,1,1000).text
; Gets the first 1000 bytes.
var %cod.return2 = $bvar(&cod,1001,1000).text
; Gets the second 1000 bytes.

Eamonn.

Joined: Aug 2004
Posts: 10
M
MRic3 Offline OP
Pikka bird
OP Offline
Pikka bird
M
Joined: Aug 2004
Posts: 10
i changed this line
var %cod.return = $bvar(&cod,1,900).text
The script doesn't give any errors when there are more then 11 players on the server.
Tthe counter is max 11 players (even when there are 17 players on the server) So that is the error...

Well i'm satisfied with it..
i don't really understand the complete script so i haven't got an idea hoe to work with more variable's...

Thanx for the help


Link Copied to Clipboard