SA-MP Forums Archive
[FilterScript] Fix for 'Huge Shootable Range' Bug - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] Fix for 'Huge Shootable Range' Bug (/showthread.php?tid=554422)



Fix for 'Huge Shootable Range' Bug - Kyance - 03.01.2015

Thanks to one of my friends, I've found a bug which lets others kill you from a HUGE( could be infinite ) distance, which happens if you've been in a vehicle.
So, I got the max. distance for each weapon, and made a simple&short fix.

pawn Код:
#define BULLET_HIT_TYPE_PLAYER          1

public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    if(hittype == BULLET_HIT_TYPE_PLAYER)
    {
        new
            Float:tX, Float:tY, Float:tZ,
            Float:distance
        ;
        GetPlayerPos(hitid, tX, tY, tZ);
        distance = GetPlayerDistanceFromPoint(playerid, tX, tY, tZ);
        switch(weaponid)
        {
            case WEAPON_SILENCED, WEAPON_COLT45, WEAPON_DEAGLE, WEAPON_UZI, WEAPON_TEC9, WEAPON_SAWEDOFF:
            {
                if(distance > 35) return 0;
            }
            case WEAPON_SHOTGSPA, WEAPON_SHOTGUN:
            {
                if(distance > 40) return 0;
            }
            case WEAPON_MP5:
            {
                if(distance > 45) return 0;
            }
            case WEAPON_AK47:
            {
                if(distance > 70) return 0;
            }
            case WEAPON_M4:
            {
                if(distance > 90) return 0;
            }
            case WEAPON_RIFLE:
            {
                if(distance > 100) return 0;
            }
            case WEAPON_SNIPER:
            {
                if(distance > 300) return 0;
            }
        }
    }
    return 1;
}
Updated, the ranges are more accurate ( Thanks to Lordzy & Vince )


Re: Fix for 'Huge Shootable Range' Bug - Lordzy - 03.01.2015

If you're unsure about weapon ranges, refer to weapon.dat found on "data" folder. I know that SA-MP uses it's own files but the weapon ranges could possibly be default.


Re: Fix for 'Huge Shootable Range' Bug - Kyance - 03.01.2015

Quote:
Originally Posted by Lordzy
Посмотреть сообщение
If you're unsure about weapon ranges, refer to weapon.dat found on "data" folder. I know that SA-MP uses it's own files but the weapon ranges could possibly be default.
Thanks!
And It looks like they're using their own settings, because it shows "100" for the Sniper Rifle, although I've got more than 200 for the Sniper Rifle in most servers.

( removed the shotgun part, misread it )


Re: Fix for 'Huge Shootable Range' Bug - Matz - 03.01.2015

Very old known bug fixed by someone else before but I'm not sure whether released or not.


Re: Fix for 'Huge Shootable Range' Bug - Neos07 - 03.01.2015

That will not cause some lag? :/


Re: Fix for 'Huge Shootable Range' Bug - Kyance - 04.01.2015

Quote:
Originally Posted by Matz
Посмотреть сообщение
Very old known bug fixed by someone else before but I'm not sure whether released or not.
From what I ******d I didn't find any topics like this D:

Quote:
Originally Posted by Neos07
Посмотреть сообщение
That will not cause some lag? :/
Shouldn't cause lag.


Re: Fix for 'Huge Shootable Range' Bug - JeaSon - 04.01.2015

nice


Re: Fix for 'Huge Shootable Range' Bug - Banana_Ghost - 05.01.2015

Does this also fix the bug that allows you to take a huge amount of damage if you're car surfing or around a vehicle, etc?


AW: Fix for 'Huge Shootable Range' Bug - Flori - 05.01.2015

Seems good. Well, this bug happens when someone dies(huge distance kill), so it also happens when you just shoot a player? Because i don't understand why you use the OnPlayerWeaponShot callback, and not the OnPlayerDeath callback..(I thought it is more logically to use the OnPlayerDeath callback, because it occurs when someone dies.)
Would be cool if you can explain it to me(or anyone), because i don't understand it. :c
Sorry for that bad question, and thanks in advance.


Re: AW: Fix for 'Huge Shootable Range' Bug - Kyance - 05.01.2015

Quote:
Originally Posted by Banana_Ghost
Посмотреть сообщение
Does this also fix the bug that allows you to take a huge amount of damage if you're car surfing or around a vehicle, etc?
Nope, this only desyncs the bullet if the "hitid"(aka player who he shot) is out of the weapons bullet distance limit... or w.e

Quote:
Originally Posted by Flori
Посмотреть сообщение
Seems good. Well, this bug happens when someone dies(huge distance kill), so it also happens when you just shoot a player? Because i don't understand why you use the OnPlayerWeaponShot callback, and not the OnPlayerDeath callback..(I thought it is more logically to use the OnPlayerDeath callback, because it occurs when someone dies.)
Would be cool if you can explain it to me(or anyone), because i don't understand it. :c
Sorry for that bad question, and thanks in advance.
My friend and I discovered the bug, when we were trolling around in a server, and he noticed that he can hit players in a HUGE distance, when they exit a vehicle.

So, the bug is there ( for the player who left the vehicle ) until he is spawned.

And I used OnPlayerWeaponShot because It happens for every shot, not just till someone dies