Raised This Month: $ Target: $400
 0% 

EventDeathMsg error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
asd13
Member
Join Date: Apr 2009
Old 07-10-2010 , 19:01   EventDeathMsg error
Reply With Quote #1

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;

asd13 is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 07-10-2010 , 19:21   Re: EventDeathMsg error
Reply With Quote #2

Check if player is connected first.
__________________
hleV is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-10-2010 , 20:56   Re: EventDeathMsg error
Reply With Quote #3

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;

__________________

Last edited by Bugsy; 07-10-2010 at 21:08.
Bugsy is offline
asd13
Member
Join Date: Apr 2009
Old 07-15-2010 , 01:19   Re: EventDeathMsg error
Reply With Quote #4

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 ) );
    }

asd13 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-15-2010 , 09:00   Re: EventDeathMsg error
Reply With Quote #5

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 ) );
    }

__________________
Bugsy is offline
asd13
Member
Join Date: Apr 2009
Old 07-15-2010 , 11:20   Re: EventDeathMsg error
Reply With Quote #6

Thank you. : )
asd13 is offline
Reply



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 07:03.


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