PHP Code:
public socket_init()
{
new ip[64],port,erre,user[32],pass[100]
new cmd[300];
get_cvar_string("cm_bot_host",ip,63)
port = get_cvar_num("cm_bot_port")
bothost = socket_open(ip,port,SOCKET_TCP,erre)
if (erre == 0) {
remove_task( RETRY );
server_print("Socket Reopened");
}
else {
socket_close(bothost);
return PLUGIN_HANDLED
}
new params[ 1 ];
params[ 0 ] = bothost;
set_task( 2.5 , "socket_read" , TASK_RECV , params , sizeof( params ) , "b" );
return PLUGIN_CONTINUE;
}
new socket_status[50]
public socket_read(botcmd[])
{
if ( socket_change( bothost ) )
{
socket_recv(bothost,botcmd,500)
if (equal(botcmd,"")) {
server_print("[Network] Connection with Bot has been lost");
socket_close(bothost);
new params[9];
params[1] = RETRY;
set_task( 1.50 , "socket_init" , RETRY , params , sizeof( params ) , "b" );
remove_task( TASK_RECV );
}
server_print("[Gather] %s",botcmd);
Well i have a small problem on Socket Read, everytime that it reads data from socket evey user's latency raises 20... Any idea to solve it ? :s
p.s last year that i had made a socket code [i have lost it] it didn't raised the latency...
__________________
function rb return $regsubex($$1-,/(.)/g,$+($chr(2) $+ $chr(3),$r(2,15),$chr(2),\1))