Little bug with anti money hack
#1

Alright..

I got a lil' bug. if i do /givecash it'll reset my cash AND ban me.

But i did not hack

PHP код:
forward GivePlayerMoneyEx(playeridammount);
public 
GivePlayerMoneyEx(playeridammount)
{
 
OldMoney[playerid] = GetPlayerMoney(playerid);
 
NewMoney[playerid] = ammount;
 
GivePlayerMoney(playeridammount);
 return 
1;
}
forward CheckMoney();
public 
CheckMoney()
{
  for(new 
=0MAX_PLAYERSi++)
  {
       if(
IsPlayerConnected(i))
       {
             if(
GetPlayerMoney(i) > NewMoney[i])
             {
                
ResetPlayerMoney(i);
                
GivePlayerMoney(iOldMoney[i]);
                
Ban(i);
             }
       }
   }
   return 
1;

Reply
#2

1. I recommend remove the "ban", because sometimes money can be replenished and without hacks (casino, stunts). And if you have not considered it, replace it though, would to "kick".
2. Check your script for the presence "GivePlayerMoney", and if it is not replaced by "GivePlayerMoneyEx", do it.
3. It is also possible that you have some filterscripts, which can also use ordinary "GivePlayerMoney" (and not "GivePlayerMoneyEx").
Reply
#3

+ To all:
For proper operation, "NewMoney[playerid]" must be equal to your current money amount.
Reply
#4

Use this instead if ResetPlayerMoney:
Код:
return 0;
Reply
#5

But it won't reset his cash ._. there is a reason why i use this...
Reply
#6

pawn Код:
forward GivePlayerMoneyEx(playerid, ammount);
public GivePlayerMoneyEx(playerid, ammount)
{
 OldMoney[playerid] = GetPlayerMoney(playerid);
 NewMoney[playerid] =  OldMoney[playerid] + ammount;//oldmoney + amount = new money
 GivePlayerMoney(playerid, ammount);
 return 1;
}
Reply
#7

Just use a timer to update the client's money every second by the value stored on the server.

When you give a player some money, use something like this:
pawn Код:
GivePlayerMoneyEx(playerid, amount)
{
    Money[playerid] = Money[playerid] + amount;
}
Somewhere in your script:
pawn Код:
// This timer runs every second
forward GlobalTimer1000();
public GlobalTimer1000()
{
    // Loop through all players and only run the timer for each player who's connected
    for (new playerid; playerid < MAX_PLAYERS; playerid++)
        if (IsPlayerConnected(playerid) == 1)
        {
            ResetPlayerMoney(playerid);
            GivePlayerMoney(playerid, Money[playerid]);
        }
}
OnGameModeInit:
pawn Код:
SetTimer("GlobalTimer1000", 1000, true);
Then this timer will run for all players.

Even when a hacker hacks his client to display $1000000 and freeze the value, it won't do him any good.
This timer overwrites his money displayed onscreen.
Even if they manage to freeze it permanently, use the value stored on the server to buy everything in your script.

If the server holds $100, while they have hacked their client to display $1000000, they won't be able to buy anything more expensive than $100 as the server knows he has only $100.

Then it doesn't matter if they hack money, and you don't need to ban them either.
And there is no need to use GetPlayerMoney anywhere in your script to even check if they're hacking.

The only thing they would be able to buy with hacked money, is a soda can out of the drinking machines.
And that alone won't ruin your server.
Reply
#8

Tried both. Same.
Reply
#9

I removed it, all of it - is there ANY tutorial that is good and if it is and u know how to fix this bug tell me please.
Reply
#10

pawn Код:
NewMoney[playerid] = ammount;
 GivePlayerMoney(playerid, ammount);
In NewMoney, you're not giving money, you're setting the money.
Use +=
pawn Код:
NewMoney[playerid] += ammount;
 GivePlayerMoney(playerid, ammount);
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)