SA-MP Forums Archive
SAMP Hit detection isn't accurate? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: SAMP Hit detection isn't accurate? (/showthread.php?tid=562965)



SAMP Hit detection isn't accurate? - Dokins - 13.02.2015

It detected a headshot and chest shot when I shot them in the leg with a desert eagle...Why would this happen?

Is there something wrong with my code or is it a SAMP problem?

This is all under OnPlayerTakeDamage.
pawn Код:
if(bodypart == 3)
    {
        TextDrawShowForPlayer(playerid,TorsoBlTD);
        if(TorsoBl[playerid] < 5)
        {
           TorsoBl[playerid] ++;
            printf("Hits %d", TorsoBl[playerid]);
            if(IsMaxDamageWep(weaponid) == 1)
            {
                BodyPartAmount[playerid][3] = 6;
            }
            else if(IsMaxDamageWep(weaponid) == 0)
            {
                BodyPartAmount[playerid][3] = 3;
            }
        }
    }
    if(bodypart == 4)
    {
        TextDrawShowForPlayer(playerid,GroinBlTD);
        if(GroinBl[playerid] < 5)
        {
           GroinBl[playerid] ++;
            printf("Hits %d", GroinBl[playerid]);
            if(IsMaxDamageWep(weaponid) == 1)
            {
                BodyPartAmount[playerid][4] = 3;
            }
            else if(IsMaxDamageWep(weaponid) == 0)
            {
                BodyPartAmount[playerid][4] = 1;
            }
        }
    }
    if(bodypart == 5)
    {
        TextDrawShowForPlayer(playerid,LArmBlTD);
        if(LArmBl[playerid] < 5)
        {
           LArmBl[playerid] ++;
            if(IsMaxDamageWep(weaponid) == 1)
            {
                BodyPartAmount[playerid][5] = 1;
                new num = RandomEx(1,5);
                if(num == 3)
                {
                    TextDrawHideForPlayer(playerid,LArmBlTD);
                    TextDrawShowForPlayer(playerid,LArmBlab);
                    LArmBr[playerid] = 1;
                }
            }
            else if(IsMaxDamageWep(weaponid) == 0)
            {
                BodyPartAmount[playerid][5] = 1;
            }
        }
    }
    if(bodypart == 6)
    {
        TextDrawShowForPlayer(playerid,RArmBlTD);
        if(RArmBl[playerid] < 5)
        {
           RArmBl[playerid] ++;
            if(IsMaxDamageWep(weaponid) == 1)
            {
                BodyPartAmount[playerid][6] = 2;
                new num = RandomEx(1,5);
                if(num == 2)
                {
                    TextDrawHideForPlayer(playerid,RArmBlTD);
                    TextDrawShowForPlayer(playerid,RArmBlab);
                    RArmBr[playerid] = 1;
                }
            }
            else if(IsMaxDamageWep(weaponid) == 0)
            {
                BodyPartAmount[playerid][6] = 1;
            }
        }
    }
    if(bodypart == 7)
    {
        TextDrawShowForPlayer(playerid,LLegBlTD);
        if(LLegBl[playerid] < 5)
        {
           LLegBl[playerid] ++;
            if(IsMaxDamageWep(weaponid) == 1)
            {
                BodyPartAmount[playerid][7] = 2;
                new num = RandomEx(1,5);
                if(num == 2)
                {
                    TextDrawHideForPlayer(playerid,LLegBlTD);
                    TextDrawShowForPlayer(playerid,LLegBlab);
                    LLegBr[playerid] = 1;
                }
            }
            else if(IsMaxDamageWep(weaponid) == 0)
            {
                BodyPartAmount[playerid][7] = 1;
            }
        }
    }
    if(bodypart == 8)
    {
        TextDrawShowForPlayer(playerid,RLegBlTD);
        if(RLegBl[playerid] < 5)
        {
            RLegBl[playerid] ++;
            if(IsMaxDamageWep(weaponid) == 1)
            {
                BodyPartAmount[playerid][8] = 1;
                new num = RandomEx(1,5);
                if(num == 2)
                {
                    TextDrawHideForPlayer(playerid,RLegBlTD);
                    TextDrawShowForPlayer(playerid,RLegBlab);
                    RLegBr[playerid] = 1;
                }
            }
            else if(IsMaxDamageWep(weaponid) == 0)
            {
                BodyPartAmount[playerid][8] = 1;
            }
        }
    }



Re: SAMP Hit detection isn't accurate? - Abagail - 13.02.2015

It's possible one of you has a skin modification(which is most likely). Another cause is that it may have appeared you were shooting at his legs; while the client was sending data to the server saying otherwise.


Re: SAMP Hit detection isn't accurate? - SickAttack - 13.02.2015

OnPlayerTakeDamage tends to be inaccurate while dealing with laggers. OnPlayerGiveDamage is more accurate than OnPlayerTakeDamage, but if you set the damaged player's health to 0 under OnPlayerGiveDamage, the death reason of the damaged player's intends to get mixed up (default reason) in some cases.


Re: SAMP Hit detection isn't accurate? - Dokins - 13.02.2015

Okay, I was doing this on local server with 2 computers to test.

It seemed more accurate when I removed the headshot script.

However, I was shooting in the legs and it didn't come up with the textdraw, but on arms it would and chest etc.


Re: SAMP Hit detection isn't accurate? - SickAttack - 13.02.2015

Quote:
Originally Posted by Dokins
Посмотреть сообщение
Okay, I was doing this on local server with 2 computers to test.

It seemed more accurate when I removed the headshot script.

However, I was shooting in the legs and it didn't come up with the textdraw, but on arms it would and chest etc.
You should also take into consideration that bullets don't take straight paths.


Re: SAMP Hit detection isn't accurate? - Dokins - 13.02.2015

What do you mean? I'm not sure this happens in SAMP.