AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Check if Attack has recieved damage from Victim (https://forums.alliedmods.net/showthread.php?t=339001)

MrPickles 08-09-2022 04:48

Check if Attack has recieved damage from Victim
 
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



EFFx 08-09-2022 05:14

Re: Check if Attack has recieved damage from Victim
 
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.

wilian159 08-09-2022 18:30

Re: Check if Attack has recieved damage from Victim
 
'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.

MrPickles 08-09-2022 20:07

Re: Check if Attack has recieved damage from Victim
 
Quote:

Originally Posted by wilian159 (Post 2786030)
'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...
     
}



wilian159 08-09-2022 20:19

Re: Check if Attack has recieved damage from Victim
 
your logic is wrong, you need to understand what you want to do, tell us, we can't guess

MrPickles 08-09-2022 20:21

Re: Check if Attack has recieved damage from Victim
 
Quote:

Originally Posted by wilian159 (Post 2786038)
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

EFFx 08-09-2022 21:47

Re: Check if Attack has recieved damage from Victim
 
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.

wilian159 08-10-2022 03:52

Re: Check if Attack has recieved damage from Victim
 
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?

MrPickles 08-11-2022 17:01

Re: Check if Attack has recieved damage from Victim
 
I have one dobut

PHP Code:

ExecuteHamHam_TakeDamageididid45.0); 

could this cause an error?, I want to use it to hurt myself

wilian159 08-11-2022 17:30

Re: Check if Attack has recieved damage from Victim
 
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)
    } 



All times are GMT -4. The time now is 11:48.

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