OnPlayerTakeDamage don't work with sniper
#1

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
Reply
#2

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

I already tried that
thanks
Reply
#4

Is working now?
Reply
#5

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

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)
Reply
#7

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

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.
Reply
#9

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.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)