Anti-Cheat Bug?
#1

Hey there,

I've got a problem with my Anti-hack, instead of it just sending a report to the admin,I want it to ban the player's IP/account also.

But when anybody connects, it bans them for nothing?

Here's my snippet.

Код:
	
	     new Float:Armour, Msg[128], Reason[128];
                if (APlayerData[playerid][PlayerSpeed] > 300)
		GetPlayerName(PlayerToBan, Name, sizeof(Name));
		SendReportToAdmins(playerid, "(Auto-Banned) Speed Hacks", true);
		format(Msg, 128, "{FF0000}[BANNED] You have been banned by {FFFFFF}Anti-Cheat {FFFF00}Reason: Speed Hacks.");
		SendClientMessage(playerid, 0xFFFFFFFF, Msg);
		BanEx(playerid, Reason);
	       APlayerData[Player][BanTime] = 2147483640;
Would really appriciate some help.

Thanks,
Ashley
Reply
#2

You should check the hack after the player has been successfully spawned.
Reply
#3

It bans them because APlayerData[playerid][PlayerSpeed] Isn't set to 0 at connect, or it is being set while they are not spawned (making a random value like 65535).

You could set the PlayerSpeed to 0 when they connect, and print the speed before they are banned to make sure its valid.
Reply
#4

I'm a little confused with that you said, I aren't that much of a scripter, (I'm still teaching myself.)

Here is my AntiHack function,
pawn Код:
stock AntiHack(playerid)
{
    // Setup local variables
    new Float:Armour, Msg[128], Reason[128];

    // Skip checking for hacks used by the player if he was reported by the Anti-Hack system already
    if (APlayerData[playerid][AutoReportTime] > 0)
    {
        // Reduce the time so the player can be reported again soon if he doesn't stop using hacks
        APlayerData[playerid][AutoReportTime]--;
        // Exit the function, this skips the hack-checks until the AutoReportTime has reached 0
        // Otherwise the player is reported every half a second until he stops using hacks
        return 1;
    }



    // Check if a filterscript gave some money (or took it) to the player
    if (GetPVarInt(playerid, "PVarMoney") != 0)
    {
        // Add the money to the players account
        APlayerData[playerid][PlayerMoney] = APlayerData[playerid][PlayerMoney] + GetPVarInt(playerid, "PVarMoney");
        // Clear the PVar
        SetPVarInt(playerid, "PVarMoney", 0);
    }
    if (GetPVarInt(playerid, "PVarScore") != 0)
    {
        // Add the money to the players account
        APlayerData[playerid][PlayerScore] = APlayerData[playerid][PlayerScore] + GetPVarInt(playerid, "PVarScore");
        // Clear the PVar
        SetPVarInt(playerid, "PVarScore", 0);
    }

    // Reset the player's money and set it to the stored value in the player's account (do the same for scorepoints)
    ResetPlayerMoney(playerid);
    GivePlayerMoney(playerid, APlayerData[playerid][PlayerMoney]);
    SetPlayerScore(playerid, APlayerData[playerid][PlayerScore]);

    // Limit the cash that the player can have
    if (APlayerData[playerid][PlayerMoney] > 999000000)
        APlayerData[playerid][PlayerMoney] = 999000000;

    // Limit the cash that the player can have below 0
    if (APlayerData[playerid][PlayerMoney] < -1000000)
        APlayerData[playerid][PlayerMoney] = -1000000;

    // Port anyone out of the area who is not an admin and inside the area 69
    Player_PortOutAdminZone(playerid, 106.0, 1805.0, -50.0, 285.0, 1940.0, 40.0, 15.0, 1732.0, 25.0);

    // Weapon hacks are also neutralized here, except for police players (if they are allowed to have weapons)
    if ((PoliceGetsWeapons == true) && (APlayerData[playerid][PlayerClass] == ClassPolice))
    {
        // Do nothing
    }
    else
        ResetPlayerWeapons(playerid); // Remove all weapons from the player

    // Check if the player got any armour (= health-hack)
    GetPlayerArmour(playerid, Armour);
    // Send an automated report to the admins so they're informed about it and can take action
    if (Armour > 1.0)
        SendReportToAdmins(playerid, "(Auto-Banned) Health Hacks", true);



    // Check if the speed is higher than 300 (kick player if it is)
    // Send an automated report to the admins so they're informed about it and can take action
    if (APlayerData[playerid][PlayerSpeed] > 300)
        GetPlayerName(PlayerToBan, Name, sizeof(Name));
        SendReportToAdmins(playerid, "(Auto-Banned) Speed Hacks", true);
        format(Msg, 128, "{FF0000}[BANNED] You have been banned by {FFFFFF}Anti-Cheat {FFFF00}Reason: Speed Hacks.");
        SendClientMessage(playerid, 0xFFFFFFFF, Msg);
        BanEx(playerid, Reason);
        APlayerData[Player][BanTime] = 2147483640;

    // Check if the player is not allowed to have a jetpack (admins lvl 5 and higher can use /fly, so they will be excluded)
    if (APlayerData[playerid][PlayerLevel] < 5)
    {
        // Check if the player is using a jetpack
        // Send an automated report to the admins so they're informed about it and can take action
        if (GetPlayerSpecialAction(playerid) == 2)
           SendReportToAdmins(playerid, "(Auto-Banned) Jet-Pack Hacks", true);
   
    }

    // Detect airbreak hack
    if (GetPlayerVehicleSeat(playerid) == 0)
    {
        // Check if the player is nearly standing still
        if (APlayerData[playerid][PlayerSpeed] < 10)
        {
            // Check if the player switched interior-id's
            if (GetPlayerInterior(playerid) != APlayerData[playerid][PreviousInt])
            {
                // Check if the new interior is the normal world or any mod-shop
                switch (GetPlayerInterior(playerid))
                {
                    case 0, 1, 2, 3: // Check interiors 0, 1, 2 and 3 (normal world and all mod-shops)
                    {
                        // Store the player's current location and interior-id for the next iteration
                        GetPlayerPos(playerid, APlayerData[playerid][PreviousX], APlayerData[playerid][PreviousY], APlayerData[playerid][PreviousZ]);
                        APlayerData[playerid][PreviousInt] = GetPlayerInterior(playerid);
                        // Exit the function
                        return 1;
                    }
                }
            }

            // Check if the player is still near the same place he was half a second ago
            if (IsPlayerInRangeOfPoint(playerid, 7.5, APlayerData[playerid][PreviousX], APlayerData[playerid][PreviousY], APlayerData[playerid][PreviousZ]))
            {
            }
            else // Send an automated report to the admins so they're informed about it and can take action
        SendReportToAdmins(playerid, "(Auto-Banned) Airbreak Hacks", true);

        }
    }
    // Store the player's current location and interior-id for the next iteration
    GetPlayerPos(playerid, APlayerData[playerid][PreviousX], APlayerData[playerid][PreviousY], APlayerData[playerid][PreviousZ]);
    APlayerData[playerid][PreviousInt] = GetPlayerInterior(playerid);

    return 1;
}
Only need to pay attention to the Speedhack one, I'll be able to teach myself the others once I've figured that one out..

If I'm correct, I'd need to add 'AntiHack(playerid);' to OnPlayerSpawn wouldn't I?
Reply
#5

Polite Bump, would be greatful for help.
Reply
#6

pawn Код:
new pSpawned[MAX_PLAYERS];//creating a variable to use for when a player is spawned
forward hackcheck();

public OnPlayerConnect(playerid)
{
     pSpawned[playerid] = 0;//setting it to 0 so the server knows you are not spawned.
     return 1;
}
public OnPlayerSpawn(playerid)
{
    pSpawned[playerid] ++;//Setting it to 1 so the server knows you are spawned
}
 
public OnGameModeInit()
{
     SetTimer("hackcheck", 1000, true);// setting a repeating timer
     return 1;
}
public hackcheck()// our timers call back
{
    for(new i; i < MAX_PLAYERS; i++;// looping through each player
    {
        if(gSpawned[i]  >= 1)// checks if the player is spawned
        {
            AntiHack(i);
        }
    }
   return 1;
}
Completly untested wrote in the browser, this should get you on the right track however I suggest just sending admins warnings, and also saving the warings to a log so you can check and see if hackers are around when no admins are present. These systems can always be bugged and a shamal will caused people to get banned for speed hacks using your code.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)