#include <a_samp>
new bool:PlayerWeapons[MAX_PLAYERS][47],bool:Spawned[MAX_PLAYERS];
// On top
public OnPlayerConnect(playerid)
{
for(new i=0;i<47;i++) PlayerWeapons[playerid][i]=false; // clears the value
Spawned[playerid]=false;
return 1;
}
public OnPlayerSpawn(playerid)
{
SetTimerEx("RealSpawn",500,false,"i",playerid);
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
new model = GetVehicleModel(GetPlayerVehicleID(playerid));
switch(model)
{
case 592,577,511,512,520,593,553,476,519,460,513,548,425,417,487,488,497,563,447,469: PlayerWeapons[playerid][46]=true;
case 457: PlayerWeapons[playerid][2]=true;
case 596,597,598,599: PlayerWeapons[playerid][25]=true;
}
}
}
forward RealSpawn(playerid);
public RealSpawn(playerid)
{
Spawned[playerid]=true;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_FIRE)
{
if(Spawned[playerid])
{
new weapon = GetPlayerWeapon(playerid);
if(weapon != 0 && !PlayerWeapons[playerid][weapon] && weapon != 40) // if weapon is not fists, and weapon is not a remote control.
BanEx(playerid,"GUN HACKS");
}
}
}
stock GivePlayerWeaponEx(playerid,weaponid,ammo)
{
PlayerWeapons[playerid][weaponid]=true; // Player Has the weapon.
GivePlayerWeapon(playerid,weaponid,ammo); // To realy give him the weapon.
}
#include <a_samp>
#include <YSI\y_bit>
new
BitArray:gPlayerWeapons[46]<MAX_PLAYERS>,
BitArray:gSpawned<MAX_PLAYERS>;
// On top
public OnPlayerConnect(playerid)
{
for(new i=0;i<47;i++) PlayerWeapons[playerid][i]=false; // clears the value
Bit_Set(gSpawned, playerid, false);
return 1;
}
public OnPlayerSpawn(playerid)
{
SetTimerEx("RealSpawn",500,false,"i",playerid);
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{
new model = GetVehicleModel(GetPlayerVehicleID(playerid));
switch(model)
{
case 592,577,511,512,520,593,553,476,519,460,513,548,425,417,487,488,497,563,447,469: Bit_Set(gPlayerWeapons[46], playerid, true);
case 457: Bit_Set(gPlayerWeapons[2], playerid, true);
case 596,597,598,599: Bit_Set(gPlayerWeapons[25], playerid, true);
}
}
}
forward RealSpawn(playerid);
public RealSpawn(playerid)
{
Bit_Set(gSpawned, playerid, true);
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_FIRE)
{
if(Bit_Get(gSpawned, playerid))
{
new weapon = GetPlayerWeapon(playerid);
if(weapon != 0 && !Bit_Get(gPlayerWeapons[weapon], playerid) && weapon != 40) // if weapon is not fists, and weapon is not a remote control.
BanEx(playerid,"GUN HACKS");
}
}
}
stock GivePlayerWeaponEx(playerid,weaponid,ammo)
{
Bit_Set(gPlayerWeapons[weaponid], playerid, true);
GivePlayerWeapon(playerid,weaponid,ammo); // To realy give him the weapon.
}
This need to be at lolo code..
Your script will ban everyone who will scroll the weapon .. For example .. he gets Uzi and deagle in server right way, no cheating. The variable sets to last given weapon ( for example tec ) he scrolls to deagle. and woot.. he gets banned.. . |
This bans people, who get out of a helicopter, because when they get out of a heli or plane, they get parachute...
|
Sorry, i didnt have time to check how many weapons are there, and i left it like that. Now its changed. Also i fixed the parachute bug(i dont think anyone spawns parachutes anyway). Maybe it's not perfect, but show my a better gun anti cheat? Wait. I can change it to title "Best gun anti cheat", if its better for you.
|