AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [help] error on health add (https://forums.alliedmods.net/showthread.php?t=250960)

indraraj striker 11-02-2014 22:18

[help] error on health add
 
if u know about first blood kill
In map de_dust 2
when you are using mid you killed one enemy, you got first blood + some hp and instant other enemy killed you.
Health didnt add to attacker at the time this error will create someone help me
how to solve ?
Thanks in advanced :)

Quote:

[FUN] Player out of range (0)
[AMXX] Displaying debug trace (plugin "firstblood.amxx")
[AMXX] Run time error 10: native error (native "set_user_health")
https://forums.alliedmods.net/showth...ght=blood+kill

ghost95v 11-03-2014 00:43

Re: [help] error on health add
 
show the source code.

zmd94 11-03-2014 02:18

Re: [help] error on health add
 
Just need to check whether the attacker is alive or not. ;)

Just use below:
PHP Code:

/* Plugin generated by AMXX-Studio */

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

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

new boolg_bFirstKill

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event "DeathMsg""event_death""a" )
    
register_event "HLTV""event_new_round""a""1=0""2=0" )  
}

public 
plugin_precache ( )
{
    
// Precache our custom sound when first blood is happen
    
precache_sound "misc/firstblood.wav" );  
}

public 
event_death ( )
{
    new 
attacker read_data )
    
    
// If the attacker is dead or 
    // the attacker is the same with the victim (this mean the player has committed suicide, 
    // then the first blood reward will be paused
    
if ( !is_user_alive(attacker) || attacker == read_data ) )
        return
    
    
// If there is still nobody drew a first blood
    
if ( ! g_bFirstKill )
    {
        
        
// First blood has happen
        
g_bFirstKill true
        
        
// The reward for first blood
        
cs_set_user_money attackercs_get_user_money attacker ) + 2000 )
        
set_user_health attackerget_user_health attacker ) + 15 )
        
set_user_armor  attackerget_user_armor attacker ) + 15 )
        
        
// Emit a sound
        
emit_sound0CHAN_AUTO"misc/firstblood.wav"0.7ATTN_NORM0PITCH_NORM );
    }
}

public 
event_new_round ( )
{
    
// Reset our first blood in the new round
    
g_bFirstKill false  



zmd94 11-03-2014 04:38

Re: [help] error on health add
 
read_data(2) is to detect the victim.

indraraj striker 11-03-2014 04:43

Re: [help] error on health add
 
Quote:

Originally Posted by zmd94 (Post 2219489)
read_data(2) is to detect the victim.

Thanks :)
btw u need to define
new victim=read_data(2)

zmd94 11-03-2014 04:45

Re: [help] error on health add
 
It is not so important, but it is not wrong to do it. ;)

indraraj striker 11-03-2014 04:46

Re: [help] error on health add
 
Quote:

Originally Posted by zmd94 (Post 2219491)
It is not so important, but it is not wrong to do it. ;)

opps oki

indraraj striker 11-03-2014 04:59

Re: [help] error on health add
 
Quote:

Originally Posted by zmd94 (Post 2219491)
It is not so important, but it is not wrong to do it. ;)

what about if player get killled by camping
[walkguard plugin]

zmd94 11-03-2014 05:07

Re: [help] error on health add
 
As far as I know when someone is being killed by camping, it is most likely the player is committed suicide. So, when we have this check attacker == read_data ( 2 ), it will not effect the first blood plugin. ;)

indraraj striker 11-03-2014 05:23

Re: [help] error on health add
 
Quote:

Originally Posted by zmd94 (Post 2219497)
As far as I know when someone is being killed by camping, it is most likely the player is committed suicide. So, when we have this check attacker == read_data ( 2 ), it will not effect the first blood plugin. ;)

k


All times are GMT -4. The time now is 17:42.

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