Anti Weapon Hack only for ID 0
#1

Hello guys

I have an anti weapon hack but strangely it only detects the forbidden weapons from id 0.

Does anyone know why?
Reply
#2

how about showing the code? xd
Reply
#3

You probably have a for loop where you're returning inside of it. That way it'd only scan player 0 and then end the loop.
Reply
#4

pawn Code:
forward WeaponHackCheck(playerid);
pawn Code:
public OnFilterScriptInit()
{
    SetTimer("WeaponHackCheck", 1000, true);
    return 1;
}
pawn Code:
public WeaponHackCheck(playerid)
{
    if(GetPlayerWeapon(playerid) == 16 && AccInfo[playerid][vip] == 0 || GetPlayerWeapon(playerid) == 35 && AccInfo[playerid][vip] == 0 || GetPlayerWeapon(playerid) == 36 && AccInfo[playerid][vip] == 0 || GetPlayerWeapon(playerid) == 37 && AccInfo[playerid][vip] == 0 || GetPlayerWeapon(playerid) == 38 && AccInfo[playerid][vip] == 0 || GetPlayerWeapon(playerid) == 39 && AccInfo[playerid][vip] == 0)
    {
      for(new i=0;i<50;i++)
      {
        new PlayerName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
        new var;
        new warned = strval(PlayerName);
        new str[128], string3[100];
        new lbweapon[64];
        AccInfo[warned][HackWarnings]++;
        var=GetPlayerWeapon(i);
        GetWeaponName(var,lbweapon,sizeof(lbweapon));
        if( AccInfo[warned][HackWarnings] == 5)
        {
        format(str,sizeof(str),"%s has automatically been kicked [Reason: Weapon Hack (%s)]",PlayerName,lbweapon);
        SendClientMessageToAll(red,str);
        SaveIn("KickLog",str);
        Kick(warned);
        return AccInfo[warned][HackWarnings] = 0;
        }
        else
        {
        var=GetPlayerWeapon(i);
        format(str, sizeof (str), "Admin Chat: WARNING: %s has a %s || Warning: %d/5", pName(warned),lbweapon,AccInfo[warned][HackWarnings]);
        MessageToAdmins(orange,str);
        format(string3, sizeof (string3), "WARNING: Weapon Hacks are not allowed! || Warning: %d/5",AccInfo[warned][HackWarnings]);
        return SendClientMessage(playerid,red,string3);
        }
    }
      }
    return 1;
}
Reply
#5

That code is very inefficient and won't even work for anyone but playerid 0. You can't pass a playerid parameter if you're calling the timer in OnGameModeInit. The script doesn't know which playerid to use so it just uses 0. Also, if a player has an illegal weapon, it just adds to his warnings once a second until it gets to five.
Reply
#6

Backwardsman, can you show me how to fix this code or can you rewrite it so that it works?

Would be very nice
Reply
#7

This is not the sulution, but i would recommend you using GetPlayerWeaponData in stead of GetPlayerWeapon.
Reply
#8

Well, I need a solution sim_sima. D:



Can somebody rewrite this so that it works? Unfortunately Backwardsman went off.
Reply
#9

Well I don't really understand what you're doing here.

pawn Code:
new warned = strval(PlayerName);
AccInfo[warned][HackWarnings]++;
You use the integer equivalent of the player's name as the index for AccInfo? Why not just use the playerid? Like this.

pawn Code:
AccInfo[playerid][HackWarnings]++;
Reply
#10

Quote:
Originally Posted by Julian12345
View Post
Well, I need a solution sim_sima. D:



Can somebody rewrite this so that it works? Unfortunately Backwardsman went off.
I just helped you making it better.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)