Raised This Month: $12 Target: $400
 3% 

[INC] debug


Post New Thread Reply   
 
Thread Tools Display Modes
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 05-24-2017 , 15:21   Re: debug.inc
Reply With Quote #11

ok about new const ... can you say how and why a static ? i want also to understand
__________________
Project: Among Us

Last edited by Craxor; 05-25-2017 at 01:34.
Craxor is offline
Send a message via ICQ to Craxor
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 05-24-2017 , 15:51   Re: debug.inc
Reply With Quote #12

Quote:
Originally Posted by Craxor View Post
ok about new const ... can you say how and why a static ? i want also to understand
Quote:
Originally Posted by PRoSToTeM@ View Post
static functions and static global variables are visible only in this file.
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 05-25-2017 , 02:07   Re: debug.inc
Reply With Quote #13

ok, can also say how ?

Do you mean like that:
PHP Code:
static get_dbg_info( const Format[], szString[], maxchars=)
{
    new 
szMap[30];    
    
get_mapnameszMapcm(szMap) );

    new 
iHouriMinutes;
    
timeiHouriMinutes );
    
    
formatexszStringmaxchars"[Map: %s, Time: %i:%i] %s"szMapiHouriMinutesFormat ); 


Last edited by Craxor; 05-25-2017 at 02:08.
Craxor is offline
Send a message via ICQ to Craxor
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 05-25-2017 , 02:18   Re: debug.inc
Reply With Quote #14

static stock.
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 05-26-2017 , 01:36   Re: debug.inc
Reply With Quote #15

As an example of using this inc i use it just for curiostiy to see wich one is called faster, plugin_natives() / CFg / Precahe and Init with the following code:

PHP Code:
#include <amxmodx>
#include <debug>

public plugin_init( )
    
debug_log1DEBUG_SERVER_CONSOLE"Plugin Init" );

public 
plugin_precache()
    
debug_log1DEBUG_SERVER_CONSOLE"Precahe" );

public 
plugin_cfg( )
    
debug_log1DEBUG_SERVER_CONSOLE"Plguin Cfg" );

public 
plugin_natives( )
    
debug_log1DEBUG_SERVER_CONSOLE"Plugin Natives" ); 
Output:

Code:
L 05/26/2017 - 08:32:11: -------- Mapchange to de_dust2 --------
[Map: de_dust2, Time: 8:32] Plugin Natives
[Map: de_dust2, Time: 8:32] Precahe
[Map: de_dust2, Time: 8:32] Plugin Init
[Map: de_dust2, Time: 8:32] Plguin Cfg
Another think was to make a plugin that anytime i touch an entity to print me a message with its classsanem and index, i used FM_Touch to detect any kind of entity because i wanne see about all of them:

PHP Code:
#include <amxmodx>
#include <debug>
#include <fakemeta>


public plugin_init( )
{
    
register_forward(FM_Touch,"fwd_touch")
}

public 
fwd_touchent,id )
{
    if( !
pev_valid(ent) || !id )    
        return 
PLUGIN_HANDLED;

    new 
classname[32];
    
pev(entpev_classnameclassnamecharsmax(classname) );

    
debug_log1DEBUG_PLAYERS_CHAT"Classname: %s | Index: %i"classnameent );

    return 
PLUGIN_CONTINUE;


Last edited by Craxor; 05-26-2017 at 01:38.
Craxor is offline
Send a message via ICQ to Craxor
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 05-26-2017 , 01:48   Re: debug.inc
Reply With Quote #16

Update, New enums added:
Code:
enum DEBUG_LOG_TYPE
{     DEBUG_SERVER_CONSOLE = 0,     DEBUG_PLAYERS_CONSOLE,     DEBUG_PLAYERS_CHAT,     DEBUG_PLAYERS_CENTER,     DEBUG_FILE  };
Craxor is offline
Send a message via ICQ to Craxor
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 05-26-2017 , 12:03   Re: debug.inc
Reply With Quote #17

The #15 is good for people that wanna know who's the first forward that starts. Native comes first, o.O, thought the precache comes first.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 05-27-2017 , 00:59   Re: debug.inc
Reply With Quote #18

Another test with this sma ( i modified the debug_log to add the substring also the Game Time, it may help someone. )

To see wich one is called first.

Code for testing:

PHP Code:
#include <amxmodx>
#include <debug>


public client_putinserverid )
{
    
debug_logDEBUG_SERVER_CONSOLE"Client_putinserver[]" );    
}

public 
client_connectid )
{
    
debug_logDEBUG_SERVER_CONSOLE"Client_connect[]" );    
}


public 
client_authorizedid )
{
    
debug_logDEBUG_SERVER_CONSOLE"Client_authorized[]" );    
}


public 
client_connectex(id, const name[], const ip[], reason[128])
{
    
debug_logDEBUG_SERVER_CONSOLE"Client_connectex[]" );

Output
Code:
L 05/27/2017 - 07:54:23: -------- Mapchange to fy_snow --------
[Map: fy_snow, Time: 7:54, Game Time: 21.550056 ] Debug: Client_connectex[]
[Map: fy_snow, Time: 7:54, Game Time: 21.550056 ] Debug: Client_connect[]
[Map: fy_snow, Time: 7:54, Game Time: 21.550056 ] Debug: Client_authorized[]
[Map: fy_snow, Time: 7:54, Game Time: 34.809577 ] Debug: Client_putinserver[]
Update:

- Added Game TIme : in the substring
- Added Debug: %s in the substring
- Remove "NumberOfMessages" and the loop from debug_log code().

Last edited by Craxor; 05-27-2017 at 01:51.
Craxor is offline
Send a message via ICQ to Craxor
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 05-27-2017 , 09:56   Re: debug.inc
Reply With Quote #19

- Code updated, added DEBUG_OFF macross and is_debug_enabled function has been removed, check the new code to see the implementantion, also i added also Caps name for each function, depends of preference.
Craxor is offline
Send a message via ICQ to Craxor
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 05-30-2017 , 06:51   Re: debug.inc
Reply With Quote #20

Updated, thanks to Prostetamoto and BLackRose added new 4 natives:
Code:
#define DEBUG_TIMER_START   debug_timer_start #define DEBUG_TIMER_STOP    debug_timer_stop #define DEBUG_TIMER_LOOP    debug_timer_loop #define DEBUG_TIMER_FORMAT  debug_timer_format

Sources;
Spoiler




Code Example for usage:
PHP Code:
#include <amxmodx>
#include <fun>
#include <fakemeta>
#include <debug>

public plugin_init( )
{
    
register_clcmd"say /test""test" );
}

public 
testid )
{
    new 
Start1 debug_timer_start();
    
debug_timer_loopiStart1is_user_alive(id), set_user_health(id,250) );
    
debug_timer_stop(Start1);

    new 
Start2 debug_timer_start();
    
debug_timer_loopiStart2is_user_alive(id), set_pev(id,pev_health,float(250)));
    
debug_timer_stop(Start2);

    new 
szStart1[32], szStart2[32];

    
debug_timer_formatStart1szStart1charsmax(szStart1) );
    
debug_timer_formatStart2szStart2charsmax(szStart2) );

    
client_printidprint_chat"Fun: %s"szStart1 );
    
client_printidprint_chat"FakeMeta: %s"szStart2 );
    
    return 
PLUGIN_HANDLED;

Output:
Code:
Fun: 0s 133ms
FakeMeta: 0s 183ms

Last edited by Craxor; 05-30-2017 at 06:51.
Craxor is offline
Send a message via ICQ to Craxor
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:02.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode