Anticheat - 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)
+--- Thread: Anticheat (
/showthread.php?tid=542271)
Anticheat -
AdelS - 18.10.2014
Код:
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.
Re: Anticheat -
Rudy_ - 18.10.2014
Edit: nvm
Re: Anticheat -
Simeon87 - 18.10.2014
Here's one possible approach:
- Keep track of the weapons that each player has been given by the server using an array of length 13.
- 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.
- 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.
Re: Anticheat -
AdelS - 18.10.2014
I make it already,but thanks.