Raised This Month: $ Target: $400
 0% 

Solved Damage Event not working?!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MihaiGamerXD
Member
Join Date: Aug 2018
Old 11-27-2018 , 16:08   Damage Event not working?!
Reply With Quote #1

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?

Last edited by MihaiGamerXD; 12-03-2018 at 12:45. Reason: It Worked
MihaiGamerXD is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-27-2018 , 21:42   Re: Damage Event not working?!
Reply With Quote #2

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.
__________________
fysiks is offline
MihaiGamerXD
Member
Join Date: Aug 2018
Old 11-28-2018 , 01:23   Re: Damage Event not working?!
Reply With Quote #3

I also tried with client_print() but still doesn't work! Oh yeah? It's a bug then!
MihaiGamerXD is offline
iceeedr
Veteran Member
Join Date: Apr 2017
Location: Brazil
Old 11-28-2018 , 06:40   Re: Damage Event not working?!
Reply With Quote #4

Read it, maybe it will help.

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


Quote:
Originally Posted by fysiks View Post
Please stop trying to help. You appear to just be posting random stuff. Wait until you actually understand more about AMX Mod X and how the game works.
https://iceeedr.com.br/
iceeedr is offline
Send a message via Skype™ to iceeedr
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 11-28-2018 , 08:20   Re: Damage Event not working?!
Reply With Quote #5

Quote:
Originally Posted by MihaiGamerXD View Post
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.
__________________

Last edited by HamletEagle; 11-28-2018 at 08:20.
HamletEagle is offline
MihaiGamerXD
Member
Join Date: Aug 2018
Old 11-28-2018 , 10:25   Re: Damage Event not working?!
Reply With Quote #6

How to debug? You mean to test the code?
MihaiGamerXD is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 11-28-2018 , 12:05   Re: Damage Event not working?!
Reply With Quote #7

I mean to put client_print messages before each if() statement to see where the execution of the code stops.
__________________
HamletEagle is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-28-2018 , 23:02   Re: Damage Event not working?!
Reply With Quote #8

Post the exact code that you used to "debug" your code.
__________________
fysiks is offline
MihaiGamerXD
Member
Join Date: Aug 2018
Old 12-01-2018 , 06:27   Re: Damage Event not working?!
Reply With Quote #9

Oh wait! It now works! Sorry for what happened. And one more thing: How to block Pick Up weapons Event when you're zombie?
MihaiGamerXD is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-01-2018 , 10:41   Re: Damage Event not working?!
Reply With Quote #10

Blocking weapon pickup has been covered many times. You would just need a condition to only block if zombie.
__________________

Last edited by Bugsy; 12-01-2018 at 10:42.
Bugsy is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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