Raised This Month: $ Target: $400
 0% 

Displaying bullet damage with HamSandwich


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 01-12-2009 , 08:58   Displaying bullet damage with HamSandwich
Reply With Quote #1

Hi. I got some problems with damage display using HamSandwich.
Code:
#include <amxmodx> #include <hamsandwich>   new g_iHudSyncObj;   public plugin_init() {         RegisterHam(Ham_TakeDamage, "player", "hTakeDamage", 1);           g_iHudSyncObj = CreateHudSyncObj(); }   public hTakeDamagePost(iVictim, iInflictor, iAttacker, Float:fDmg) {         if (!is_user_connected(iVictim) || !is_user_connected(iAttacker))                 return;           if (iVictim != iAttacker && get_user_team(iVictim) != get_user_team(iAttacker))         {                 set_hudmessage(200, 200, 200, -1.0, 0.46, 0, 6.0, 2.0, 0.1, 0.1, -1);                 ShowSyncHudMsg(iAttacker, g_iHudSyncObj, "%i^n", floatround(fDmg));         } }
Sometimes it shows more or less damage than the victim loses. Like you hit for 16, but victim lost only 8. Or you hit for 96, but victim (which had 100 HP) died.

For example use Glock's Burst-Fire mode and shoot to other player's head. It will show 96 while the other player is dead.

Anyone can suggest how to fix this?
__________________
hleV is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 01-12-2009 , 09:13   Re: Displaying bullet damage with HamSandwich
Reply With Quote #2

try to take a look into amxx super
__________________
xPaw is offline
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 01-12-2009 , 09:17   Re: Displaying bullet damage with HamSandwich
Reply With Quote #3

Quote:
For example use Glock's Burst-Fire mode and shoot to other player's head. It will show 96 while the other player is dead.
I thinks the bullet don't fire at the same time, and the last bullet makes that 96 dmg.

Anyway, i tried the same thing 2 weeks ago, and i maked the floatround before set_hudmessage, creating a variable.

PHP Code:
new dmg floatround(fDmg); 
__________________

anakin_cstrike is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 01-12-2009 , 09:39   Re: Displaying bullet damage with HamSandwich
Reply With Quote #4

It's clear with Glock. But still sometimes shows 10 more or less damage than the player lost.

Going to use 'Damage' event until someone will find out how to fix it.

EDIT: Also the floatround is a bit tricky in this case because it displays number which has +-1 difference from the real taken damage. I mean if I do 1.1 damage, floatround will make it 1, but the victim get 2 dmg, because it's more than 1. Any ideas how to solve it?
__________________

Last edited by hleV; 01-12-2009 at 09:53.
hleV is offline
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 01-12-2009 , 10:58   Re: Displaying bullet damage with HamSandwich
Reply With Quote #5

Well, i think it will always make 2dmg if it was 1.1 or other values between 1.1 and 1.9 . If you set the player's health at 1.x it will automatically change to 2 (hl)
__________________

anakin_cstrike is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 01-12-2009 , 11:34   Re: Displaying bullet damage with HamSandwich
Reply With Quote #6

Yes. But if the fFloat = 1.1, floatround(fFloat) = 1. So if I do 20.1 damage, player will lose 21 HP but it will print that he lost 20.
__________________

Last edited by hleV; 01-12-2009 at 11:43.
hleV is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-12-2009 , 11:49   Re: Displaying bullet damage with HamSandwich
Reply With Quote #7

Damage (arg4) is not the damage that the player will actually take.
It depends on DMG_TYPE, wepon, distance, armor...
To retrieve real damage, register the forward as post (as you did), and check pev_dmg_take player value.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-14-2009 , 14:31   Re: Displaying bullet damage with HamSandwich
Reply With Quote #8

Quote:
Originally Posted by ConnorMcLeod View Post
To retrieve real damage, register the forward as post (as you did), and check pev_dmg_take player value.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 01-14-2009 , 14:32   Re: Displaying bullet damage with HamSandwich
Reply With Quote #9

Ahh...i thought you were refering at his post
__________________

anakin_cstrike is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 01-12-2009 , 13:50   Re: Displaying bullet damage with HamSandwich
Reply With Quote #10

Thanks. Another question.
Code:
#include <amxmodx> #include <fakemeta> #include <hamsandwich>   new g_bCritHit[33];   public plugin_init() {         RegisterHam(Ham_TakeDamage, "player", "hTakeDamagePre");         RegisterHam(Ham_TakeDamage, "player", "hTakeDamagePost", 1); }   public hTakeDamagePre(iVictim, iInflictor, iAttacker, Float:fDmg) {         new iRandom = random_num(0, 100);           if (iRandom < 15) // 15% of success         {                 g_bCritHit[iAttacker] = true;                 new fMultiplier = random_float(1.5, 2.5);                   SetHamParamFloat(4, fDmg * fMultiplier);         } }   public hTakeDamagePost(iVictim, iInflictor, iAttacker, Float:fDmg) {         if (g_bCritHit[iAttacker])         {                 pev(iVictim, pev_dmg_take, fDmg);                   client_print(iAttacker, print_chat, "You've made a critical hit with %d damage", floatround(fDmg));                   g_bCritHit[iAttacker] = false;         } }

(example code, skipped connected/alive checks)

I want to print not only the total damage, but also the starting damage (which was multiplied) and multiplier. All in the same message.

Like this: You've made a critical hit: normal dmg: 10, dmg multiplier: 2, total dmg: 20

Of course I could do this with some global variables, but isn't there another way?
__________________

Last edited by hleV; 01-12-2009 at 13:53.
hleV is offline
Reply


Thread Tools
Display Modes

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 01:38.


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