IsPlayerInRangeOfPoint/OnPlayerWeaponShot problem
#1

So, I've tried creating an Aimbot Detector for the "new famous aimbot of 0.3z".
At first it worked, but after 'heavier' usage it started to bug.
So i tried to fix it, then it didn't work etc..

After some time, Tamer T told me to use
pawn Код:
GetPlayerLastShotVectors(playerid, fOriginX, fOriginY, fOriginZ, fHitPosX, fHitPosY, fHitPosZ);
Instead of the
pawn Код:
OnPlayerWeaponShot(...., Float:fX, Float:fY, Float:fZ)
That OnPlayerWeaponShot has.

It worked at first, but then after more usage/testing, it started to give out false/random alerts etc..
Code;
pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    TimesShot[playerid]++;
    if(TimesShot[playerid] < 20)
    {
        if(hittype == BULLET_HIT_TYPE_PLAYER)
        {
            if(!IsAFK{ hitid })
            {
                if(!CoolDown[playerid])
                {
                    new Float:fOriginX, Float:fOriginY, Float:fOriginZ, Float:fHitPosX, Float:fHitPosY, Float:fHitPosZ;
                    GetPlayerLastShotVectors(playerid, fOriginX, fOriginY, fOriginZ, fHitPosX, fHitPosY, fHitPosZ);
                    CheckForAimbot(playerid, fHitPosX, fHitPosY, fHitPosZ);
                }
            }
        }
    }
    return 1;
}

stock CheckForAimbot(playerid, Float:fX, Float:fY, Float:fZ)
{
    new string[118], Float:pX, Float:pY, Float:pZ;
    GetPlayerPos(playerid, pX, pY, pZ);
   
    if(!CoolDown[playerid])
    {
        if(!DetectedForAimbot{ playerid })
        {
            foreach(Player, i)
            {
                if(GetPlayerState(i) != PLAYER_STATE_SPECTATING)
                {
                    if(!IsPlayerInRangeOfPoint(i, 3.0, fX, fY, fZ))
                    {
                        TimesDetected[playerid]++;
                        if(TimesDetected[playerid] >= 3)
                        {
                            format(string, sizeof(string), "WARNING: %s(%d) is POSSIBLY using aimbot. /spec %d and /atest %d to test him.", GetName(playerid), playerid, playerid, playerid);
                            //SendClientMessageToAll(COLOR_NOTES2, string);
                            DetectedForAimbot{ playerid } = true;
                        }
                    }
                }
            }
            if(TimesDetected[playerid] >= 3)
            {
                SendClientMessageToAll(COLOR_NOTES2, string);
            }
        }
    }
    string = "\0";
}
I tried adding "else" under "if(!IsPlayer ......)", to reduce "TimesDetected" but then it didn't work at all.
Any ideas? :\

Video preview -
[ame]http://www.youtube.com/watch?v=22L6RUMBqf8[/ame]
Reply
#2

Bump..
Reply
#3

This is the problem:
pawn Код:
foreach(Player, i)
            {
                if(GetPlayerState(i) != PLAYER_STATE_SPECTATING)
                {
                    if(!IsPlayerInRangeOfPoint(i, 3.0, fX, fY, fZ))
                    {
                        TimesDetected[playerid]++;
                        if(TimesDetected[playerid] >= 3)
                        {
                            format(string, sizeof(string), "WARNING: %s(%d) is POSSIBLY using aimbot. /spec %d and /atest %d to test him.", GetName(playerid), playerid, playerid, playerid);
                            //SendClientMessageToAll(COLOR_NOTES2, string);
                            DetectedForAimbot{ playerid } = true;
                        }
                    }
                }
            }
If any one of the first 3 online players are not within range it will give you a false warning. So if you had 7 players online (ID 0, 1, 2, 4, 6, 7, . If you shot ID 6, it would run through ID 0 (TimesDetected = 1), ID 1 (TimesDetected = 2), ID 2 (TimeDetected = 3 - Gives warning) etc. So it will give you a warning before it even reaches ID 6. Give this a shot:

pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    TimesShot[playerid]++;
    if(TimesShot[playerid] < 20)
    {
        if(hittype == BULLET_HIT_TYPE_PLAYER)
        {
            if(!IsAFK{hitid})
            {
                if(!CoolDown[playerid])
                {
                    new Float:fOriginX, Float:fOriginY, Float:fOriginZ, Float:fHitPosX, Float:fHitPosY, Float:fHitPosZ;
                    GetPlayerLastShotVectors(playerid, fOriginX, fOriginY, fOriginZ, fHitPosX, fHitPosY, fHitPosZ);
                    CheckForAimbot(playerid, fHitPosX, fHitPosY, fHitPosZ, hitid);
                }
            }
        }
    }
    return 1;
}

CheckForAimbot(playerid, Float:fX, Float:fY, Float:fZ, attacked = INVALID_PLAYER_ID)
{
    if(!CoolDown[playerid])
    {
        if(!DetectedForAimbot{playerid})
        {
            if(attacked != INVALID_PLAYER_ID)
            {
                if(!IsPlayerInRangeOfPoint(attacked, 3.0, fX, fY, fZ))
                {
                    TimesDetected[playerid]++;
                    if(TimesDetected[playerid] >= 3)
                    {
                        new string[110];
                        format(string, sizeof(string), "WARNING: %s(%d) is POSSIBLY using aimbot. /spec %d and /atest %d to test him.", GetName(playerid), playerid, playerid, playerid);
                        SendClientMessageToAll(COLOR_NOTES2, string);
                        DetectedForAimbot{playerid} = true;
                    }
                }
            }
        }
    }
    return 1;
}
Reply
#4

Quote:
Originally Posted by Threshold
Посмотреть сообщение
This is the problem:
pawn Код:
foreach(Player, i)
            {
                if(GetPlayerState(i) != PLAYER_STATE_SPECTATING)
                {
                    if(!IsPlayerInRangeOfPoint(i, 3.0, fX, fY, fZ))
                    {
                        TimesDetected[playerid]++;
                        if(TimesDetected[playerid] >= 3)
                        {
                            format(string, sizeof(string), "WARNING: %s(%d) is POSSIBLY using aimbot. /spec %d and /atest %d to test him.", GetName(playerid), playerid, playerid, playerid);
                            //SendClientMessageToAll(COLOR_NOTES2, string);
                            DetectedForAimbot{ playerid } = true;
                        }
                    }
                }
            }
If any one of the first 3 online players are not within range it will give you a false warning. So if you had 7 players online (ID 0, 1, 2, 4, 6, 7, . If you shot ID 6, it would run through ID 0 (TimesDetected = 1), ID 1 (TimesDetected = 2), ID 2 (TimeDetected = 3 - Gives warning) etc. So it will give you a warning before it even reaches ID 6. Give this a shot:

pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    TimesShot[playerid]++;
    if(TimesShot[playerid] < 20)
    {
        if(hittype == BULLET_HIT_TYPE_PLAYER)
        {
            if(!IsAFK{hitid})
            {
                if(!CoolDown[playerid])
                {
                    new Float:fOriginX, Float:fOriginY, Float:fOriginZ, Float:fHitPosX, Float:fHitPosY, Float:fHitPosZ;
                    GetPlayerLastShotVectors(playerid, fOriginX, fOriginY, fOriginZ, fHitPosX, fHitPosY, fHitPosZ);
                    CheckForAimbot(playerid, fHitPosX, fHitPosY, fHitPosZ, hitid);
                }
            }
        }
    }
    return 1;
}

CheckForAimbot(playerid, Float:fX, Float:fY, Float:fZ, attacked = INVALID_PLAYER_ID)
{
    if(!CoolDown[playerid])
    {
        if(!DetectedForAimbot{playerid})
        {
            if(attacked != INVALID_PLAYER_ID)
            {
                if(!IsPlayerInRangeOfPoint(attacked, 3.0, fX, fY, fZ))
                {
                    TimesDetected[playerid]++;
                    if(TimesDetected[playerid] >= 3)
                    {
                        new string[110];
                        format(string, sizeof(string), "WARNING: %s(%d) is POSSIBLY using aimbot. /spec %d and /atest %d to test him.", GetName(playerid), playerid, playerid, playerid);
                        SendClientMessageToAll(COLOR_NOTES2, string);
                        DetectedForAimbot{playerid} = true;
                    }
                }
            }
        }
    }
    return 1;
}
---------
works!
Thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)