SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 18/12/2009, 03:01 AM   #1
BP13
High-roller
 
BP13's Avatar
 
Join Date: Jan 2009
Location: Canada
Posts: 2,034
Reputation: 2
Default Simple Anticheat Check not working

here is my whole code.

pawn Code:
#include <a_samp>
#include <IsPlayerLadmin>

new timer;
new bool: ADMIN[MAX_PLAYERS];
new bool: ADMIN2[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;
    }
    return 1;
}

public OnPlayerDisconnect(playerid)
{
  ADMIN[playerid] = false;
  ADMIN2[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); //Slot 9
            if(ammo > 1 && weap == 42) //Weapon ID 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");
            }
        }
        else if(ADMIN2[i] == false) //Not banning for brass nuckles (ID 1)
      {
            GetPlayerWeaponData(i, 0, weap, ammo); //Slot 0
            if(ammo > 1 && weap == 1) //Weapon ID 1
            {
                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");
            }
        }
    }
    return 1;
}
__________________
BP13 is offline  
Old 18/12/2009, 03:29 AM   #2
FreshKilla
Big Clucker
 
FreshKilla's Avatar
 
Join Date: Feb 2008
Location: Canada
Posts: 126
Reputation: 8
Default Re: Simple Anticheat Check not working

If its using to check if they have weapons why not just make the code simpler and just use:

pawn Code:
if(GetPlayerWeapon(i) == weaponid)
  {
    if(GetPlayerAmmo(i) > 0)
    {
      // Code here...
    }
  }

Then you would follow the pattern with:

pawn Code:
if(GetPlayerWeapon(i) == weaponid)
  {
    if(GetPlayerAmmo(i) > 0)
    {
      // Code here...
    }
  }
  else if(GetPlayerWeapon(i) == weaponid)
  {
    if(GetPlayerAmmo(i) > 0)
    {
      // Code here...
    }
  }

But if its just to check weapons, I recommend using OnPlayerUpdate, its commonly known to be used for Anti Cheats.
FreshKilla is offline  
Old 18/12/2009, 03:35 AM   #3
BP13
High-roller
 
BP13's Avatar
 
Join Date: Jan 2009
Location: Canada
Posts: 2,034
Reputation: 2
Default Re: Simple Anticheat Check not working

Could this work? Do I even need the ammo part because I really don't care how much ammo they have in their guns.

pawn Code:
forward AntiCheat();
public AntiCheat()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
      if(ADMIN[i] == false && GetPlayerWeapon(i) == 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");
        }
        else if(ADMIN2[i] == false && GetPlayerWeapon(i) == 1)
      {
            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");
        }
    }
    return 1;
}
__________________
BP13 is offline  
Old 18/12/2009, 03:39 AM   #4
FreshKilla
Big Clucker
 
FreshKilla's Avatar
 
Join Date: Feb 2008
Location: Canada
Posts: 126
Reputation: 8
Default Re: Simple Anticheat Check not working

Id rather do it like this:

pawn Code:
public AntiCheat()
{
  for(new i = 0; i < MAX_PLAYERS; i++)
  {
    if(ADMIN[i] == false)
    {
      if(GetPlayerWeapon(i) == 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");
      }
      else if(GetPlayerWeapon(i) == 1)
      {
        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");
      }
    }
  }
  return 1;
}
FreshKilla is offline  
Old 18/12/2009, 04:01 AM   #5
BP13
High-roller
 
BP13's Avatar
 
Join Date: Jan 2009
Location: Canada
Posts: 2,034
Reputation: 2
Default Re: Simple Anticheat Check not working

Quote:
Originally Posted by FreshKilla [PR-RP
]
If its using to check if they have weapons why not just make the code simpler and just use:

pawn Code:
if(GetPlayerWeapon(i) == weaponid)
  {
    if(GetPlayerAmmo(i) > 0)
    {
      // Code here...
    }
  }

Then you would follow the pattern with:

pawn Code:
if(GetPlayerWeapon(i) == weaponid)
  {
    if(GetPlayerAmmo(i) > 0)
    {
      // Code here...
    }
  }
  else if(GetPlayerWeapon(i) == weaponid)
  {
    if(GetPlayerAmmo(i) > 0)
    {
      // Code here...
    }
  }

But if its just to check weapons, I recommend using OnPlayerUpdate, its commonly known to be used for Anti Cheats.
I don't really understand whats happening here. I join as a admin and I am free to use the forbidden guns. Then I join as a non admin and then get auto-banned right after I connect?
__________________
BP13 is offline  
Old 28/02/2010, 03:09 PM   #6
DarkPower
Gangsta
 
DarkPower's Avatar
 
Join Date: Feb 2010
Posts: 645
Reputation: 7
Default Re: Simple Anticheat Check not working

Very nice tutorial tnx
DarkPower is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] [FS] Simple AntiCheat TMasters Filterscripts 3 11/06/2010 09:40 PM
I simple cant get the codes working... Lorenc_ Help Archive 2 27/04/2010 09:15 PM
Simple Code Not working Antonio [G-RP] Help Archive 6 17/04/2010 01:43 AM
[Include] [INC] Simple Check VehModel heufix Includes 6 20/09/2009 09:06 PM
AntiCheat not working Robbin237 Help Archive 0 04/04/2009 08:12 AM


All times are GMT. The time now is 05:40 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.