[Help] My anti weapon systen dont work good!
#1

Hey guys,

I just have created a ANTI WEAPON CHEAT SYSTEM.
But it didnt work really work good, I have scripted a lot of weapons, It bans automatically good, but when a player spawn he got basic weapons. But when I press 'Spawn' I am auto banned for weapon cheat, but i didnt cheat, thats WRONG.

Peoples need only automatically banned when they cheat some weapons.
But now peoples got automatically banned when they spawn, because they got basic weapons.

This is the script:

PHP код:
public OnPlayerUpdate(playerid)
{
            new 
weaponid GetPlayerWeapon(playerid);
            new 
Nam[MAX_PLAYER_NAME];
            new 
str[128];
            if(
weaponid == 16)
            {
            
GetPlayerName(playerid,Nam,sizeof(Nam));
            
format(str,sizeof(str),"-UGW- %s (%d) has been automatically banned for killing with and having a cheated Grenade.",Nam);
            
SendClientMessageToAll(0xFF0000FF,str);
            
BanEx(playerid,"Anti Weapon Cheat Hack!");
            }
            if(
weaponid == 39)
            {
            
GetPlayerName(playerid,Nam,sizeof(Nam));
            
format(str,sizeof(str),"-UGW- %s (%d) has been automatically banned for killing with and having a cheated Satchel Charge.",Nam);
            
SendClientMessageToAll(0xFF0000FF,str);
            
BanEx(playerid,"Anti Weapon Cheat Hack!");
            }
            if(
weaponid == 38)
            {
            
GetPlayerName(playerid,Nam,sizeof(Nam));
            
format(str,sizeof(str),"-UGW- %s (%d) has been automatically banned for killing with and having a cheated Minigun.",Nam);
            
SendClientMessageToAll(0xFF0000FF,str);
            
BanEx(playerid,"Anti Weapon Cheat Hack!");
            }
            if(
weaponid == 37)
            {
            
GetPlayerName(playerid,Nam,sizeof(Nam));
            
format(str,sizeof(str),"-UGW- %s (%d) has been automatically banned for killing with and having a cheated Flamethrower.",Nam);
            
SendClientMessageToAll(0xFF0000FF,str);
            
BanEx(playerid,"Anti Weapon Cheat Hack!");
            }
            if(
weaponid == 36)
            {
            
GetPlayerName(playerid,Nam,sizeof(Nam));
            
format(str,sizeof(str),"-UGW- %s (%d) has been automatically banned for killing with and having a cheated HS Rocket.",Nam);
            
SendClientMessageToAll(0xFF0000FF,str);
            
BanEx(playerid,"Anti Weapon Cheat Hack!");
            }
            if(
weaponid == 35)
            {
            
GetPlayerName(playerid,Nam,sizeof(Nam));
            
format(str,sizeof(str),"-UGW- %s (%d) has been automatically banned for killing with and having a cheated RPG.",Nam);
            
SendClientMessageToAll(0xFF0000FF,str);
            
BanEx(playerid,"Anti Weapon Cheat Hack!");
            }
            if(
weaponid == 44)
            {
            
GetPlayerName(playerid,Nam,sizeof(Nam));
            
format(str,sizeof(str),"-UGW- %s (%d) has been automatically banned for killing with and having a Night Vis Goggles.",Nam);
            
SendClientMessageToAll(0xFF0000FF,str);
            
BanEx(playerid,"Anti Weapon Cheat Hack!");
            }
            if(
weaponid == 45)
            {
            
GetPlayerName(playerid,Nam,sizeof(Nam));
            
format(str,sizeof(str),"-UGW- %s (%d) has been automatically banned for killing with and having a cheated Thermal Goggles.",Nam);
            
SendClientMessageToAll(0xFF0000FF,str);
            
BanEx(playerid,"Anti Weapon Cheat Hack!");
            }
            if(
weaponid == 43)
            {
            
GetPlayerName(playerid,Nam,sizeof(Nam));
            
format(str,sizeof(str),"-UGW- %s (%d) has been automatically banned for killing with and having a cheated Camera.",Nam);
            
SendClientMessageToAll(0xFF0000FF,str);
            
BanEx(playerid,"Anti Weapon Cheat Hack!");
            }
            if(
weaponid == 46)
            {
            
GetPlayerName(playerid,Nam,sizeof(Nam));
            
format(str,sizeof(str),"-UGW- %s (%d) has been automatically banned for killing with and having a cheated Parachute.",Nam);
            
SendClientMessageToAll(0xFF0000FF,str);
            
BanEx(playerid,"Anti Weapon Cheat Hack!");
            }
            if(
weaponid == 41)
            {
            
GetPlayerName(playerid,Nam,sizeof(Nam));
            
format(str,sizeof(str),"-UGW- %s (%d) has been automatically banned for killing with and having a cheated Spraycan.",Nam);
            
SendClientMessageToAll(0xFF0000FF,str);
            
BanEx(playerid,"Anti Weapon Cheat Hack!");
            }
            if(
weaponid == 40)
            {
            
GetPlayerName(playerid,Nam,sizeof(Nam));
            
format(str,sizeof(str),"-UGW- %s (%d) has been automatically banned for killing with and having a cheated Detanator.",Nam);
            
SendClientMessageToAll(0xFF0000FF,str);
            
BanEx(playerid,"Anti Weapon Cheat Hack!");
            }
            if(
weaponid == 42)
            {
            
GetPlayerName(playerid,Nam,sizeof(Nam));
            
format(str,sizeof(str),"-UGW- %s (%d) has been automatically banned for killing with and having a cheated Fire Extinguisher.",Nam);
            
SendClientMessageToAll(0xFF0000FF,str);
            
BanEx(playerid,"Anti Weapon Cheat Hack!");
            }
            if(
weaponid == 34)
            {
            
GetPlayerName(playerid,Nam,sizeof(Nam));
            
format(str,sizeof(str),"-UGW- %s (%d) has been automatically banned for killing with and having a cheated Sniper Rifle.",Nam);
            
SendClientMessageToAll(0xFF0000FF,str);
            
BanEx(playerid,"Anti Weapon Cheat Hack!");
            }
            if(
weaponid == 33)
            {
            
GetPlayerName(playerid,Nam,sizeof(Nam));
            
format(str,sizeof(str),"-UGW- %s (%d) has been automatically banned for killing with and having a cheated Country Rifle.",Nam);
            
SendClientMessageToAll(0xFF0000FF,str);
            
BanEx(playerid,"Anti Weapon Cheat Hack!");
            }
            if(
weaponid == 32)
            {
            
GetPlayerName(playerid,Nam,sizeof(Nam));
            
format(str,sizeof(str),"-UGW- %s (%d) has been automatically banned for killing with and having a cheated Tec9.",Nam);
            
SendClientMessageToAll(0xFF0000FF,str);
            
BanEx(playerid,"Anti Weapon Cheat Hack!");
            }
            if(
weaponid == 31)
            {
            
GetPlayerName(playerid,Nam,sizeof(Nam));
            
format(str,sizeof(str),"-UGW- %s (%d) has been automatically banned for killing with and having a cheated M4.",Nam);
            
SendClientMessageToAll(0xFF0000FF,str);
            
BanEx(playerid,"Anti Weapon Cheat Hack!");
            }
            if(
weaponid == 30)
            {
            
GetPlayerName(playerid,Nam,sizeof(Nam));
            
format(str,sizeof(str),"-UGW- %s (%d) has been automatically banned for killing with and having a cheated AK 47.",Nam);
            
SendClientMessageToAll(0xFF0000FF,str);
            
BanEx(playerid,"Anti Weapon Cheat Hack!");
            }
            if(
weaponid == 29)
            {
            
GetPlayerName(playerid,Nam,sizeof(Nam));
            
format(str,sizeof(str),"-UGW- %s (%d) has been automatically banned for killing with and having a cheated MP5.",Nam);
            
SendClientMessageToAll(0xFF0000FF,str);
            
BanEx(playerid,"Anti Weapon Cheat Hack!");
            }
            if(
weaponid == 28)
            {
            
GetPlayerName(playerid,Nam,sizeof(Nam));
            
format(str,sizeof(str),"-UGW- %s (%d) has been automatically banned for killing with and having a cheated Micro SMG Uzi.",Nam);
            
SendClientMessageToAll(0xFF0000FF,str);
            
BanEx(playerid,"Anti Weapon Cheat Hack!");
            }
            if(
weaponid == 27)
            {
            
GetPlayerName(playerid,Nam,sizeof(Nam));
            
format(str,sizeof(str),"-UGW- %s (%d) has been automatically banned for killing with and having a cheated Combat shotgun.",Nam);
            
SendClientMessageToAll(0xFF0000FF,str);
            
BanEx(playerid,"Anti Weapon Cheat Hack!");
            }
            if(
weaponid == 26)
            {
            
GetPlayerName(playerid,Nam,sizeof(Nam));
            
format(str,sizeof(str),"-UGW- %s (%d) has been automatically banned for killing with and having a cheated Sawnoff shotgun.",Nam);
            
SendClientMessageToAll(0xFF0000FF,str);
            
BanEx(playerid,"Anti Weapon Cheat Hack!");
            }
            if(
weaponid == 25)
            {
            
GetPlayerName(playerid,Nam,sizeof(Nam));
            
format(str,sizeof(str),"-UGW- %s (%d) has been automatically banned for killing with and having a cheated Shotgun.",Nam);
            
SendClientMessageToAll(0xFF0000FF,str);
            
BanEx(playerid,"Anti Weapon Cheat Hack!");
            }
            if(
weaponid == 24)
            {
            
GetPlayerName(playerid,Nam,sizeof(Nam));
            
format(str,sizeof(str),"-UGW- %s (%d) has been automatically banned for killing with and having a cheated Desert Eagle.",Nam);
            
SendClientMessageToAll(0xFF0000FF,str);
            
BanEx(playerid,"Anti Weapon Cheat Hack!");
            }
            if(
weaponid == 23)
            {
            
GetPlayerName(playerid,Nam,sizeof(Nam));
            
format(str,sizeof(str),"-UGW- %s (%d) has been automatically banned for killing with and having a cheated Silenced 9mm.",Nam);
            
SendClientMessageToAll(0xFF0000FF,str);
            
BanEx(playerid,"Anti Weapon Cheat Hack!");
            }
            if(
weaponid == 22)
            {
            
GetPlayerName(playerid,Nam,sizeof(Nam));
            
format(str,sizeof(str),"-UGW- %s (%d) has been automatically banned for killing with and having a cheated 9mm.",Nam);
            
SendClientMessageToAll(0xFF0000FF,str);
            
BanEx(playerid,"Anti Weapon Cheat Hack!");
            }
            if(
weaponid == 17)
            {
            
GetPlayerName(playerid,Nam,sizeof(Nam));
            
format(str,sizeof(str),"-UGW- %s (%d) has been automatically banned for killing with and having a cheated Tear Gas.",Nam);
            
SendClientMessageToAll(0xFF0000FF,str);
            
BanEx(playerid,"Anti Weapon Cheat Hack!");
            }
            return 
1;

Hope anyone can fix this or help me out of this bug.

Thanks
Reply
#2

The way you are doing this is stupid. You are probably being banned because you have a weapon that it being used in the OnPlayerUpdate to ban, such as a 9mm will ban you if you have one.

Use this type of thing if you wish to make it so weapons cannot be hacked and if they are, they will be banned.

pawn Код:
enum wTypes
{
    Melee,
    Rifle,
    //Etcetra
};
new Weapons[MAX_PLAYERS][wTypes];

stock GivePlayerServerWeapon(playerid, weaponid, ammo)
{
    if(!IsPlayerConnected(playerid)) return 1;
    if(weapon == 34) //If the weapon is a rifle (sniper rifle)
    {
        Weapons[MAX_PLAYERS][Rifle] = weaponid;
    }
    //same process, but depending on weapon, type changes
    GivePlayerWeapon(playerid, weaponid, ammo); // It is now save to use this function
    return 1;
}

stock CheckWeapons(playerid)
{
    if(!IsPlayerConnected(playerid)) return 1;
    new WeaponRifle[2];
    GetPlayerWeaponData(playerid, 6, WeaponRifle[0], WeaponRife[1]); //player, weaponslot, variable to store weaponid, variable to store ammo
    if(Weapons[MAX_PLAYERS][Rifle] != WeaponRifle[0]) //If the Weapon he is carrying in the rifle slot is not set into the variable (not given, hacked)
    {
        //What to do if player hacked sniper rifle, should use custom stock for this such as BanPlayer(playerid) to avoid having to type this out each time
    }
    return 1;
}
Keep adding the codes for different weapons, so that it can make it so ANY weapon that is hacked will ban them.

Use CheckWeapons(playerid); under OnPlayerUpdate to check if they hacked a weapon.

Use GivePlayerServerWeapon instead of GivePlayerWeapon to avoid getting the player banned.
Reply
#3

Well what do you expect? You're not saving which weapons a player has legitimately acquired.
Oh, and this is probably the most unmaintainable piece of code that I have ever seen. Hint: GetWeaponName

Edit: Damn, I shouldn't think that long about what I'd want to write. :/
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)