[HELP]I Want To Build a Anti Cheat.
#1

hi
i want build anti cheat for :
crasher
money
weapon
bots
and vehcile spawner

i want you to give me direction
Or how to start to build something like that
I have been programming
I know programming
ty all
Reply
#2

Well, with money anticheat ain't that hard. All you have to do, is create a new variable, in which you 'hold' the player moneys and check / add / substract / take / w/e from that variable instead of money. Let me give you an example:

pawn Код:
new pMoney[MAX_PLAYERS];

public OnPlayerUpdate(playerid)
{
    if(GetPlayerMoney(playerid) != pMoney[playerid])
    {
        ResetPlayerMoney(playerid);
        GivePlayerMoney(playerid, pMoney[playerid]);
    }
    return 1;
}
Now, whenever you want to give or take money to / from a player, you change that variable.

pawn Код:
//GivePlayerMoney(playerid, 1000); This will become:
pMoney[playerid] += 1000;

With anti weapons cheats it's a little more complicated. You must create a new variable for each weapon slot, which you can find all about here.

After creating a variable for each slot, when you give a weapon or take one, you have to modify that specific variable. You can use the 'OnPlayerUpdate' callback to check if a player have a different weapon ID than he should have. Now, the problem is what happens when there's no ammo left in a weapon and it 'disappears'...

Also, it's not really necessary to use 'OnPlayerUpdate' callback, you can also create a new timer, which loops through all online players. You can set the timer time to 500 ms.
The idea is that OnPlayerUpdate is called pretty often (few times per second), which means at a basis of hundred players, it might lag or something.


I don't know what's 'Crasher' supposed to mean.

About bots, I don't know what exactly you're reffering to.
Reply
#3

Anti-Bot:
pawn Код:
#define MAX_BOTS 5
//Change MAX_BOTS to the amount of players MAXIMUM that can play on the same IP.

public OnPlayerConnect(playerid)
{
    new ip[15];
    new BotCount = 0;
    GetPlayerIp(playerid, ip, 15);
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i)) //Foreach is a better option
        {
            if(i == playerid) continue;
            new playerip[15];
            GetPlayerIp(i, playerip, 15);
            if(strcmp(playerip, ip, true) == 0)
            {
                BotCount++;
                if(BotCount >= MAX_BOTS) return BanEx(i, "Bot Detected");
            }
        }
    }
    return 1;
}
//There may be better alternatives to this, but this is one I quickly scripted.
As for the anti-crasher anticheat, a great tutorial/script by JernejL works perfectly. I suggest you check it out.
https://sampforum.blast.hk/showthread.php?tid=317303
Reply
#4

Quote:
Originally Posted by antonio112
Посмотреть сообщение
Well, with money anticheat ain't that hard. All you have to do, is create a new variable, in which you 'hold' the player moneys and check / add / substract / take / w/e from that variable instead of money. Let me give you an example:

pawn Код:
new pMoney[MAX_PLAYERS];

public OnPlayerUpdate(playerid)
{
    if(GetPlayerMoney(playerid) != pMoney[playerid])
    {
        ResetPlayerMoney(playerid);
        GivePlayerMoney(playerid, pMoney[playerid]);
    }
    return 1;
}
Now, whenever you want to give or take money to / from a player, you change that variable.

pawn Код:
//GivePlayerMoney(playerid, 1000); This will become:
pMoney[playerid] += 1000;

With anti weapons cheats it's a little more complicated. You must create a new variable for each weapon slot, which you can find all about here.

After creating a variable for each slot, when you give a weapon or take one, you have to modify that specific variable. You can use the 'OnPlayerUpdate' callback to check if a player have a different weapon ID than he should have. Now, the problem is what happens when there's no ammo left in a weapon and it 'disappears'...

Also, it's not really necessary to use 'OnPlayerUpdate' callback, you can also create a new timer, which loops through all online players. You can set the timer time to 500 ms.
The idea is that OnPlayerUpdate is called pretty often (few times per second), which means at a basis of hundred players, it might lag or something.


I don't know what's 'Crasher' supposed to mean.

About bots, I don't know what exactly you're reffering to.
but i want to build a O_GivePlayerMoney
and i have this stock
stock O_GivePlayerMoney(playerid,money)
{
statick Omoney;
GivePlayerMoney(playerid,money);
return Omoney;
}
this good ? or not ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)