AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [VIP] Show Damage - weird result (https://forums.alliedmods.net/showthread.php?t=189231)

SEnergyable 07-04-2012 20:15

[VIP] Show Damage - weird result
 
Hello,

I'm trying to do custom VIP plugin, everything works fine so far except showing damage, I've tried the plugin that's everyone using and it's working fine, so there's something wrong with my code; when I damage someone it will show 0 as damage, HOWEVER I've tried to show it in chat (client_print) and got result of 2 client prints, first one was normal damage and second was 0, therefore my hud message is always changed to that 0 after normal damage

so I've got output like this when I shot someone:

Quote:

Damage Report: 20
Damage Report: 0
and my hud message showed only 0

what's weird is that with HEgrenade it's working normally

Grenade: http://i.imgur.com/NfKem.png
Gun: http://i.imgur.com/h9wyE.png

source: (not whole ofc, only damage)

Code:

/* Plugin generated by AMXX-Studio */

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

#define PLUGIN "VIP"
#define VERSION "1.0"
#define AUTHOR "SEnergy!"

new g_MsgSync;

public plugin_init() {
        register_plugin(PLUGIN, VERSION, AUTHOR)
        register_event("Damage","myDmg","b")
        g_MsgSync = CreateHudSyncObj()
}

public myDmg(id)
{
        new attacker = get_user_attacker(id);
       
        if(is_user_connected(id) && is_user_connected(attacker))
        {
                if(get_user_team(id) != get_user_team(attacker))
                {
                        if(get_user_flags(attacker) & ADMIN_LEVEL_C)
                        {
                                new damage = read_data(2);
                                set_hudmessage(0, 100, 200, -1.0, 0.55, 2, 0.1, 4.0, 0.02, 0.02, -1)
                                ShowSyncHudMsg(attacker, g_MsgSync, "%i^n", damage)
                                client_print(attacker, print_chat, "Damage Report: %i", damage)
                        }
                }
        }
        return PLUGIN_HANDLED;
}


Liverwiz 07-04-2012 20:31

Re: [VIP] Show Damage - weird result
 
new t[32]; formatex(t, charsmax(t), "%d", damage)
ShowSyncHudMsg(attacker, g_MsgSync, t)

try that.

SEnergyable 07-05-2012 06:22

Re: [VIP] Show Damage - weird result
 
same result, any other ideas? :D

<VeCo> 07-05-2012 06:44

Re: [VIP] Show Damage - weird result
 
PHP Code:

register_event("Damage","myDmg","be","2>0"


SEnergyable 07-05-2012 09:37

Re: [VIP] Show Damage - weird result
 
Quote:

Originally Posted by <VeCo> (Post 1743775)
PHP Code:

register_event("Damage","myDmg","be","2>0"


well this works pretty much, except that when I hit the head it won't do anything, so it works only with normal hits, also it don't shows when I kill someone with grenade :X any suggestions?

edit: so far I noticed it's that it's not working with damage over 100 and when I kill someone with grenade :X

Liverwiz 07-05-2012 10:02

Re: [VIP] Show Damage - weird result
 
PHP Code:

register_event("DeathMsg""event_death""a"

Damage isn't fired when they die. That's misleading....But should work with grenades.
This might be weird with grenade kills, i'm not sure.
You're going to want to filter out id == 0 and id == id as to not register suicide or fall-death

SEnergyable 07-05-2012 10:12

Re: [VIP] Show Damage - weird result
 
Quote:

Originally Posted by Liverwiz (Post 1743882)
PHP Code:

register_event("DeathMsg""event_death""a"

Damage isn't fired when they die. That's misleading....But should work with grenades.
This might be weird with grenade kills, i'm not sure.
You're going to want to filter out id == 0 and id == id as to not register suicide or fall-death

what about that damage higher than 100?

<VeCo> 07-05-2012 10:44

Re: [VIP] Show Damage - weird result
 
I would use Ham_TakeDamage. It's more controllable.

SEnergyable 07-05-2012 10:55

Re: [VIP] Show Damage - weird result
 
super edit: holy fck, I had "e" flag in register_event -.-'


All times are GMT -4. The time now is 15:19.

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