 |
Senior Member
Join Date: Oct 2010
Location: Varna, Bulgaria
|

03-30-2023
, 13:55
Re: Module: Orpheu2.3
|
#1507
|
Quote:
Originally Posted by Arkshine
Code:
#include <amxmodx>
#include <orpheu>
new Msg[ 100 ];
public plugin_precache()
{
register_srvcmd( "catch", "catch" );
}
public catch()
{
new OrpheuHook:handlePrintf = OrpheuRegisterHook( OrpheuGetFunction( "Con_Printf" ), "Con_Printf" );
server_cmd( "stats" );
server_exec();
OrpheuUnregisterHook( handlePrintf );
const tokensN = 7;
const tokenLen = 19;
static tokens[ tokensN ][ tokenLen + 1 ];
for ( new i = 0; i < tokensN; i++ )
{
trim( Msg );
strtok( Msg, tokens[ i ], tokenLen, Msg, charsmax( Msg ), ' ' );
}
new Float:cpu = str_to_float( tokens[ 0 ] );
new Float:in = str_to_float( tokens[ 1 ] );
new Float:out = str_to_float( tokens[ 2 ] );
new uptime = str_to_num ( tokens[ 3 ] );
new users = str_to_num ( tokens[ 4 ] );
new Float:fps = str_to_float( tokens[ 5 ] );
new players = str_to_num ( tokens[ 6 ] );
server_print( "CPU[%f] IN[%f] OUT[%f] UPTIME[%d] USERS[%d] FPS[%f] PLAYERS[%d]", cpu, in, out, uptime, users, fps, players );
}
public OrpheuHookReturn:Con_Printf( const a[], const message[] )
{
copy( Msg,charsmax( Msg ), message );
return OrpheuSupercede;
}
|
ReAPI version:
Code:
#include <amxmodx>
#include <reapi>
static Msg[ 100 ];
static HookChain:g_handlePrintf;
public plugin_precache()
{
DisableHookChain( g_handlePrintf = RegisterHookChain( RH_Con_Printf, "Con_Printf_Pre" ) );
register_srvcmd( "catch", "catch" );
}
public catch()
{
EnableHookChain( g_handlePrintf );
server_cmd( "stats" );
server_exec();
DisableHookChain( g_handlePrintf );
const tokensN = 14;
const tokenLen = 19;
static tokens[ tokensN ][ tokenLen + 1 ];
for ( new i = 0; i < tokensN; i++ )
{
trim( Msg );
strtok( Msg, tokens[ i ], tokenLen, Msg, charsmax( Msg ), ' ' );
}
new Float:cpu = str_to_float( tokens[ 7 ] );
new Float:in = str_to_float( tokens[ 8 ] );
new Float:out = str_to_float( tokens[ 9 ] );
new uptime = str_to_num ( tokens[ 10 ] );
new users = str_to_num ( tokens[ 11 ] );
new Float:fps = str_to_float( tokens[ 12 ] );
new players = str_to_num ( tokens[ 13 ] );
server_print( "CPU[%f] IN[%f] OUT[%f] UPTIME[%d] USERS[%d] FPS[%f] PLAYERS[%d]", cpu, in, out, uptime, users, fps, players );
}
public Con_Printf_Pre( const message[] )
{
copy( Msg, charsmax( Msg ), message );
return HC_SUPERCEDE;
}
__________________
|
|
|
|