18.03.2012, 02:30
(
Последний раз редактировалось Snipa; 28.07.2014 в 00:10.
)
Alright, so this will allow you to enjoy your server without the pain of weapon hackers.
What we'll need first is foreach, a fast and easy to use looping system made by ******.
https://sampforum.blast.hk/showthread.php?tid=92679
Add
to the top of your script.
Alright, so under your includes and all, add this:
That'll create a variable (true/false) for every player, for every weapon.
Also add this to your script. That will make 2 new functions, one which makes sure the variable is set when the player is given the weapon and the other which makes sure the variable is set to false when weapons need to be reset.
REPLACE ALL INSTANCES OF GivePlayerWeapon AND ResetPlayerWeapon WITH GivePlayerWeaponEx AND ResetPlayerWeaponEx!
Now in your OnPlayerConnect:
That will set all weapons to false when a player connects and disconnects.
Now, time for a warning/ban code:
Add this:
Let me explain, the OnGameModeInit sets a timer to execute the anticheat function every 1000 ms (1 second).
The AntiCheat loops through every player, gets their weapon, and if it's false, it checks their state, so if it's 1, 2, or 3........
Oh, almost forgot! Be sure to give a parachute on spawn or script a workaround. Also for police cars and the caddy.
Euh, if anything's wrong, just tell me..
What we'll need first is foreach, a fast and easy to use looping system made by ******.
https://sampforum.blast.hk/showthread.php?tid=92679
Add
pawn Код:
#include <foreach>
Alright, so under your includes and all, add this:
pawn Код:
new bool:Weapon[MAX_PLAYERS][47];
pawn Код:
GivePlayerWeaponEx(playerid,weaponid,ammo)
{
Weapon[playerid][weaponid] = true;
return GivePlayerWeapon(playerid,weaponid,ammo);
}
ResetPlayerWeaponsEx(playerid)
{
for(new i=0;i<47;i++) Weapon[playerid][i] = false;
ResetPlayerWeapons(playerid);
}
REPLACE ALL INSTANCES OF GivePlayerWeapon AND ResetPlayerWeapon WITH GivePlayerWeaponEx AND ResetPlayerWeaponEx!
Now in your OnPlayerConnect:
pawn Код:
public OnPlayerConnect(playerid)
{
ResetPlayerWeaponsEx(playerid);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
ResetPlayerWeaponsEx(playerid);
return 1;
}
Now, time for a warning/ban code:
Add this:
pawn Код:
public OnGameModeInit()
{
SetTimer("AntiCheat", 1000, 1);
return 1;
}
forward AntiCheat();
public AntiCheat()
{
foreach(Player, i)
{
new weap = GetPlayerWeapon(i);
if(weap != 46 && weap != 40 && weap > 0 && Weapon[i][weap] == false)
{
if(GetPlayerState(i) == 1 || GetPlayerState(i) == 2 || GetPlayerState(i) == 3) {
//Ban or warning code here
}
}
}
return 1;
}
The AntiCheat loops through every player, gets their weapon, and if it's false, it checks their state, so if it's 1, 2, or 3........
Oh, almost forgot! Be sure to give a parachute on spawn or script a workaround. Also for police cars and the caddy.
Euh, if anything's wrong, just tell me..