AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Damage Event not working?! (https://forums.alliedmods.net/showthread.php?t=312343)

MihaiGamerXD 11-27-2018 16:08

Damage Event not working?!
 
Hello and I don't understand why the damage event is not working?

Here is the code:
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
#include <hamsandwich>

static zombie[33]

public 
plugin_init() {
    
register_plugin("Block Damage","1.0","MihaiGamerXD")
    
RegisterHam(Ham_TakeDamage,"player","onDamage")
    
register_event("HLTV""onNewRound""a","1=0","2=0")
}

public 
onNewRound() {
    new 
id get_random_player("a")
    
cs_set_user_team(id,CS_TEAM_T)
    
zombie[id] = true
}

public 
onDamage(victiminflictorattackerFloat:damagedmg_bits) {
        if (
zombie[attacker]) {
        new 
last get_birds("a");
        if (
last == 1)
            return 
HAM_IGNORED;
        
        
cs_set_user_team(victim,CS_TEAM_T);
        
set_user_health(victim,500);
        
strip_user_weapons(victim);
        
give_item(victim,"weapon_ak47");
        return 
HAM_SUPERCEDE;
    }
    
    return 
HAM_IGNORED;
}

stock get_random_player(const flags[]="", const team[]="") {
    new 
players[32], pnum;
    
get_players(playerspnumflagsteam);
    
    return (
pnum 0) ? players[random(pnum)] : -1;
}

stock get_birds(const flags[]="", const team[]="") {
    new 
players[32], pnumbirdsid;
    
get_players(playerspnumflagsteam);

    for (--
pnumpnum >= 0pnum--)
    {
        
id players[pnum];

        if (!
zombie[id])
            
birds++;
    }

    return 
birds;


And it doesn't work, it doesn't do nothing! Is something wrong or it's a bug?

fysiks 11-27-2018 21:42

Re: Damage Event not working?!
 
How is the damage event not working? Does onDamage() ever get called? Add a client_print() to onDamage() and see if it's being executed.

If that works, you need to debug your code incrementally. Add a bunch of prints in there to see what values are occurring so that you can track down what is and isn't being executed and why.

MihaiGamerXD 11-28-2018 01:23

Re: Damage Event not working?!
 
I also tried with client_print() but still doesn't work! Oh yeah? It's a bug then!

iceeedr 11-28-2018 06:40

Re: Damage Event not working?!
 
Read it, maybe it will help.

https://forums.alliedmods.net/showpo...8&postcount=71

HamletEagle 11-28-2018 08:20

Re: Damage Event not working?!
 
Quote:

Originally Posted by MihaiGamerXD (Post 2625934)
I also tried with client_print() but still doesn't work! Oh yeah? It's a bug then!

If there's a bug, it is in your code. Functions from hamsandwich CAN NOT be bugged.
Debug the code properly.

MihaiGamerXD 11-28-2018 10:25

Re: Damage Event not working?!
 
How to debug? You mean to test the code?

HamletEagle 11-28-2018 12:05

Re: Damage Event not working?!
 
I mean to put client_print messages before each if() statement to see where the execution of the code stops.

fysiks 11-28-2018 23:02

Re: Damage Event not working?!
 
Post the exact code that you used to "debug" your code.

MihaiGamerXD 12-01-2018 06:27

Re: Damage Event not working?!
 
Oh wait! It now works! Sorry for what happened. And one more thing: How to block Pick Up weapons Event when you're zombie?

Bugsy 12-01-2018 10:41

Re: Damage Event not working?!
 
Blocking weapon pickup has been covered many times. You would just need a condition to only block if zombie.


All times are GMT -4. The time now is 07:36.

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