SA-MP Forums Archive
[HELP]I Want To Build a Anti Cheat. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [HELP]I Want To Build a Anti Cheat. (/showthread.php?tid=411942)



[HELP]I Want To Build a Anti Cheat. - ofekw2 - 31.01.2013

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



Re: [HELP]I Want To Build a Anti Cheat. - antonio112 - 31.01.2013

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.


Re: [HELP]I Want To Build a Anti Cheat. - Threshold - 31.01.2013

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


Re: [HELP]I Want To Build a Anti Cheat. - ofekw2 - 31.01.2013

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 ?