AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Forward TakeDamage Doesn´t work (https://forums.alliedmods.net/showthread.php?t=135754)

S34Qu4K3 08-19-2010 10:40

Forward TakeDamage Doesn´t work
 
I´m making an extra item for Zombie Plague, but when I buy the extra item nothing happens, only show me the first client print

Full Code:
PHP Code:

#include <amxmodx> 
#include <amxmisc>
#include <zombieplague> 
#include <hamsandwich>

new g_thief
new boolthief_active[33]

public 
plugin_init()
{
    
    
register_plugin("[ZP] Extra Item: Ammo Packs Thief""1.0""S34Qu4K3"
    
g_thief zp_register_extra_item("Ammo Packs Thief"10ZP_TEAM_HUMAN
    
register_dictionary("zp_extra_ap_thief.txt")
    
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage"1)
    
}

public 
zp_extra_item_selected(iditemid
{
    if (
itemid == g_thief
    {

    
thief_active[id] = true
    client_print
(idprint_chat"In your next hit you will try to stole AmmoPacks from your victim")

    }
}  
public 
fw_TakeDamage(victiminflictorattackerFloat:damagedamage_type,id)
{
       
         if (
victim == attacker || ZP_TEAM_HUMAN)  
        return 
HAM_IGNORED
    
    
static damdam floatround(damage)
    
    new 
inflictorsap zp_get_user_ammo_packs(inflictor)
    new 
victimsap zp_get_user_ammo_packs(victim)
    
    
    if(
thief_active[id])
    {
        return 
HAM_IGNORED
    
}
    else
    {
        if(
dam <= 20)
        {
            if(
victimsap >= 1)
            {
                
zp_set_user_ammo_packs(victimvictimsap 1)
                
zp_set_user_ammo_packs(inflictorinflictorsap 1)
            }
            else
            {
                
client_print(idprint_chat"You haven't steal anything ")
            }
        }
        else if(
dam >= 40 && dam <= 59)
        {
            if(
victimsap >= 3)
            {
                
zp_set_user_ammo_packs(victimvictimsap 3)
                
zp_set_user_ammo_packs(inflictorinflictorsap 3)
            }
            else
            {
                
client_print(idprint_chat"You haven't steal anything ")
            }
        }
        else if(
dam >= 60 && dam <= 79)
        {
            if(
victimsap >= 5)
            {
                
zp_set_user_ammo_packs(victimvictimsap 5)
                
zp_set_user_ammo_packs(inflictorinflictorsap 5)
            }
            else
            {
                
client_print(idprint_chat"You haven't steal anything ")
            }
        }
        else if(
dam >= 80 && dam <= 99)
        {
            if(
victimsap >= 6)
            {
                
zp_set_user_ammo_packs(victimvictimsap 6)
                
zp_set_user_ammo_packs(inflictorinflictorsap 6)
            }
            else
            {
                
client_print(idprint_chat"You haven't steal anything ")
            }
        }
        else if(
dam >= 100 && dam <= 119)
        {
            if(
victimsap >= 8)
            {
                
zp_set_user_ammo_packs(victimvictimsap 8)
                
zp_set_user_ammo_packs(inflictorinflictorsap 8)
            }
            else
            {
                
client_print(idprint_chat"You haven't steal anything ")
            }
        }
        else if(
dam >= 120 && dam <= 149)
        {
            if(
victimsap >= 10)
            {
                
zp_set_user_ammo_packs(victimvictimsap 10)
                
zp_set_user_ammo_packs(inflictorinflictorsap 10)
            }
            else
            {
                
client_print(idprint_chat"You haven't steal anything ")
            }
        }
        else if(
dam >= 150 && dam <= 199)
        {
            if(
victimsap >= 10)
            {
                
zp_set_user_ammo_packs(victimvictimsap 12)
                
zp_set_user_ammo_packs(inflictorinflictorsap 12)
            }
            else
            {
                
client_print(idprint_chat"You haven't steal anything ")
            }
        }
        else if(
dam >= 200 && dam <= 499)
        {
            if(
victimsap >= 10)
            {
                
zp_set_user_ammo_packs(victimvictimsap 15)
                
zp_set_user_ammo_packs(inflictorinflictorsap 15)
            }
            else
            {
                
client_print(idprint_chat"You haven't steal anything ")
            }
        }
        
thief_active[id] = true
    
}
    return 
PLUGIN_CONTINUE
        



drekes 08-19-2010 10:42

Re: Forward TakeDamage Doesn´t work
 
Remove the id param in fw_TakeDamage

S34Qu4K3 08-19-2010 10:49

Re: Forward TakeDamage Doesn´t work
 
But, if i remove the param, i cant compile, undefined symbol in
PHP Code:

if(thief_active[id]) 

&
PHP Code:

client_print(id,.... 


SHould I use attacker instead of id ?

Arkshine 08-19-2010 10:58

Re: Forward TakeDamage Doesn´t work
 
The last param is the damageBits, nothing to do with the victim's index which is the first param...

S34Qu4K3 08-19-2010 11:12

Re: Forward TakeDamage Doesn´t work
 
We, i don´t understand you Arkshine, i´ve use bad the forward?

I tyried to put attacker instead of id and doesn´t work T_T

Bugsy 08-19-2010 13:19

Re: Forward TakeDamage Doesn´t work
 
Remove id from the forward param list. Replace id with victim in the forward code.

S34Qu4K3 08-19-2010 13:29

Re: Forward TakeDamage Doesn´t work
 
Doesn´t work

PHP Code:


#include <amxmodx> 
#include <amxmisc>
#include <zombieplague> 
#include <hamsandwich>

new g_thief
new boolthief_active[33]

public 
plugin_init()
{
    
    
register_plugin("[ZP] Extra Item: Ammo Packs Thief""1.0""S34Qu4K3"
    
g_thief zp_register_extra_item("Ammo Packs Thief"10ZP_TEAM_HUMAN
    
register_dictionary("zp_extra_ap_thief.txt")
    
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage"1)
    
}

public 
zp_extra_item_selected(iditemid
{
    if (
itemid == g_thief
    {

    
thief_active[id] = true
    client_print
(idprint_chat"In your next hit you will try to stole AmmoPacks from your victim")

    }
}  
public 
fw_TakeDamage(victiminflictorattackerFloat:damagedamage_type)
{
       
         if (
victim == attacker || ZP_TEAM_HUMAN)  
        return 
HAM_IGNORED
    
    
static damdam floatround(damage)
    
    new 
inflictorsap zp_get_user_ammo_packs(inflictor)
    new 
victimsap zp_get_user_ammo_packs(victim)
    
    
    if(
thief_active[victim])
    {
        return 
HAM_IGNORED
    
}
    else
    {
        if(
dam <= 20)
        {
            if(
victimsap >= 1)
            {
                
zp_set_user_ammo_packs(victimvictimsap 1)
                
zp_set_user_ammo_packs(inflictorinflictorsap 1)
            }
            else
            {
                
client_print(victimprint_chat"You haven't steal anything ")
            }
        }
        else if(
dam >= 40 && dam <= 59)
        {
            if(
victimsap >= 3)
            {
                
zp_set_user_ammo_packs(victimvictimsap 3)
                
zp_set_user_ammo_packs(inflictorinflictorsap 3)
            }
            else
            {
                
client_print(victimprint_chat"You haven't steal anything ")
            }
        }
        else if(
dam >= 60 && dam <= 79)
        {
            if(
victimsap >= 5)
            {
                
zp_set_user_ammo_packs(victimvictimsap 5)
                
zp_set_user_ammo_packs(inflictorinflictorsap 5)
            }
            else
            {
                
client_print(victimprint_chat"You haven't steal anything ")
            }
        }
        else if(
dam >= 80 && dam <= 99)
        {
            if(
victimsap >= 6)
            {
                
zp_set_user_ammo_packs(victimvictimsap 6)
                
zp_set_user_ammo_packs(inflictorinflictorsap 6)
            }
            else
            {
                
client_print(victimprint_chat"You haven't steal anything ")
            }
        }
        else if(
dam >= 100 && dam <= 119)
        {
            if(
victimsap >= 8)
            {
                
zp_set_user_ammo_packs(victimvictimsap 8)
                
zp_set_user_ammo_packs(inflictorinflictorsap 8)
            }
            else
            {
                
client_print(victimprint_chat"You haven't steal anything ")
            }
        }
        else if(
dam >= 120 && dam <= 149)
        {
            if(
victimsap >= 10)
            {
                
zp_set_user_ammo_packs(victimvictimsap 10)
                
zp_set_user_ammo_packs(inflictorinflictorsap 10)
            }
            else
            {
                
client_print(victimprint_chat"You haven't steal anything ")
            }
        }
        else if(
dam >= 150 && dam <= 199)
        {
            if(
victimsap >= 10)
            {
                
zp_set_user_ammo_packs(victimvictimsap 12)
                
zp_set_user_ammo_packs(inflictorinflictorsap 12)
            }
            else
            {
                
client_print(victimprint_chat"You haven't steal anything ")
            }
        }
        else if(
dam >= 200 && dam <= 499)
        {
            if(
victimsap >= 10)
            {
                
zp_set_user_ammo_packs(victimvictimsap 15)
                
zp_set_user_ammo_packs(inflictorinflictorsap 15)
            }
            else
            {
                
client_print(victimprint_chat"You haven't steal anything ")
            }
        }
        
thief_active[victim] = false
    
}
    return 
PLUGIN_CONTINUE
        



alan_el_more 08-19-2010 17:37

Re: Forward TakeDamage Doesn´t work
 
PHP Code:

if (victim == attacker || !zp_get_user_zombie(attacker))  
        return 
HAM_IGNORED 

and replace inflictor -> attacker


All times are GMT -4. The time now is 21:59.

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