[Solved] AntiCheat Message...
#1

pawn Код:
if(ServerInfo[AntiCheat] == true)
{
    new string[128];
    for(new i = 0; i < MAX_PLAYERS; i ++)
    {
        if(PlayerInfo[i][Cash] < pMoney(i))
        {
            new
                cheaterid = i,
                oldcash;
               
            if(PlayerInfo[i][Level] > 2 && IsPlayerConnected(i))
            {
                while(pMoney(cheaterid) > oldcash)
                 {
                    SendClientMessage(i, SYSTEM_DENIAL, "Bot");
                    format(string, sizeof(string), "%s (ID:%d) has had an illegal money increase (%d$).", pName(cheaterid), cheaterid, pMoney(cheaterid) - PlayerInfo[cheaterid][Cash]);
                    SendClientMessage(i, SYSTEM_INFO, string);
                    oldcash = pMoney(cheaterid);
                }
            }
            else
            {
                PlayerInfo[cheaterid][Banned] = true;
                Kick(cheaterid);
            }
            continue;
        }
    }
}
This code is called every second but for not repeating this:
pawn Код:
SendClientMessage(i, SYSTEM_DENIAL, "Bot");
format(string, sizeof(string), "%s (ID:%d) has had an illegal money increase (%d$).", pName(cheaterid), cheaterid, pMoney(cheaterid) - PlayerInfo[cheaterid][Cash]);
SendClientMessage(i, SYSTEM_INFO, string);
oldcash = pMoney(cheaterid);
every second I made this:
pawn Код:
while(pMoney(cheaterid) > oldcash)
but the message is still repeating itself every second...

Why?
Reply
#2

You create the variable oldcash in that part of the script, when you create a variable, it is always 0. You do
pawn Код:
while(pMoney(cheaterid) > oldcash)
So it checks if pMoney(cheaterid) is bigger than 0, I think that a player almost has more than 0 money.
Reply
#3

Quote:
Originally Posted by Marcel
You create the variable oldcash in that part of the script, when you create a variable, it is always 0. You do
pawn Код:
while(pMoney(cheaterid) > oldcash)
So it checks if pMoney(cheaterid) is bigger than 0, I think that a player almost has more than 0 money.
Then, how do I set the variable to player's money in order to check it again?
Reply
#4

pawn Код:
new oldcash = GetPlayerMoney( playerid );
Reply
#5

Quote:
Originally Posted by Marcel
pawn Код:
new oldcash = GetPlayerMoney( playerid );
Then it would have no sense, would it?

pawn Код:
while(pMoney(cheaterid) > oldcash)
Because you'll be checking if player's money is greater than player's money again, it would be always equal and would return 0...
Reply
#6

Then you need to create a variable on top, like
pawn Код:
new oldcash[ MAX_PLAYERS ];
And then:
pawn Код:
if(ServerInfo[AntiCheat] == true)
{
    new string[128];
    for(new i = 0; i < MAX_PLAYERS; i ++)
    {
        if(PlayerInfo[i][Cash] < pMoney(i))
        {
            new
                cheaterid = i;
               
            if(PlayerInfo[i][Level] > 2 && IsPlayerConnected(i))
            {
                while(pMoney(cheaterid) > oldcash[i])
                 {
                    SendClientMessage(i, SYSTEM_DENIAL, "Bot");
                    format(string, sizeof(string), "%s (ID:%d) has had an illegal money increase (%d$).", pName(cheaterid), cheaterid, pMoney(cheaterid) - PlayerInfo[cheaterid][Cash]);
                    SendClientMessage(i, SYSTEM_INFO, string);
                    oldcash[i] = pMoney(cheaterid);
                }
            }
            else
            {
                PlayerInfo[cheaterid][Banned] = true;
                Kick(cheaterid);
            }
            continue;
        }
    }
}
Reply
#7

Oh, thanks Marcel!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)