Raised This Month: $32 Target: $400
 8% 

[HELP] Regarding event_damage function


Post New Thread Reply   
 
Thread Tools Display Modes
TheSpaniard
Senior Member
Join Date: Jul 2017
Location: Hell
Old 10-07-2017 , 04:20   Re: [HELP] Regarding event_damage function
Reply With Quote #11

Quote:
Originally Posted by siriusmd99 View Post
Your way of thinking is really strange...
You cannot call it from other function and multiply damage outside the hook function.


If you want to do this just use standard ham Take damage and check some bools set from other functions.

For example I make a plugin which gives me possibility to have 2x more damage by activating some kind of extra energy potion (out of imagination, sorry).
For example you want it to last like for 10 seconds.

So you hook impulse (flashlight, standard when you press f) and when you press f function activate_damage will be called.

In this plugin you just set the time when this will end like
g_endtime[player] =get systime + how_many_seconds


Then in ham take damage you check
If get systime - g_endtime[player] >= 0
//then multiply damage or other stuff you want

Try to think more abstract instead of inventing weird things..
I am not calling anything outside the hook see this :-
PHP Code:
public fw_takedamage(iClientiInflictoriAttackerFloat:fDamagem_Damagebits)
{
    if(
is_user_alive(iClient) && is_user_alive(iAttacker) && iInflictor == CSW_AK47||CSW_M4A1||CSW_AWP)
    {
        
SetHamParamFloat(4fDamage*get_pcvar_float(CVAR_DAMAGE_MULTI))
    }
    return 
HAM_IGNORED

As the code suggests i want the damage multiplied in specific case where the inflictor is m4a1 and ak47 and awp
The Catch:-
These are not the only conditions i want to apply i want the ham to be executed only when it is called in a specific case, in switch condition or the above ham would be executed on all ak47 or awp or m4a1 skins i am putting in the plugin.

EDIT: The above code is done immediately after crazy's answer, this for people who can say that i am a copycat not a programmer.
__________________
And I Am Back.

Last edited by TheSpaniard; 10-07-2017 at 04:26. Reason: SEE THE EDIT
TheSpaniard is offline
DjSoftero
Veteran Member
Join Date: Nov 2014
Location: Lithuania
Old 10-07-2017 , 04:46   Re: [HELP] Regarding event_damage function
Reply With Quote #12

Quote:
Originally Posted by TheSpaniard View Post
I am not calling anything outside the hook see this :-
PHP Code:
public fw_takedamage(iClientiInflictoriAttackerFloat:fDamagem_Damagebits)
{
    if(
is_user_alive(iClient) && is_user_alive(iAttacker) && iInflictor == CSW_AK47||CSW_M4A1||CSW_AWP)
    {
        
SetHamParamFloat(4fDamage*get_pcvar_float(CVAR_DAMAGE_MULTI))
    }
    return 
HAM_IGNORED

As the code suggests i want the damage multiplied in specific case where the inflictor is m4a1 and ak47 and awp
The Catch:-
These are not the only conditions i want to apply i want the ham to be executed only when it is called in a specific case, in switch condition or the above ham would be executed on all ak47 or awp or m4a1 skins i am putting in the plugin.

EDIT: The above code is done immediately after crazy's answer, this for people who can say that i am a copycat not a programmer.
inflictor is usualy the attacker, unless it`s the grenade so you can`t compare it that way. also if inflictor was gun it should be inflictor == csw_awp || incfilctor == csw_ak47 || inflicotr ==... etc. but again. inflicotr is not gun entity. so dont do it
__________________
retired chump

Last edited by DjSoftero; 10-07-2017 at 04:47.
DjSoftero is offline
TheSpaniard
Senior Member
Join Date: Jul 2017
Location: Hell
Old 10-07-2017 , 04:53   Re: [HELP] Regarding event_damage function
Reply With Quote #13

Quote:
Originally Posted by DjSoftero View Post
inflictor is usualy the attacker, unless it`s the grenade so you can`t compare it that way. also if inflictor was gun it should be inflictor == csw_awp || incfilctor == csw_ak47 || inflicotr ==... etc. but again. inflicotr is not gun entity. so dont do it
it says victim is the person on which the damage is executed, attacker is the owner of the inflictor and inflictor is the entity by which the direct damage is inflicted for example knife.
__________________
And I Am Back.
TheSpaniard is offline
Old 10-07-2017, 07:43
DjSoftero
This message has been deleted by DjSoftero.
DjSoftero
Veteran Member
Join Date: Nov 2014
Location: Lithuania
Old 10-07-2017 , 07:52   Re: [HELP] Regarding event_damage function
Reply With Quote #14

accidently deleted message. amazing...

look at this: https://forums.alliedmods.net/showthread.php?t=82334

Inflictor is the entity that caused the damage directly to the victim. For knife/guns attacker is the inflictor.

If you don`t believe me, then do the research/testing part on your won.
__________________
retired chump
DjSoftero is offline
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 10-07-2017 , 07:55   Re: [HELP] Regarding event_damage function
Reply With Quote #15

Quote:
Originally Posted by TheSpaniard View Post
it says victim is the person on which the damage is executed, attacker is the owner of the inflictor and inflictor is the entity by which the direct damage is inflicted for example knife.
That's incorrect, when it's a player directly inflicting the damage(using a weapon) inflictor will always be the same as attacker.

Inflictor will contain non-player entity id for things such as nade explosions, c4 explodes or other sorts of custom damages such as spawning an env_explosion


Here's how to do damage bonuses on different weapons

Code:
//Inside ham takedamage to double knife damage if(is_user_connected(attacker) && attacker == inflictor && get_user_weapon(attacker) == CSW_KNIFE) {     SetHamParamFloat(4, damage * 2);   }

code can be replicated for other or multiple weapons
if you have more than one then I would strongly suggest you do a switch for get_user_weapon()
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.

Last edited by aron9forever; 10-07-2017 at 07:55.
aron9forever is offline
DeMNiX
Veteran Member
Join Date: Nov 2011
Location: Russia
Old 10-08-2017 , 04:52   Re: [HELP] Regarding event_damage function
Reply With Quote #16

Quote:
Originally Posted by TheSpaniard
public fw_takedamage(iClient, iInflictor, iAttacker, Float:fDamage, m_Damagebits)
{
if(is_user_alive(iClient) && is_user_alive(iAttacker) && iInflictor == CSW_AK47||CSW_M4A1||CSW_AWP)
{
SetHamParamFloat(4, fDamage*get_pcvar_float(CVAR_DAMAGE_MULTI))
}
return HAM_IGNORED
}
PHP Code:
 iInflictor == CSW_AK47||CSW_M4A1||CSW_AWP 
did u test it? i think not



PHP Code:
 (is_user_alive(iClient
it's unnecessary code. Player that tooks damage can't be invalid



PHP Code:
 //checks knife damage
if (m_Damagebits & (DMG_BULLET DMG_NEVERGIB )) 
__________________
My channel with test codes
https://www.youtube.com/user/demnix03

Zombie Riot [Scenario & bots-zombie 11.11.2023]
https://youtu.be/8ZZan-aq2sc

Last edited by DeMNiX; 10-08-2017 at 06:07.
DeMNiX is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-08-2017 , 06:04   Re: [HELP] Regarding event_damage function
Reply With Quote #17

This check is incorrect

iInflictor == CSW_AK47||CSW_M4A1||CSW_AWP
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
DeMNiX
Veteran Member
Join Date: Nov 2011
Location: Russia
Old 10-08-2017 , 06:16   Re: [HELP] Regarding event_damage function
Reply With Quote #18

PHP Code:
public fw_takedamage(iClientiInflictoriAttackerFloat:fDamagem_Damagebits)
{
     if(~
m_Damagebits & (DMG_BULLET DMG_NEVERGIB )) return HAM_IGNORED// if not knife attack return;
     //some yours conditions here
     // no needs to checking on attacker becouse it's knife attack. No needs to check victim
     
if (!you_condition) return HAM_IGNORED;

     
SetHamParamFloat(4fDamage*get_pcvar_float(CVAR_DAMAGE_MULTI))
     return 
HAM_IGNORED;

__________________
My channel with test codes
https://www.youtube.com/user/demnix03

Zombie Riot [Scenario & bots-zombie 11.11.2023]
https://youtu.be/8ZZan-aq2sc
DeMNiX is offline
TheSpaniard
Senior Member
Join Date: Jul 2017
Location: Hell
Old 10-08-2017 , 06:35   Re: [HELP] Regarding event_damage function
Reply With Quote #19

Quote:
Originally Posted by DeMNiX View Post
PHP Code:
public fw_takedamage(iClientiInflictoriAttackerFloat:fDamagem_Damagebits)
{
     if(~
m_Damagebits & (DMG_BULLET DMG_NEVERGIB )) return HAM_IGNORED// if not knife attack return;
     //some yours conditions here
     // no needs to checking on attacker becouse it's knife attack. No needs to check victim
     
if (!you_condition) return HAM_IGNORED;

     
SetHamParamFloat(4fDamage*get_pcvar_float(CVAR_DAMAGE_MULTI))
     return 
HAM_IGNORED;

Doesn't anybody think for my case event_damage makes more sense. Because i want it for multiple weapons??
__________________
And I Am Back.

Last edited by TheSpaniard; 10-08-2017 at 06:35.
TheSpaniard is offline
DeMNiX
Veteran Member
Join Date: Nov 2011
Location: Russia
Old 10-08-2017 , 06:44   Re: [HELP] Regarding event_damage function
Reply With Quote #20

Quote:
Originally Posted by TheSpaniard View Post
Doesn't anybody think for my case event_damage makes more sense. Because i want it for multiple weapons??
PHP Code:
public fw_takedamage(iClientiInflictoriAttackerFloat:fDamagem_Damagebits)
{
     if(
m_Damagebits & (DMG_BULLET DMG_NEVERGIB )) { //if knife attack;
     //some yours conditions here
     // no needs to checking on attacker becouse it's knife attack. No needs to check victim
     
if (!you_condition) return HAM_IGNORED;

     
SetHamParamFloat(4fDamage*get_pcvar_float(CVAR_DAMAGE_MULTI))
     }
     else if(
m_Damagebits DMG_BULLET) {
            
// Check active item of attacker here and set the damage

      
     


    return 
HAM_IGNORED;

__________________
My channel with test codes
https://www.youtube.com/user/demnix03

Zombie Riot [Scenario & bots-zombie 11.11.2023]
https://youtu.be/8ZZan-aq2sc
DeMNiX 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 03:35.


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