AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Run time error (https://forums.alliedmods.net/showthread.php?t=299921)

RAW_192 07-30-2017 12:49

Run time error
 
Quote:

L 07/30/2017 - 12:40:55: Invalid player id 0
L 07/30/2017 - 12:40:55: [AMXX] Displaying debug trace (plugin "hamEvents.amxx")
L 07/30/2017 - 12:40:55: [AMXX] Run time error 10: native error (native "get_user_weapon")
L 07/30/2017 - 12:40:55: [AMXX] [0] hamEvents.sma::fw_HamKilledPost (line 46)
PHP Code:

    public fw_HamKilledPostiVictimiAttackeriShouldGib 
    {
        new 
point get_user_point(iAttacker)    
        if( ! ( 
is_user_connectediVictim ) || is_user_connectediAttacker ) ) )
        return 
HAM_IGNORED ;
        
        if( 
get_user_weaponiAttacker ) == CSW_KNIFE )
        {
        
client_print_coloriAttackerprint_chat"^4 --------------Knife Kill Detected---------");
        
set_user_point(iAttackerpoint+20)
        }
        
        return 
HAM_IGNORED
    



TBagT 07-30-2017 13:03

Re: Run time error
 
Try this
PHP Code:

#define is_a_valid_player(%1) (1<=%1<=g_max_players)

new g_max_players;

public 
plugin_init( ) {
        
// ... //
        
g_max_players get_maxplayers( );
}

public 
fw_HamKilledPostiVictimiAttackeriShouldGib ) { 
        if( !
is_a_valid_playeriAttacker ) || iVictim == iAttacker )
                return 
HAM_IGNORED;

        new 
point get_user_pointiAttacker );
        if( 
get_user_weaponiAttacker ) == CSW_KNIFE ) { 
                
client_print_coloriAttackerprint_chat"^4 --------------Knife Kill Detected---------" ); 
                
set_user_pointiAttackerpoint 20 );
        } 

        return 
HAM_IGNORED;



siriusmd99 07-30-2017 14:48

Re: Run time error
 
You can check if attacker is alive and then get weapon.Dead players don't have weapons in hands...


All times are GMT -4. The time now is 23:03.

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