Anti Money Cheat problem
#1

I made a small anti cheat with the variables pCash.

Now I use this command to check the system.
Basically the system works but something stupid is happening.

pawn Код:
CMD:checkhackers(playerid, params[])
{
    new str[128];
    if(!CheckAdmin(playerid, ADMIN_LEVEL_1)) return NotAuthMSG(playerid);
    foreach(Player, i)
    {
        new money = GetPlayerMoney(i);
        if(money != PlayerInfo[i][pCash])
        {
            format(str, sizeof(str), "WARNING: [ID:%d]%s is hacking money.", i, GetName(i));
            SCM(playerid, COLOR_LIGHTRED, str);
        }
        if (GetPlayerWeapon(i) != 0 && !Weapons[i][GetPlayerWeapon(i)] && GetPlayerWeapon(i) != 46)
        {
            format(str, sizeof(str), "WARNING: [ID:%d]%s is hacking weapons.", i, GetName(i));
            SCM(playerid, COLOR_LIGHTRED, str);
        }
    }
    return 1;
}
But after i'm using this method like killing myself, it gives me -500 cash
and when I use /checkhackers it shows that i'm a hacker.

pawn Код:
public OnPlayerSpawn(playerid)
{
    if(GetIntVar(playerid, "gLogged") != 1)
    {
        KickEx(playerid, "[SERVER]: You must be logged in to spawn!");
        return 1;
    }
    if(PlayerInfo[playerid][pJailed] < 1) LoadPlayerToys(playerid);
    if(GetIntVar(playerid, "JustDied") == 1)
    {
        PutPlayer(playerid,PlayerInfo[playerid][pPosX],PlayerInfo[playerid][pPosY],PlayerInfo[playerid][pPosZ]);
        SetInterior(playerid, PlayerInfo[playerid][pInt]);
        SetWorld(playerid, PlayerInfo[playerid][pWorld]);
        SetPlayerCameraPos(playerid,PlayerInfo[playerid][pPosX]+6,PlayerInfo[playerid][pPosY]+3,PlayerInfo[playerid][pPosZ]+3);
        SetPlayerCameraLookAt(playerid,PlayerInfo[playerid][pPosX],PlayerInfo[playerid][pPosY],PlayerInfo[playerid][pPosZ]);
        FreezePlayer(playerid);
        SetPlayerHealth(playerid, 1000.0);
        SetTimerEx("DeadAnim", 100, 0, "i", playerid);
        SCM(playerid, COLOR_YELLOW, "You've lost $500 when you died.");
        GiveCash(playerid, -500);
        SCM(playerid, COLOR_YELLOWG, "You are brutally wounded, you may wait for a medic or '/acceptdeath'.");
    }
    return 1;
}

That's my stocks for giving cash... everything seems OKAY, i've been trying to fix this problem for weeks!!

pawn Код:
///////////////////////////Cash///////////////////////////////////
stock GiveCash(playerid, cash)
{
    GivePlayerMoney(playerid, cash);
    return PlayerInfo[playerid][pCash] += cash;
}
stock ResetCash(playerid)
{
    PlayerInfo[playerid][pCash] = 0;
    ResetPlayerMoney(playerid);
    return 1;
}
stock SetCash(playerid, cash)
{
    PlayerInfo[playerid][pCash] = cash;
    ResetPlayerMoney(playerid);
    GivePlayerMoney(playerid, cash);
    return 1;
}
stock GetCash(playerid) return PlayerInfo[playerid][pCash];
///////////////////////////Cash///////////////////////////////////
And when i'm using for example /givemoney with the givecash stock it works..
Reply
#2

As far as I know, -500 everytime you die is already embedded in the Game itself.
There's no way to prevent that although you can Reset the money on the OnPlayerDeath callback, then set the money again when he spawn. Some would say to just add cash on OnPlayerDeath (Add 500 specifically) but in your case, it isn't the proper way as you're still in the /checkhackers list if you do that.

I assume that /givemoney is one of your commands, and you're using the givecash stock. It works without a doubt as you're using a serverside money script. The -500 per kill is actually client-side so it will be detected. (Even with the Vehicle Bonus stunts)
Reply
#3

Got it fixed, and I disabled everything related to stunts bonus.
pawn Код:
public GiveCash(playerid, cash)
{
    new oldcash = GetPlayerMoney(playerid);
    if(oldcash < PlayerInfo[playerid][pCash] && oldcash > -1) PlayerInfo[playerid][pCash] = oldcash;
    PlayerInfo[playerid][pCash] += cash;
    ResetPlayerMoney(playerid);
    GivePlayerMoney(playerid,PlayerInfo[playerid][pCash]);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)