Issue with anticheat
#1

Hi all, I have a problem when testing my anticheat. Sometimes (few times happens), when I give a weapon to a player ingame (at moment I have only tested locally with me), the anticheat removes that weapon. Currently, my weapon check functions are these.

This one is inside a 1second timer:
pawn Код:
for(new slot = 0; slot < 13; slot++)
    {
        new weapon, bullets;
        GetPlayerWeaponData(playerid, slot, weapon, bullets);
        if(weapon!= 0 && weapon!= 46)
        {
            if(weapon!= PlayerInfo[playerid][pWeapons][slot] || weapon> PlayerInfo[playerid][pBullets][slot])
            {
                format(textArray, sizeof(textArray), "[ANTICHEAT ID:%d]: Player %s has spawned weapons.", playerid, PlayerInfo[playerid][pName]);
                SendClientMessageToAll(COLOR_RED, textArray);
                break;
            }
            else PlayerInfo[playerid][pBullets][slot] = bullets;
        }
    }
And the function to give a weapon to a player, would be this:
pawn Код:
GiveRealWeapon(playerid, weapon, bullets)
{
    new slot = GetWeaponSlot(weapon);
    if(PlayerInfo[playerid][pWeapons][slot] != 0)
    {
        if(3 <= slot <= 5 || weapon == PlayerInfo[playerid][pWeapons][slot]) PlayerInfo[playerid][pBullets][slot] += bullets;
        else PlayerInfo[playerid][pBullets][slot] = bullets;
        PlayerInfo[playerid][pWeapons][slot] = weapon;
    }
    else
    {
        PlayerInfo[playerid][pWeapons][slot] = weapon;
        PlayerInfo[playerid][pBullets][slot] = bullets;
    }
    GivePlayerWeapon(playerid, weapon, bullets);
    return 1;
}
Seeing that it gives false positives with this function, I decided to make a double check of the bullets correctly adding to the "PlayerInfo[playerid][pBullets][slot]" array, so I tried this one:

pawn Код:
GiveRealWeapon(playerid, weapon, bullets)
{
    new slot = GetWeaponSlot(weapon);
    new currentBullets = PlayerInfo[playerid][pBalas][slot];
    if(PlayerInfo[playerid][pWeapons][slot] != 0)
    {
        if(3 <= slot <= 5 || weapon == PlayerInfo[playerid][pWeapons][slot]) PlayerInfo[playerid][pBullets][slot] += bullets;
        else PlayerInfo[playerid][pBullets][slot] = bullets;
        PlayerInfo[playerid][pWeapons][slot] = weapon;
    }
    else
    {
        PlayerInfo[playerid][pWeapons][slot] = weapon;
        PlayerInfo[playerid][pBullets][slot] = bullets;
    }
    if(PlayerInfo[playerid][pBullets][slot] == currentBullets && bullets != 0) GiveRealWeapon(playerid, weapon, bullets);
    else GivePlayerWeapon(playerid, weapon, bullets);
    return 1;
}
But this isn't a right solution, as it keeps giving false positives and removes the weapon from the player. Any idea of what could be happening?

Thanks.
Reply


Messages In This Thread
Issue with anticheat - by Xabi - 28.12.2013, 10:56
Re: Issue with anticheat - by Patrick - 28.12.2013, 11:20
Respuesta: Issue with anticheat - by Xabi - 28.12.2013, 14:41
Respuesta: Issue with anticheat - by Xabi - 29.12.2013, 18:23

Forum Jump:


Users browsing this thread: 1 Guest(s)