Anticheat
#3

Here's one possible approach:
  1. Keep track of the weapons that each player has been given by the server using an array of length 13.
  2. When a player is given a weapon by the server, store the ID of that weapon in their array to indicate that they are supposed to have that gun.
  3. When a player damages another player, make sure that they are expected to have the weapon they're using.
The required code would look something like this:
Код:
#define MAX_PLAYERS 32 //Player capacity of your server

new weapons[MAX_PLAYERS][13]; //Store the weapon each player should have in a specific slot

//Function to give players a weapon
giveGun(playerid, weaponid, ammo)
{
	GivePlayerWeapon(playerid, weaponid, ammo);
	
	//Keep track of what weapons the player has
	for(new i = 0; i < 13; i++)
	{
		new temp;
		GetPlayerWeaponData(playerid, i, weapons[playerid][i], temp);
	}
}

public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid, bodypart)
{
	new bool:allowedWeapon = false;
	for(new i = 0; i < 13; i++)
	{
		if(weapons[playerid][i] == weaponid)
		{
			allowedWeapon = true;
			break;
		}
	}
	
	if(allowedWeapon == false)
	{
		//We did not expect the player to have this weapon, they must have cheated!
		//Do something.
	}

	return 1;
}
In order for this code to function without false positives, it will be necessary to prevent players from acquiring weapons using the default ammunition, add your own checkpoint etc.
Reply


Messages In This Thread
Anticheat - by AdelS - 18.10.2014, 07:47
Re: Anticheat - by Rudy_ - 18.10.2014, 13:39
Re: Anticheat - by Simeon87 - 18.10.2014, 15:08
Re: Anticheat - by AdelS - 18.10.2014, 16:40

Forum Jump:


Users browsing this thread: 1 Guest(s)