Anticheat
#1

Код:
AC_GivePlayerWeapon(playerid, weaponid, muni)
{
   Sigurnaora[playerid] = 1;
   GivePlayerWeapon(playerid, weaponid, muni);
   return 1;
}
How can I make if a player have a weapon that is not gave with AC_GivePlayerWeapon ,that kick him.
Reply
#2

Edit: nvm
Reply
#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
#4

I make it already,but thanks.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)