can this fail?
#1

can this fail when used as a anticheat?

at the top
pawn Код:
//#define WEAPON_TEARGAS(17)//is already defined in a_samp.inc
#define WEAPON_NIGHTVISION (44)//not sure you can do this idk...
#define WEAPON_THERMAL (45)//same as above
//--------------------------------------

//on a (1 second timer)

    if (PlayerLoggedIn[i] != 0)//checks if they are logged in
    {
         WeaponCheck(i);
    }
//--------------------------------------
}

public WeaponCheck(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        if(GetPlayerWeapon(playerid) == WEAPON_TEARGAS)//checks for weapon (in-hand)
        {
             BAN
             return 1;
        }
        if(GetPlayerWeapon(playerid) == WEAPON_THERMAL)//checks for weapon (in-hand)
        {
             BAN
             return 1;
        }
        if(GetPlayerWeapon(playerid) == WEAPON_NIGHTVISION)//checks for weapon (in-hand)
        {
             BAN
             return 1;
        }
    }
}
idk...but some ppl have been banned an they rekon they never had that weapon, but before it was like this i had it on a sendadminmsg for a few months and we tested it heaps with all those weapons an others like the minigun an it only sent the msg to the admins when they were physically holding that weapon an not for having it in their inventory or on person.
So i thought i better ask, just to make sure, can this Fail?
Reply
#2

It shouldn't fail, even if the coding can be done better. And your defines will work.
Reply
#3

This can fail yes. There is an bug in sa-mp 0.3c that did not exist in older versions. The bug makes the GetPlayerWeapon() function to return weapons that doesn't exist. To fix this add an check so the ammo needs to be 1 or more.
Reply
#4

Cool! thanks mike, thats what i thought an atm i even reset weapons before login then players login an onplayerspawn calls the weapon set function, which also resets weapons to start with then gives all pre-saved account weapons.

should i also just change these to numeric values?
example:
pawn Код:
if(GetPlayerWeapon(playerid) == 17) {
Reply
#5

No need to change to numeric. But anyway read my post and add an ammo check. Because as your anti cheat is now it can ban players that doesn't have WEAPON_TEARGAS. That's due to an stupid sa-mp bug that makes GetPlayerWeapon(playerid) returns guns the player doesn't have the good thing is that it returns 0 in ammo or less. So adding an control that the ammo is 1 or over 1 will fix it.
Reply
#6

ok, cool thanks will do that
Reply
#7

so this is the right way to go about it, i did it like this so the player still has to be physically holding the gun and if they are its only then it checks the gun+ammo as you can see...

pawn Код:
}

public WeaponCheck(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        new cheatweapon, cheatammo;
        for (new i=0; i<13; i++)
        {
             GetPlayerWeaponData(playerid, i, cheatweapon, cheatammo);
             if(GetPlayerWeapon(playerid) == WEAPON_TEARGAS)
             {
                  if(cheatweapon == WEAPON_TEARGAS && cheatammo >= 1)
                  {
                       //ban
                       //return 1;
                  }
             // nextcheck...
correct?
Reply
#8

change
if(GetPlayerWeapon(playerid) == WEAPON_TEARGAS)
to
if(cheatweapon == WEAPON_TEARGAS && cheatammo > 0)

and remove the second check
Reply
#9

yeah but strangely enough i would like the check to be triggered by the player physically holding it...

pawn Код:
}
if(GetPlayerWeapon(playerid) == WEAPON_MINIGUN)
{
    new cheatweapon, cheatammo;
    for (new i=0; i<13; i++)
    {
        GetPlayerWeaponData(playerid, i, cheatweapon, cheatammo);
        if(cheatweapon == WEAPON_MINIGUN && cheatammo >= 1)
        {
            //BAN
            //return 1;
        }
//nextcheck
i think this will do, thanks for your help guys
Reply
#10

okay sorry for the bump, but does anyone know if there is anything i can do about this, its not detected as a cheat but it is...

[Weapon: Minigun] || [Ammo: -31073]

and sometimes...

[Weapon: Minigun] || [Ammo: -31074]

Could i just simply change the ammo check to if it don't equal zero?, would that detect negative ammo?
pawn Код:
}
if(GetPlayerWeapon(playerid) == WEAPON_MINIGUN)
{
    new cheatweapon, cheatammo;
    for (new i=0; i<13; i++)
    {
        GetPlayerWeaponData(playerid, i, cheatweapon, cheatammo);
        if(cheatweapon == WEAPON_MINIGUN && cheatammo != 0)
        {
            //BAN
            //return 1;
        }
//nextcheck
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)