SA-MP Forums Archive
OnPlayerTakeDamage don't work with sniper - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP (https://sampforum.blast.hk/forumdisplay.php?fid=3)
+--- Forum: Bug Reports (https://sampforum.blast.hk/forumdisplay.php?fid=20)
+--- Thread: OnPlayerTakeDamage don't work with sniper (/showthread.php?tid=377222)



OnPlayerTakeDamage don't work with sniper - DartakousLien - 13.09.2012

hello everyone, well, here I was thinking of trying something and then I remembered this callback
but I found a problem, it does not work with sniper ... works with other weapons, but not with sniper. why?
this is bug?

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    if(weaponid==WEAPON_SNIPER)
    {
        SetPlayerHealth(playerid,0.0);
    }
    return 1;
}
https://sampwiki.blast.hk/wiki/OnPlayerTakeDamage


Re: OnPlayerTakeDamage don't work with sniper - Eric - 13.09.2012

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    if(weaponid == 34)
    {
        SetPlayerHealth(playerid,0.0);
    }
    return 1;
}
Try that.


Re: OnPlayerTakeDamage don't work with sniper - DartakousLien - 13.09.2012

I already tried that
thanks


Re: OnPlayerTakeDamage don't work with sniper - N0FeaR - 13.09.2012

Is working now?


Re: OnPlayerTakeDamage don't work with sniper - Lordzy - 14.09.2012

Try this.
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    if(GetPlayerWeapon(playerid) == 34)
    {
        SetPlayerHealth(playerid,0.0);
    }
    return 1;
}



Re: OnPlayerTakeDamage don't work with sniper - SuperViper - 14.09.2012

Unconfirmed.

I tested this with five sniper shots, each one being further apart from the target.



This is my test code:
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID)
    {
        if(weaponid == 34)
        {
            printf("(C1) OnPlayerTakeDamage(%d, %d, %f, %d),(DISTANCE: %f)", playerid, issuerid, amount, weaponid, GetDistanceBetweenPlayers(playerid, issuerid));
        }
        else if(GetPlayerWeapon(issuerid) == 34)
        {
            printf("(C2) OnPlayerTakeDamage(%d, %d, %f, %d), (DISTANCE: %f)", playerid, issuerid, amount, weaponid, GetDistanceBetweenPlayers(playerid, issuerid));
        }
    }
   
    return 1;
}


These are my results:
pawn Код:
[19:46:00] (C1) OnPlayerTakeDamage(0, 1, 41.250000, 34),(DISTANCE: 14.662270)
[19:46:13] (C1) OnPlayerTakeDamage(0, 1, 41.250000, 34),(DISTANCE: 43.184646)
[19:46:37] (C1) OnPlayerTakeDamage(0, 1, 41.250000, 34),(DISTANCE: 86.199714)
[19:46:48] (C1) OnPlayerTakeDamage(0, 1, 41.250000, 34),(DISTANCE: 114.422538)
[19:47:08] (C1) OnPlayerTakeDamage(0, 1, 41.250000, 34),(DISTANCE: 145.569320)



Re: OnPlayerTakeDamage don't work with sniper - TheArcher - 14.09.2012

@SuperViper So GetPlayerWeapon doesn't work at all on that callback?


Re: OnPlayerTakeDamage don't work with sniper - Roko_foko - 14.09.2012

Quote:
Originally Posted by TheArcher
Посмотреть сообщение
@SuperViper So GetPlayerWeapon doesn't work at all on that callback?
You can't know that from code he posted( because it's inside of else which isn't called ). You can only know that when player shoots another player with sniper it WORKS.


Re: OnPlayerTakeDamage don't work with sniper - SuperViper - 14.09.2012

Quote:
Originally Posted by TheArcher
Посмотреть сообщение
@SuperViper So GetPlayerWeapon doesn't work at all on that callback?
Both cases should work, but the second one wasn't even checked for because it was in an else if statement, which will never be executed if the statement before is true.