AntiCheat problem (money)
#1

Ok, look. I was making my anticheat(money) system and here what I have:
When player type /login pass i start timer for him
Код:
moneytimer[playerid] = SetTimerEx("MoneyCheck",3000,1,"i",playerid);
When he disconnects from server i kill it
Код:
KillTimer(moneytimer[playerid]);
Here is how i check player's money
Код:
forward MoneyCheck(playerid);
public MoneyCheck(playerid)
{
  new clientcash;
  clientcash = GetPlayerMoney(playerid);
  if(clientcash > servercash[playerid])
  {
    SetTimerEx("MoneyCheck2",2000,false,"i",playerid);
  }
  else
  {
    servercash[playerid] = clientcash;
  }
  return 1;
}
if player is suspecting in cehating i start 2 timer for him
Код:
forward MoneyCheck2(playerid);
public MoneyCheck2(playerid)
{
  new clientcash;
  clientcash = GetPlayerMoney(playerid);
  if(clientcash > servercash[playerid])
  {
    new string[256],nick[24];
    GetPlayerName(playerid, nick, sizeof(nick));
      format(string, sizeof(string), "[LSPD] Игрок %s был кикнут за читы на деньги.",nick);
      SendClientMessageToAll(COLOR_RED, string);
    ResetPlayerMoney(playerid);
    Kick(playerid);
  }
return 1;
}
And here is my giveplayermoney function
Код:
forward xGivePlayerMoney(playerid, amount);
public xGivePlayerMoney(playerid, amount)
{
  new tmp;
  tmp = GetPlayerMoney(playerid);
  GivePlayerMoney(playerid,amount);
  servercash[playerid] = tmp + amount;
  return 1;
}
So. think that everything is ok. And it's really working. BUT! Sometimes people is kicked from server because of cheats(they are not cheaters). Help me pls.
Reply
#2

I've also had a problem with this... but found a way to avoid errors.
Top of the script:
pawn Код:
forward MoneyGiving(playerid, status);
new givingmoney[MAX_PLAYERS];
OnPlayerConnect:
pawn Код:
givingmoney[playerid] = 0;
Put this in your timer before if(clientcash > servercash[playerid]):
pawn Код:
if(givingmoney[i]) return;
Function:
pawn Код:
public MoneyGiving(playerid, status)
{
    givingmoney[playerid] = status;
}
And finally insert these to your Money funcs:
pawn Код:
givingmoney[playerid] = 1;
SetTimerEx("MoneyGiving", 1500, 0, "i,i", playerid, 0);
З.Ы. русские захватят весь мир))
Reply
#3

oooh! thx dude!
p.s. лооооол
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)