Anti Cheat bans player when given weapons serversided.
#1

I've recently made an Anti Cheat though it's got some flaws which I can't seem to fix. If you're given weapons sever side, it gives you your weapon. However, after around a minute, you get banned for weapon hacking.

This is under my KeyStateChange:
pawn Код:
switch(newkeys)
    {
        //Anti-Cheat (Weapon Checks)
        case KEY_AIM:
        {
            new WeaponData[2];
            for(new i = 0; i < 11; i++)
            {
                GetPlayerWeaponData(playerid, i, WeaponData[0], WeaponData[1]);

                //Anti-Cheat Tazer exception.
                if(i == 2 && Tazer[playerid] == true && WeaponData[1] == 0)
                {
                    SendClientMessage(playerid, COLOR_RED, "You have discharged your tazer!");
                    Tazer[playerid] = false;
                    return _native_GivePlayerWeapon(playerid, Weapons[playerid][2][0], Weapons[playerid][2][1]);
                }

                if(WeaponData[0] != Weapons[playerid][i][0]) BanPlayer(playerid, "Anti-Cheat", "Weapon Hacking");
                if(WeaponData[1] > Weapons[playerid][i][1]) BanPlayer(playerid, "Anti-Cheat", "Ammo Hacking");
            }
        }
    }
As you can see if it doesn't correspond to the one given serverside, it bans.

This is something I tried using to get it to work but it doesn't, it still bans you.
pawn Код:
_native_GivePlayerWeapon(playerid, WeaponID, Ammo)
{
    return GivePlayerWeapon(playerid, WeaponID, Ammo);
}

SF_GivePlayerWeapon(playerid, WeaponID, Ammo)
{
    Weapons[playerid][GetWeaponSlot(WeaponID)][0] = WeaponID;
    Weapons[playerid][GetWeaponSlot(WeaponID)][1] = Ammo;
    GivePlayerWeapon(playerid, WeaponID, Ammo);
}

#if defined _ALS_GivePlayerWeapon
    #undef GivePlayerWeapon
#else
    #define _ALS_GivePlayerWeapon
#endif
#define GivePlayerWeapon SF_GivePlayerWeapon
Reply
#2

Anyone?
Reply
#3

Well I bet you already got your warning for bumping on your thread.

About your problem, as I've seen, it doesn't have to do with after how much time you get banned, it could be that you are entering a police vehicle for example, which gives you a shotgun; your anticheat doesn't check this case so you most likely for a 100% will get banned. I'll give you a link to wups's included of server sided weapons, he has this checks for vehicles you exactly need and maybe also some improvements for you.

Just click here.
Reply
#4

Actually, No it's not when you enter vehicles. It's given serversided, so read the thread properly before commenting.
Reply
#5

Quote:
Originally Posted by Binx
Посмотреть сообщение
Actually, No it's not when you enter vehicles. It's given serversided, so read the thread properly before commenting.
Please, read my reply and understand it properly. There is no possibility you getting banned after a minute because you are not using any timer. Other thing is that in class section, sometimes players, are returning to have weapons and stuff, so you probably want to check if player is spawned before detecting his weapons, would be an advantage.

Also, you don't have to get players weapondata. All you have to do is get his weapon, so probably something like this:

pawn Код:
static weapon;
weapon = GetPlayerWeapon(playerid);
if(!Weapons[playerid][weapon] && weapon != 40 && weapon != 0) // Ban
P.S. It's not FB here for comments, you might be referring to replies.
Reply
#6

pawn Код:
new WeaponData[2];
            for(new i = 0; i < 11; i++)
            {
How is this correct? Should it be
pawn Код:
new WeaponData[11][2]
Because basically if it were what you coded, you would just keep replacing the things all over and over. As to your problem, I'll edit and let you know!
Reply
#7

I'll try that now.

E:
Код:
error 035: argument type mismatch (argument 3)
error 033: array must be indexed (variable "WeaponData")
error 033: array must be indexed (variable "WeaponData")
error 033: array must be indexed (variable "WeaponData")
error 021: symbol already defined: "WeaponData"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)