AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Problem with Damage[attacker] (https://forums.alliedmods.net/showthread.php?t=88171)

dogandcat 03-21-2009 10:54

Problem with Damage[attacker]
 
well, i cant put this to work.

Code:

#include <amxmodx>
#include <fun>
#include <zombieplague>
#include <hamsandwich>

new const item_name[] = "Danio Fijado (175)"
new g_itemid_damage
new g_damageselection[33]
new cvar_bladedamage

public plugin_init()
{
    register_plugin("[ZP] Damage Selection", "1.0", "MasI")
   
    register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
    register_clcmd("drop", "clcmd_drop")
   
    RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
   
   
    g_itemid_damage = zp_register_extra_item(item_name, 21, ZP_TEAM_HUMAN)
    cvar_bladedamage = register_cvar("zp_damage_selection", "175")
}

public zp_extra_item_selected(id,itemid)
{
    if(!is_user_alive(id))
   
    return PLUGIN_HANDLED;
   
    if(itemid==g_itemid_damage)
    {
        // Dont Drop
        g_damageselection[id] = true
        //hud
        new name[32]
        get_user_name(id, name, 31)
        set_hudmessage(0, 255, 0, 0.05, 0.45, 1, 0.0, 5.0, 1.0, 1.0, -1)
        show_hudmessage(0, "%s Se ah Comprado Damage !!!", name)
    }
    return PLUGIN_CONTINUE;
}

// Ham Take Damage Forward (inflictor = weapon)
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
{

    if (g_damageselection[attacker])
    {   
        // Set nemesis damage
        SetHamParamFloat(4, get_pcvar_float(cvar_bladedamage))
        return HAM_IGNORED;
    }
    return HAM_SUPERCEDE;
}

public clcmd_drop(id)
{
    if (g_damageselection[id])
        return PLUGIN_HANDLED;
   
    return PLUGIN_CONTINUE;
}

public event_round_start()
{
    for (new player; player <= 32; player++) g_damageselection[player] = false;
}


Bugsy 03-21-2009 11:45

Re: why it isnt working?damage.
 
Try changing the cvar to a float in the cvar register:
PHP Code:

cvar_bladedamage register_cvar("zp_damage_selection""175.0"


And replace HAM_IGNORED with HAM_OVERRIDE

PHP Code:

    if (g_damageselection[attacker])
    {    
        
// Set nemesis damage
        
SetHamParamFloat(4get_pcvar_float(cvar_bladedamage))
        return 
HAM_OVERRIDE;
    } 

The HAM_SUPERCEDE at the bottom should be HAM_IGNORED or else it will block all damage.

Arkshine 03-21-2009 11:47

Re: why it isnt working?damage.
 
OVERRIDE is not needed because you change on the fly, it should be HANDLED.

Bugsy 03-21-2009 11:49

Re: why it isnt working?damage.
 
Quote:

Originally Posted by arkshine (Post 785833)
OVERRIDE is not needed because you change on the fly, it should be HANDLED.

I was referring to this thread... I now see you also advised HAM_HANDLED is ok to use in the thread as well. :-B

http://forums.alliedmods.net/showthread.php?t=86940

dogandcat 03-21-2009 12:37

Re: why it isnt working?damage.
 
Code:

#include <amxmodx>
#include <fun>
#include <zombieplague>
#include <hamsandwich>

new const item_name[] = "Danio Fijado (175)"
new g_itemid_damage
new g_damageselection[33]
new cvar_bladedamage

public plugin_init()
{
    register_plugin("[ZP] Damage Selection", "1.0", "MasI")
   
    register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
    register_clcmd("drop", "clcmd_drop")
   
    RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
   
   
    g_itemid_damage = zp_register_extra_item(item_name, 21, ZP_TEAM_HUMAN)
    cvar_bladedamage  =  register_cvar("zp_damage_selection", "175.0")
}

public zp_extra_item_selected(id,itemid)
{
    if(!is_user_alive(id))
   
    return PLUGIN_HANDLED;
   
    if(itemid==g_itemid_damage)
    {
        // Dont Drop
        g_damageselection[id] = true
        //hud
        new name[32]
        get_user_name(id, name, 31)
        set_hudmessage(0, 255, 0, 0.05, 0.45, 1, 0.0, 5.0, 1.0, 1.0, -1)
        show_hudmessage(0, "%s Se ah Comprado Damage !!!", name)
    }
    return PLUGIN_CONTINUE;
}

// Ham Take Damage Forward (inflictor = weapon)
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
{

    if (g_damageselection[attacker])
    {   
        // Set nemesis damage
        SetHamParamFloat(4, get_pcvar_float(cvar_bladedamage))
        return HAM_OVERRIDE;
    }
    return HAM_IGNORED;
}

public clcmd_drop(id)
{
    if (g_damageselection[id])
        return PLUGIN_HANDLED;
   
    return PLUGIN_CONTINUE;
}

public event_round_start()
{
    for (new player; player <= 32; player++) g_damageselection[player] = false;
}

not working.

Code:

#include <amxmodx>
#include <fun>
#include <zombieplague>
#include <hamsandwich>

new const item_name[] = "Danio Fijado (175)"
new g_itemid_damage
new g_damageselection[33]
new cvar_bladedamage

public plugin_init()
{
    register_plugin("[ZP] Damage Selection", "1.0", "MasI")
   
    register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
    register_clcmd("drop", "clcmd_drop")
   
    RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
   
   
    g_itemid_damage = zp_register_extra_item(item_name, 21, ZP_TEAM_HUMAN)
    cvar_bladedamage  =  register_cvar("zp_damage_selection", "175.0")
}

public zp_extra_item_selected(id,itemid)
{
    if(!is_user_alive(id))
   
    return PLUGIN_HANDLED;
   
    if(itemid==g_itemid_damage)
    {
        // Dont Drop
        g_damageselection[id] = true
        //hud
        new name[32]
        get_user_name(id, name, 31)
        set_hudmessage(0, 255, 0, 0.05, 0.45, 1, 0.0, 5.0, 1.0, 1.0, -1)
        show_hudmessage(0, "%s Se ah Comprado Damage !!!", name)
    }
    return PLUGIN_CONTINUE;
}

// Ham Take Damage Forward (inflictor = weapon)
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
{

    if (g_damageselection[attacker])
    {   
        // Set nemesis damage
        SetHamParamFloat(4, get_pcvar_float(cvar_bladedamage))
        return HAM_HANDLED;
    }
    return HAM_IGNORED;
}

public clcmd_drop(id)
{
    if (g_damageselection[id])
        return PLUGIN_HANDLED;
   
    return PLUGIN_CONTINUE;
}

public event_round_start()
{
    for (new player; player <= 32; player++) g_damageselection[player] = false;
}

not working :S

Arkshine 03-21-2009 12:47

Re: why it isnt working?damage.
 
Try the Bugsy' suggestion. Replace HAM_IGNORE by HAM_HANDLED and HAM_SUPERCE by HAM_IGNORED.

dogandcat 03-21-2009 12:58

Re: why it isnt working?damage.
 
lets see...

dogandcat 03-21-2009 13:03

Re: why it isnt working?damage.
 
Code:

#include <amxmodx>
#include <fun>
#include <zombieplague>
#include <hamsandwich>

new const item_name[] = "Danio Fijado (XD)"
new g_itemid_damage
new g_damageselection[33]
new cvar_bladedamage

public plugin_init()
{
    register_plugin("[ZP] Damage Selection", "1.0", "MasI")
   
    register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
    register_clcmd("drop", "clcmd_drop")
   
    RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
   
   
    g_itemid_damage = zp_register_extra_item(item_name, 21, ZP_TEAM_HUMAN)
    cvar_bladedamage  =  register_cvar("zp_damage_selection", "175.0")
}

public zp_extra_item_selected(id,itemid)
{
    if(!is_user_alive(id))
   
    return PLUGIN_HANDLED;
   
    if(itemid==g_itemid_damage)
    {
        // Dont Drop
        g_damageselection[id] = true
        //hud
        new name[32]
        get_user_name(id, name, 31)
        set_hudmessage(0, 255, 0, 0.05, 0.45, 1, 0.0, 5.0, 1.0, 1.0, -1)
        show_hudmessage(0, "%s Se ah Comprado Damage !!!", name)
    }
    return PLUGIN_CONTINUE;
}

// Ham Take Damage Forward (inflictor = weapon)
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
{

    if (g_damageselection[attacker])
    {   
        // Set nemesis damage
        SetHamParamFloat(4, get_pcvar_float(cvar_bladedamage))
        return HAM_HANDLED;
    }
    return HAM_IGNORED;
}


public clcmd_drop(id)
{
    if (g_damageselection[id])
        return PLUGIN_HANDLED;
   
    return PLUGIN_CONTINUE;
}

public event_round_start()
{
    for (new player; player <= 32; player++) g_damageselection[player] = false;
}

Not working LOL

Bugsy 03-21-2009 14:01

Re: why it isnt working?damage.
 
I managed to get it to work by adding a multiplier of 2.0.

To test, go in your server and throw a nade and stand on it. It will only give 5 damage.

PHP Code:

new Float:g_fMultiplier 2.0;

public 
fw_TakeDamage(victiminflictorattackerFloat:damagedamage_type)
{
    
SetHamParamFloat5.0 g_fMultiplier );
    return 
HAM_HANDLED;



Exolent[jNr] 03-21-2009 18:24

Re: why it isnt working?damage.
 
Your topic's title must be descriptive. Fix it before posting again.


All times are GMT -4. The time now is 09:02.

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