SA-MP Forums Archive
Timer or OnPlayerUpdate - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Timer or OnPlayerUpdate (/showthread.php?tid=115181)



Timer or OnPlayerUpdate - BP13 - 22.12.2009

Which method would be better for this anticheat and cause less lag. Please also post why you would choose OnPlayerUpdate or timer.

pawn Код:
#include <a_samp>
#include <IsPlayerLadmin>

new timer;
new bool: ADMIN[MAX_PLAYERS];
new bool: ADMIN2[MAX_PLAYERS];
new bool: ADMIN3[MAX_PLAYERS];
new bool: ADMIN4[MAX_PLAYERS];
new bool: ADMIN5[MAX_PLAYERS];

public OnFilterScriptInit()
{
  timer = SetTimer("AntiCheat",5000,true);
    print("Cheat Extinguisher by [SU]BP13 loaded");
    return 1;
}

public OnFilterScriptExit()
{
    KillTimer(timer);
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    if(IsPlayerLAdmin(playerid))
    {
    ADMIN[playerid] = true;
    ADMIN2[playerid] = true;
    ADMIN3[playerid] = true;
    ADMIN4[playerid] = true;
    ADMIN5[playerid] = true;
    }
    return 1;
}

public OnPlayerDisconnect(playerid)
{
  ADMIN[playerid] = false;
  ADMIN2[playerid] = false;
  ADMIN3[playerid] = false;
  ADMIN4[playerid] = false;
  ADMIN5[playerid] = false;
  return 1;
}

forward AntiCheat();
public AntiCheat()
{
    new weap, ammo;
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
      if(ADMIN[i] == false)
      {
            GetPlayerWeaponData(i, 9, weap, ammo);
            if(weap == 42)
            {
                new string [128];
                new pName[MAX_PLAYER_NAME];
                GetPlayerName(i, pName, sizeof(pName));
                format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
                SendClientMessageToAll(0xFF0000FF, string);
                BanEx(i, "AntiCheat - Fire Extinguisher");
            }
        }
        if(ADMIN2[i] == false)
      {
            GetPlayerWeaponData(i, 10, weap, ammo);
            if(weap == 15)
            {
                new string [128];
                new pName[MAX_PLAYER_NAME];
                GetPlayerName(i, pName, sizeof(pName));
                format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
                SendClientMessageToAll(0xFF0000FF, string);
                BanEx(i, "AntiCheat - Cane");
            }
        }
      if(ADMIN3[i] == false)
      {
            GetPlayerWeaponData(i, 1, weap, ammo);
            if(weap == 7)
            {
                new string [128];
                new pName[MAX_PLAYER_NAME];
                GetPlayerName(i, pName, sizeof(pName));
                format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
                SendClientMessageToAll(0xFF0000FF, string);
                BanEx(i, "AntiCheat - Pool Cue");
            }
        }
      if(ADMIN4[i] == false)
      {
            GetPlayerWeaponData(i, 11, weap, ammo);
            if(weap == 44)
            {
                new string [128];
                new pName[MAX_PLAYER_NAME];
                GetPlayerName(i, pName, sizeof(pName));
                format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
                SendClientMessageToAll(0xFF0000FF, string);
                BanEx(i, "AntiCheat - Nightvision");
            }
        }
      if(ADMIN5[i] == false)
      {
            GetPlayerWeaponData(i, 11, weap, ammo);
            if(weap == 45)
            {
                new string [128];
                new pName[MAX_PLAYER_NAME];
                GetPlayerName(i, pName, sizeof(pName));
                format(string, sizeof(string), "BANNED: %s has been auto banned by console.", pName);
                SendClientMessageToAll(0xFF0000FF, string);
                BanEx(i, "AntiCheat - Thermal Goggles");
            }
        }
    }
    return 1;
}



Re: Timer or OnPlayerUpdate - [03]Garsino - 22.12.2009

Timer => Checks 1 amount per choosen time.
On‌PlayerUpdate => Check 50 times per second per player?!


Re: Timer or OnPlayerUpdate - BP13 - 23.12.2009

I'm going to assume OnPlayerUpdate is not efficient (at all) its also questionable why it even exists. The only use it would have if Garsino said was true would be very small things. Any more answers?