28.12.2013, 10:56
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:
And the function to give a weapon to a player, would be this:
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:
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.
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;
}
}
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;
}
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;
}
Thanks.