Raised This Month: $ Target: $400
 0% 

Check if Attack has recieved damage from Victim


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MrPickles
Member
Join Date: Aug 2022
Location: Colombia
Old 08-09-2022 , 04:48   Check if Attack has recieved damage from Victim
Reply With Quote #1

PHP Code:
public @PlayerTakeDamage__int_Victim__int_Inflictor__int_AttackerFloat:__float_Damage__int_DamageBits 
{
      
// In this exact moment, how can i check if the attacker has been received damage from victim too?, Attacker == Attacker doesnt work cause this mean that u hurt u yourself

MrPickles is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 08-09-2022 , 05:14   Re: Check if Attack has recieved damage from Victim
Reply With Quote #2

This triggers when you damage someone. The parameters are who took damage, who received and how much damage was taken (the last parameter is barely used). You cannot detect both at the same time.

What you can do, is making a 2D interger that grabs the damage you received, so you can see if the person you've damaged, had damaged you before.
__________________
EFFx is offline
wilian159
Member
Join Date: Dec 2013
Old 08-09-2022 , 18:30   Re: Check if Attack has recieved damage from Victim
Reply With Quote #3

'victim' is always the one who takes the damage, if you take the damage you are the 'victim'

what you need to do is check if the 'victim' is x thing, and x thing etc.
__________________
Hmm, nice....... www.addonscs.com
wilian159 is offline
MrPickles
Member
Join Date: Aug 2022
Location: Colombia
Old 08-09-2022 , 20:07   Re: Check if Attack has recieved damage from Victim
Reply With Quote #4

Quote:
Originally Posted by wilian159 View Post
'victim' is always the one who takes the damage, if you take the damage you are the 'victim'

what you need to do is check if the 'victim' is x thing, and x thing etc.
PHP Code:
public @PlayerTakeDamage__int_Victim__int_Inflictor__int_AttackerFloat:__float_Damage__int_DamageBits 
{
      
g_Victim[__int_Attacker] = __int_Victim;

      if( 
__int_Attacker == g_Victim[__int_Victim])
     {
            
// Probably this will works, but even when they damage each other, one of they, i mean, one forward it will be executed before than the other...
     
}

MrPickles is offline
wilian159
Member
Join Date: Dec 2013
Old 08-09-2022 , 20:19   Re: Check if Attack has recieved damage from Victim
Reply With Quote #5

your logic is wrong, you need to understand what you want to do, tell us, we can't guess
__________________
Hmm, nice....... www.addonscs.com
wilian159 is offline
MrPickles
Member
Join Date: Aug 2022
Location: Colombia
Old 08-09-2022 , 20:21   Re: Check if Attack has recieved damage from Victim
Reply With Quote #6

Quote:
Originally Posted by wilian159 View Post
your logic is wrong, you need to understand what you want to do, tell us, we can't guess
???????????? what are u talking about?? i think u dont understand( the example is very clear )

pd: if u dont understand dont post nonsense to gain posts and dont try to reply cause i will not read u

Last edited by MrPickles; 08-09-2022 at 20:23.
MrPickles is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 08-09-2022 , 21:47   Re: Check if Attack has recieved damage from Victim
Reply With Quote #7

PHP Code:
g_Victim[__int_Victim] = __int_Attacker 
As soon as you damage someone, the victim will catch your id.
And then, when damaging again, use

PHP Code:
if(g_Damage[__int_Attacker] == __int_Victim
This will return true if the victim has damaged you before.
Your #4 sample was just in reverse, but you got the idea right.
__________________
EFFx is offline
wilian159
Member
Join Date: Dec 2013
Old 08-10-2022 , 03:52   Re: Check if Attack has recieved damage from Victim
Reply With Quote #8

as I said, the one who suffers the damage will always be the 'victim', from the moment you (attacker) suffer damage you are the 'victim', you know?
__________________
Hmm, nice....... www.addonscs.com
wilian159 is offline
MrPickles
Member
Join Date: Aug 2022
Location: Colombia
Old 08-11-2022 , 17:01   Re: Check if Attack has recieved damage from Victim
Reply With Quote #9

I have one dobut

PHP Code:
ExecuteHamHam_TakeDamageididid45.0); 
could this cause an error?, I want to use it to hurt myself
MrPickles is offline
wilian159
Member
Join Date: Dec 2013
Old 08-11-2022 , 17:30   Re: Check if Attack has recieved damage from Victim
Reply With Quote #10

this code is from my 'hegrenade', it deals X ray damage
maybe i can help you

PHP Code:
new xVictim = -1

    
while((xVictim engfunc(EngFunc_FindEntityInSpherexVictimxAtkOrigin300.0)) != 0)
    {
        if(!
is_user_alive(xVictim))
            continue

        new 
Float:xOrigin[3], Float:xDistanceFloat:xDamage
        pev
(xVictimpev_originxOrigin)

        
xDistance get_distance_f(xOriginxAtkOrigin)
        
xDamage 100.0 floatmul(100.0floatdiv(xDistance300.0))
        
xDamage *= 1.0

        
if(xDamage 1.0)
            continue

        
ExecuteHamB(Ham_TakeDamagexVictimxEntxAttackerxDamageDMG_GRENADE)
    } 
__________________
Hmm, nice....... www.addonscs.com
wilian159 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 22:28.


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