AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   HE Bonus Plugin (https://forums.alliedmods.net/showthread.php?t=171623)

RuRuRu612754 11-08-2011 11:14

HE Bonus Plugin
 
I wrote a plugin I give you only kill the enemy with hand grenades health.

Once I get compile errors.

What do I do?

Code:

#include <amxmodx>
#include <fun>

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

        register_event("DeathMsg", "EventDeathMsg", "a", "1>0")
}

public EventDeathMsg()
{
            if(get_user_weapon() == CSW_HEGRENADE)
        {
                Bonus()
            }
}

public Bonus(id)
{
        client_print(id, print_center, "Since You killed the enemy with the HE\nYou add 25 to health")
        set_user_health(id, (get_user_health(id) + 25))
}


Blue Snake. 11-08-2011 11:27

Re: HE Bonus Plugin
 
PHP Code:

get_user_weapon(read_data(1))
Bonus(read_data(1)) 

But i think you'll need read_data(4, weapon, 31) (with new weapon[32] before) instead of get_user_weapon, but i don't know what name it will return for HE. You can test it by printing the 'weapon' string.

And if I've got the idea of your plugin, you should check if the killer is not the victim, becase you can suicide with the HE

PHP Code:

if(read_data(1) != read_data(2))
    
Bonus(read_data(1)) 

Or, an easy way:

PHP Code:

new killer read_data(1)
new 
victim read_data(2)
new 
weapon[32]
read_data(4weapon31


ConnorMcLeod 11-08-2011 11:57

Re: HE Bonus Plugin
 
register_event("DeathMsg", "EventDeathMsg_HeGrenade", "a", "1>0", "4=grenade")

Then you don't have to check weapon in callback.

RuRuRu612754 11-08-2011 21:09

Re: HE Bonus Plugin
 
thanks for all answer

@ConnorMcLeod

compile is success
However, the message is displayed to all players.
And health is not added

What should I do?

Code:

#include <amxmodx>
#include <fun>

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

        register_event("DeathMsg", "EventDeathMsgHeGrenade", "a", "1>0", "4=grenade")
}

public EventDeathMsgHeGrenade(id)
{
        client_print(id, print_center, "Since You killed the enemy with the HE\nYou add 25 to health")
        set_user_health(id, (get_user_health(id) + 25))
}


dark_style 11-09-2011 00:41

Re: HE Bonus Plugin
 
PHP Code:

public EventDeathMsgHeGrenade()
{
        static 
iKilleriVictim
        
        iKiller 
read_data)
        
iVictim read_data)
        
        if( 
iKiller != iVictim )
        {
                
client_printiKillerprint_center"Since You killed the enemy with the HE\nYou add 25 to health" )
                
                
set_user_healthiKillerget_user_healthiKiller ) + 25 )
        }



RuRuRu612754 11-09-2011 01:55

Re: HE Bonus Plugin
 
@dark_style

thanks

I was able to complete your thanks to this plugin


All times are GMT -4. The time now is 14:16.

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