PDA

View Full Version : Little bug with anti money hack


Glossy42O
03/02/2015, 11:02 AM
Alright..

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

But i did not hack

forward GivePlayerMoneyEx(playerid, ammount);
public GivePlayerMoneyEx(playerid, ammount)
{
OldMoney[playerid] = GetPlayerMoney(playerid);
NewMoney[playerid] = ammount;
GivePlayerMoney(playerid, ammount);
return 1;
}
forward CheckMoney();
public CheckMoney()
{
for(new i =0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(GetPlayerMoney(i) > NewMoney[i])
{
ResetPlayerMoney(i);
GivePlayerMoney(i, OldMoney[i]);
Ban(i);
}
}
}
return 1;
}

OstGot
03/02/2015, 11:13 AM
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").

OstGot
03/02/2015, 11:17 AM
+ To all:
For proper operation, "NewMoney[playerid]" must be equal to your current money amount.

Kruno88
03/02/2015, 11:21 AM
Use this instead if ResetPlayerMoney:
return 0;

Glossy42O
03/02/2015, 03:24 PM
But it won't reset his cash ._. there is a reason why i use this...

BroZeus
03/02/2015, 03:30 PM
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;
}

PowerPC603
03/02/2015, 03:43 PM
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:

GivePlayerMoneyEx(playerid, amount)
{
Money[playerid] = Money[playerid] + amount;
}


Somewhere in your script:

// 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:

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.

Glossy42O
03/02/2015, 04:21 PM
Tried both. Same.

Glossy42O
04/02/2015, 01:50 PM
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.

CalvinC
04/02/2015, 03:38 PM
NewMoney[playerid] = ammount;
GivePlayerMoney(playerid, ammount);
In NewMoney, you're not giving money, you're setting the money.
Use +=
NewMoney[playerid] += ammount;
GivePlayerMoney(playerid, ammount);