AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Optimizing (https://forums.alliedmods.net/showthread.php?t=105614)

xPaw 10-06-2009 11:47

Optimizing
 
Oh no its xpaw here

PHP Code:

#include <amxmodx>

new g_pTimelimit;
new 
g_szMapname32 ];
new 
bool:g_bSawMotd33 ];

public 
plugin_init( ) {
    
register_plugin"MOTD System""1.0""xPaw" );
    
    if( !
file_exists"motd.txt" ) )
        
pause"ad" );
    
    
g_pTimelimit get_cvar_pointer"mp_timelimit" );
    
    
get_mapnameg_szMapname31 );
    
    
register_dictionary"timeleft.txt" );
    
    
register_messageget_user_msgid"MOTD" ), "MessageMOTD" );
}

public 
client_connectid )
    
g_bSawMotdid ] = false;

public 
MessageMOTD( const MsgId, const MsgDest, const id ) {
    if( 
g_bSawMotdid ] )
        return 
PLUGIN_CONTINUE;
    
    new 
szText128 ], szName40 ], bSet;
    
get_msg_arg_string2szText127 );
    
    if( 
containszText"%username%" ) != ) {
        
get_user_nameidszName31 );
        
replaceszText127"%username%"szName );
        
        
bSet true;
    }
    
    if( 
containszText"%servname%" ) != ) {
        
get_user_name0szName39 );
        
replaceszText127"%servname%"szName );
        
        
bSet true;
    }
    
    if( 
containszText"%currmap%" ) != ) {
        
replaceszText127"%currmap%"g_szMapname );
        
        
bSet true;
    }
    
    if( 
containszText"%timeleft%" ) != ) {
        if( 
get_pcvar_floatg_pTimelimit ) ) {
            new 
iTimeleft get_timeleft( );
            
            
formatexszName39"%d:%02d"iTimeleft 60iTimeleft 60 );
        } else
            
formatexszName39"%L"LANG_PLAYER"NO_T_LIMIT" );
        
        
replaceszText127"%timeleft%"szName );
        
        
bSet true;
    }
    
    if( 
bSet )
        
set_msg_arg_string2szText );
    
    if( 
get_msg_arg_int) == )
        
g_bSawMotdid ] = true;
    
    return 
PLUGIN_CONTINUE;


Any changes / suggestions?

hleV 10-06-2009 12:31

Re: Optimizing
 
Shouldn't contain() not return -1 instead of 1?

xPaw 10-06-2009 12:32

Re: Optimizing
 
EDIT: Woops i just noticed what i typed 1 instead of -1. -_-


All times are GMT -4. The time now is 22:35.

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