Anti health hack problem
#1

Hey, so when I fall some where to the ground, before the spawn protection ends, the Anti Cheat kicks me after Spawn Protection ends:

Under OnPlayerUpdate:

pawn Код:
new Float:pHealth;
    GetPlayerHealth(playerid, pHealth);
    new hacker[MAX_PLAYER_NAME];
    GetPlayerName(playerid, hacker, MAX_PLAYER_NAME);
    if(pHealth > 99)
    {
    if(Freemod[playerid] == 0 && OnDuty[playerid] == 0 && Spawnprotection[playerid] == 0)
    {
    new antimsg[128];
    format(antimsg, sizeof(antimsg), "%s (%d) Has Been Kicked By The Anti-Cheat (AC) | Reason: Health Hacks.", hacker, playerid);
    SendClientMessageToAll(0x00FFFFFF, antimsg);
    SendClientMessage(playerid, 0xFF0000AA, "You Have Been Kicked By The Anti-Cheat (AC) | Reason: Health Hacks.");
    SetTimerEx("TimeKicker", 500, false, "d", playerid);
    }
    }
OnPlayerSpawn:

pawn Код:
public OnPlayerSpawn(playerid)
{
    Delete3DTextLabel(alabel[playerid]);
    SendClientMessage(playerid,0xFF66FFAA,"Welcome To LSGW! If you are new here, see those commands: /cmds /rules /help /updates /credits.");
    StopAudioStreamForPlayer(playerid); // Stop the audio stream
    Freemod[playerid] = 0;
    gangwarmod[playerid] = 1;
    drylakemod[playerid] = 0;
    AntiHealthSpam[playerid] = 0;
    IsSongPlaying[playerid] = 0;
    OnDuty[playerid] = 0;
    Killstreak[playerid] = 0;
    LSFreemod[playerid] = 0;
    LVFreemod[playerid] = 0;
    LVFreemod2[playerid] = 0;
    Spawnprotection[playerid] = 1;
    TextDrawShowForPlayer(playerid, Textdraw2);
    PlayerTextDrawShow(playerid, Textdraw000[playerid]);
    PlayerTextDrawShow(playerid, Textdraw111[playerid]);
    PlayerTextDrawShow(playerid, Textdraw222[playerid]);
    PlayerTextDrawShow(playerid, Textdraw333[playerid]);
    PlayerTextDrawShow(playerid, Textdraw444[playerid]);
    TextDrawShowForPlayer(playerid, Textdraw555);
    SetPlayerHealth(playerid, 100);
    if(playerfreezed[playerid] == 1)
    {
      TogglePlayerControllable(playerid, 0);
    }
    else if(playerfreezed[playerid] == 0)
    {
      TogglePlayerControllable(playerid, 1);
    }
    if(Info[playerid][VIPLevel] >= 1)
    {
      if(Info[playerid][Favouriteskin] > -1 || Info[playerid][Favouriteskin] < 299)
      {
        if(Autouseskin[playerid] == 1)
        {
          SetPlayerSkin(playerid, Info[playerid][Favouriteskin]);
          SendClientMessage(playerid, 0x00FFFFFF, "Your Skin Has Been Changed To Your Favourite Skin! If You Want To Use It Manually, Do /useskin.");
        }
      }
    }
    new HouseID;

    // Reset the HouseID where the player is located
    APlayerData[playerid][CurrentHouse] = 0;

    // If SpawnAtHouse is set to "true", re-position the player at the first house in his list of owned houses
    if (SpawnAtHouse == true)
    {
        // Get the first HouseID in your list of owned houses
        HouseID = APlayerData[playerid][Houses][0];
        // Check if the player has a house in this first slot
        if (HouseID != 0)
        {
            // Re-position the player at the house's coordinates
            SetPlayerPos(playerid, AHouseData[HouseID][HouseX], AHouseData[HouseID][HouseY], AHouseData[HouseID][HouseZ]);
        }
    }
    if(IsSpecing[playerid] == 1)
    {
        SetPlayerPos(playerid,SpecX[playerid],SpecY[playerid],SpecZ[playerid]);// Remember earlier we stored the positions in these variables, now we're gonna get them from the variables.
        SetPlayerInterior(playerid,Inter[playerid]);//Setting the player's interior to when they typed '/spec'
        SetPlayerVirtualWorld(playerid,vWorld[playerid]);//Setting the player's virtual world to when they typed '/spec'
        IsSpecing[playerid] = 0;//Just saying you're free to use '/spec' again YAY :D
        IsBeingSpeced[spectatorid[playerid]] = 0;//Just saying that the player who was being spectated, is not free from your stalking >:D
    }
    ClearAnimations(playerid);
    new world = random(40);
    SetPlayerVirtualWorld(playerid, world);
    if(world == 0)
    {
    SetPlayerVirtualWorld(playerid, 50);
    }
    SetPlayerHealth(playerid, 99999999);
    Spawntimer[playerid] = SetTimerEx("Spawnprotect", 5000, false, "d", playerid);
    SendClientMessage(playerid, -1, "You are under spawn protection for 5 seconds.");
    GameTextForPlayer(playerid, "~g~Spawn Protection On", 3000, 4);
    TextDrawShowForPlayer(playerid,Text:Stats[playerid]);
    TextDrawShowForPlayer(playerid,Text:R_1[playerid]);
    return 1;
}
Reply
#2

It would be better to use a timer of 1-10 seconds instead of OnPlayerUpdate.
Quote:
Originally Posted by SA-MP Wiki
This callback is called very frequently per second per player
But since you get kicked after your spawn protection disappears, can you show that code?
Reply
#3

You didn't understand me, before the spawn protection disappears, I accidently fall to the ground, and after spawn protection disappear, it kicks me, if i didn't fall, nothing will happen.

Code:
pawn Код:
forward Spawnprotect(playerid);
public Spawnprotect(playerid)
{
    SetPlayerHealth(playerid, 99);
    Spawnprotection[playerid] = 0;
    SetPlayerVirtualWorld(playerid, 0);
    SendClientMessage(playerid, -1, "You are now no longer under spawn protection.");
    GameTextForPlayer(playerid, "~r~Spawn Protection Off", 3000, 4);
    if(Info[playerid][VIPLevel] >= 1)
    {
    GivePlayerWeapon(playerid, 5, 500);
    GivePlayerWeapon(playerid, 24, 500);
    GivePlayerWeapon(playerid, 27, 200);
    GivePlayerWeapon(playerid, 29, 1000);
    GivePlayerWeapon(playerid, 30, 1000);
    SendClientMessage(playerid, -1, "You Have Got 2x Ammo Of Weapons For Being VIP.");
    }
    else
    {
    GivePlayerWeapon(playerid, 5, 250);
    GivePlayerWeapon(playerid, 24, 250);
    GivePlayerWeapon(playerid, 27, 100);
    GivePlayerWeapon(playerid, 29, 500);
    GivePlayerWeapon(playerid, 30, 500);
    }
}
Reply
#4

Try changing 'pHealth > 99' to 'pHealth >= 100.0'. If you add the decimal, it will increase the accuracy of the function.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)