AlliedModders

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

asd13 07-10-2010 19:01

EventDeathMsg error
 
PHP Code:

L 07/11/2010 00:01:13: [CSTRIKEPlayer out of range (0)
L 07/11/2010 00:01:13: [AMXXDisplaying debug trace (plugin "vip_money.amxx")
L 07/11/2010 00:01:13: [AMXXRun time error 10native error (native "cs_get_user_money")
L 07/11/2010 00:01:13: [AMXX]    [0kvip_money.sma::EventDeathMsg (line 21

PHP Code:

#include < amxmodx >
#include < cstrike >

const VipFlags ADMIN_LEVEL_H;

new 
iMoney;
new 
iMoney_Hs;
new 
iMoney_Kill;

public 
plugin_init( ) {
    
register_plugin"PLUGIN""VERSION""AUTHOR" );
    
register_event"DeathMsg""EventDeathMsg""a" );
    
    
iMoney_Hs    register_cvar"amx_money_hs",    "800" );
    
iMoney_Kill    register_cvar"amx_money_kill",    "500" );
}


public 
EventDeathMsg( ) {
    if( 
get_user_flagsread_data) ) & VipFlags ) {
        if( 
cs_get_user_moneyread_data) ) >= 16000 ) {
            return 
PLUGIN_HANDLED;
        } 
        
        if( 
read_data) )
            
iMoney get_pcvar_numiMoney_Hs );
        else
            
iMoney get_pcvar_numiMoney_Kill );
        
        
cs_set_user_moneyread_data), cs_get_user_moneyread_data) ) -300 iMoney );
    }
    return 
PLUGIN_HANDLED;



hleV 07-10-2010 19:21

Re: EventDeathMsg error
 
Check if player is connected first.

Bugsy 07-10-2010 20:56

Re: EventDeathMsg error
 
You should do that as well as add a condition to your DeathMsg event so it will only fire if the killer is a player. Below I made those 2 fixes and also made a few other efficiency adjustments. Also, I don't understand why you subtract 300 from the awarded money? Why not just reduce the cvar value by that amount?
PHP Code:

#include <amxmodx>
#include <cstrike>

const VipFlags ADMIN_LEVEL_H;

new 
iMoney_Hs;
new 
iMoney_Kill;

public 
plugin_init( ) 
{
    
register_plugin"PLUGIN" "VERSION" "AUTHOR" );

    
register_event"DeathMsg" "EventDeathMsg" "a" "1>0" );
    
    
iMoney_Hs register_cvar"amx_money_hs" "800" );
    
iMoney_Kill register_cvar"amx_money_kill" "500" );
}

public 
EventDeathMsg( ) 
{
    new 
iKiller read_data);
    
    if( 
is_user_connectediKiller ) && ( get_user_flagsiKiller ) & VipFlags ) && ( cs_get_user_moneyiKiller ) < 16000 ) )
        
cs_set_user_moneyiKiller clampcs_get_user_moneyiKiller ) + get_pcvar_numread_data) ? iMoney_Hs iMoney_Kill ) , 16000 ) );
    
    return 
PLUGIN_HANDLED;



asd13 07-15-2010 01:19

Re: EventDeathMsg error
 
Thanks. : )

This is what i made from it now. : )

PHP Code:

#include < amxmodx >
#include < cstrike >
#include < fun > 

const VipFlags ADMIN_LEVEL_H;

new 
iMoney_Hs;
new 
iMoney_Kill;

new 
iHp_Max;
new 
iHp_Hs;
new 
iHp_Kill;

public 
plugin_init( ) {
    
register_plugin"PLUGIN" "VERSION" "AUTHOR" );
    
    
register_event"DeathMsg" "EventDeathMsg" "a" "1>0" );
    
    
iMoney_Hs register_cvar"amx_money_hs" "800" );
    
iMoney_Kill register_cvar"amx_money_kill" "500" );
    
    
iHp_Max register_cvar"amx_hp_max" "100" );
    
iHp_Hs register_cvar"amx_hp_hs" "30" );
    
iHp_Kill register_cvar"amx_hp_kill" "15" );
}

public 
EventDeathMsg( ) {
    new 
iKiller read_data);
    
    if( 
is_user_connectediKiller ) && ( get_user_flagsiKiller ) & VipFlags ) ) {
        if( 
cs_get_user_moneyiKiller ) < 16000 )
            
cs_set_user_moneyiKiller clampcs_get_user_moneyiKiller ) + get_pcvar_numread_data) ? iMoney_Hs iMoney_Kill ) , 16000 ) );
        
        if( 
get_user_healthiKiller ) < get_pcvar_num iHp_Max ) )
            
set_user_healthiKiller clampget_user_healthiKiller ) + get_pcvar_numread_data) ? iHp_Hs iHp_Kill ) ) );
        
        if( 
get_user_healthiKiller ) > get_pcvar_num iHp_Max ) ) set_user_healthiKillerget_pcvar_num iHp_Max ) );
    }



Bugsy 07-15-2010 09:00

Re: EventDeathMsg error
 
This will eliminate a few native calls and the last line of your code.

Untested
PHP Code:

#include < amxmodx >
#include < cstrike >
#include < fun > 

const VipFlags ADMIN_LEVEL_H;

new 
iMoney_Hs;
new 
iMoney_Kill;

new 
iHp_Max;
new 
iHp_Hs;
new 
iHp_Kill;

public 
plugin_init( ) {
    
register_plugin"PLUGIN" "VERSION" "AUTHOR" );
    
    
register_event"DeathMsg" "EventDeathMsg" "a" "1>0" );
    
    
iMoney_Hs register_cvar"amx_money_hs" "800" );
    
iMoney_Kill register_cvar"amx_money_kill" "500" );
    
    
iHp_Max register_cvar"amx_hp_max" "100" );
    
iHp_Hs register_cvar"amx_hp_hs" "30" );
    
iHp_Kill register_cvar"amx_hp_kill" "15" );
}

public 
EventDeathMsg( ) {
    new 
iKiller read_data);
    
    if( 
is_user_connectediKiller ) && ( get_user_flagsiKiller ) & VipFlags ) ) 
    {
        new 
iMoney iHealth iHPMax iHS;
        
        
iMoney cs_get_user_moneyiKiller );
        
iHealth get_user_healthiKiller );
        
iHPMax get_pcvar_numiHp_Max );
        
iHS read_data);
    
        if( 
iMoney 16000 )
            
cs_set_user_moneyiKiller clampiMoney get_pcvar_numiHS iMoney_Hs iMoney_Kill ) , 16000 ) );
        
        if( 
iHealth iHPMax )
            
set_user_healthiKiller clampiHealth get_pcvar_numiHS iHp_Hs iHp_Kill ) , iHPMax ) );
    }



asd13 07-15-2010 11:20

Re: EventDeathMsg error
 
Thank you. : )


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

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