Alright, I have this script, but the socket still ping timeouts. Help please. Thanks.
on 1:sockread:dnn:{
var %temp | sockread %temp
if (%temp == PING) { sockwrite -n $sockname PONG $2- }
}
Figured it out. I needed:
on 1:sockread:dnn:{
var %temp | sockread %temp
if ($gettok(%temp,1,32) == PING) { sockwrite -n $sockname PONG $2- }
}
You can also use "tokenize" command. That allows you to tokenize texts.
Usage; /tokenize <ascii code> <text>
on 1:sockread:dnn:{
var %temp
sockread %temp
tokenize 32 %temp
if ([color:red]$1[/color] == PING) { sockwrite -n $sockname PONG [color:red]$2-[/color] }
}
Glad you figured it out, but just remember there is no tokenized data in sockread unless you use /tokenize, your $2- is null there.
Oh I didn't see.
phrozen, you cannot use data as token like $2- by not using tokenize command if theres not already tokenized.
;--------
;there should be like below code if there not using tokenizing;
if ($gettok(%temp,1,32) == ping) sockwrite -tn $sockname pong $gettok(%temp,2-,32)
;--------
by using tokenize command;
if ($1== ping) sockwrite -tn $sockname pong $2-
;-------