AntiCheat not working...
#1

Hello
I made an anti-cheat some time ago but it didn't work very well...
I made a few changes to it (for ex, instead of using onplayerupdate i used a timer) but it made it even worse...
And it's behavior is very weird

Here's the timer that gets called once every second.
pawn Код:
public AntiMoneyHack()
{
    for(new i=0; i<MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(GetPlayerMoney(i) > pMoney[i])
            {
                new playername[MAX_PLAYER_NAME],string[128];
                GetPlayerName(i,playername,sizeof(playername));
                format(string,sizeof(string),"Server: {FF0000}%s {FFFFFF}was banned, reason: {FF0000}Money Hack{FFFFFF}",playername);
                for(new b=0; i<MAX_PLAYERS; i++)
                {
                    if(IsPlayerConnected(b))
                    {
                        if(pInfo[b][Admin] >= 1)
                        {
                            SCM(b,COLOR_LIGHTRED,string);
                            new string500[128];
                            format(string500,sizeof(string500),"DEBUG: Your money: %d Server Money %d",GetPlayerMoney(b),pMoney[b]);
                            SCM(b,COLOR_WHITE,string500);
                        }
                    }
                }
                new logstring[256],d,m,y,h,mi,s;
                gettime(h,mi,s);
                getdate(y,m,d);
                new plrIP[16];
                GetPlayerIp(i, plrIP, sizeof(plrIP));
                format(logstring,sizeof(logstring),"%d/%d/%d %d:%d:%d Server: %s[%s] was banned, reason: Money Hack",d,m,y,h,mi,s,playername,plrIP);
                Log(logstring);
                SafeResetPlayerMoney(i);
                new banstring[128];
                format(banstring,sizeof(banstring),"banip %s",plrIP);
                SendRconCommand(banstring);
                SendRconCommand("reloadbans");
                pInfo[i][Banned]=1;
                SetTimerEx("TimeKick",500,false,"i",i);
            }
        }
    }
}
And this is what crashdetect has to say about it
Код:
[12:35:57] [debug] Run time error 4: "Array index out of bounds"
[12:35:57] [debug]  Accessing element at index 500 past array upper bound 499
[12:35:57] [debug] AMX backtrace:
[12:35:57] [debug] #0 00083498 in ?? (0x000001f4) from GM.amx
[12:35:57] [debug] #1 0008dddc in public AntiMoneyHack () from GM.amx
The thing is that it randomly bans players when they die (at least it says so in the logs, but players don't get banned and the admins don't get notified about the cheater).
OnPlayerDeath doesn't handle any money, so i don't think that's the problem. However OnPlayerSpawn does, it charges the medic fee and also gives 100$ (as you may know, when you die, you automatically lose 100$, and ofc the money are taken with the default giveplayermoney...).
P.S.: It doesn't detect money cheaters also

Any help please? Thanks
Reply
#2

Anyone?
Reply
#3

Some tips from my side:


1: Raise it to 3 seconds to have less lag.
2: What's the point of the multiple loops? One is enough, you should remove the:


pawn Код:
for(new b=0; i<MAX_PLAYERS; i++)
                {
                    if(IsPlayerConnected(b))
And use the first loop you used, "i".


3: Don't ban the player right away for money hack, instead set their money back to the stat, that way they can't hack and also send a message to all admins as a warning that he might be hacking. As you might get tons of bans due to money cheat because of the Pay n Spray and the Vending machines. And yeah the OnPlayerDeath taking 100$ can also false ban too, as sometimes AntiCheat could be called before you give the 100$ back.


Hope these suggestions will help you, also get the include from Emmet_ with vending machines and make a check for vending machines or remove all the vending machines.


EDIT: I think that your major issue of it not being called properly is caused by that double loop, not sure tho.


EDIT2: Use the whole anti cheat in just 1 timer and callback, that means make a complete check for all weapons, money, everything else you got the check for instead of making 1 timer for money, 1 for weapons, etc. Otherwise it has a bigger chance of lagging as multiple timers will be called at same time.
Reply
#4

Thank you very much for those tips
The second loop (the one with b) is for sending the message to all admins.
I'll try to remove it, but i don't think it's gonna make any difference.
Thanks once again
Reply
#5

Quote:
Originally Posted by Vlad64
Посмотреть сообщение
Thank you very much for those tips
The second loop (the one with b) is for sending the message to all admins.
I'll try to remove it, but i don't think it's gonna make any difference.
Thanks once again
Lol, i'm soooo blind
pawn Код:
for(new b=0; i<MAX_PLAYERS; i++)
That's where the problem was The ac system finally works now
Thanks Blast3r once again
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)