KeyStateChange - Anti weapon hack help
#1

Help me fix this, it keeps giving me errors


pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
        if(newkeys & KEY_FIRE && ForbiddenGuns(playerid) && !pInfo[playerid][pLevel] >= 0)) // firs this was IsPlayerAdmin but i need it to block admins, not rcon. ever since i changed it i got errors, help me fix
        {
            new pname[MAX_PLAYER_NAME];
            new zstr[124];
            GetPlayerName(playerid, pname, sizeof(pname));
            format(zstr, sizeof(string), "SERVER: %s has been banned! Reason: Forbidden weapon", pname);
            SendClientMessageToAll(0xFF1A00C8,zstr);
            print(zstr);
            BanEx(playerid,zstr);
            }
        }
        // and other codes below this but its no point posting them cause the errors are here xd ^
Reply
#2

Change
pawn Код:
!pInfo[playerid][pLevel] >= 0)
to
pawn Код:
pInfo[playerid][pLevel] == 0
Should only check people who have the (admin?) level of 0
Reply
#3

Why don't you stick simpler operators? That last part will always return true, regardless of what level the player actually is.

Let's say the admin level is 0: 0 inverted becomes 1, 1 is greater than or equal to 0, statement is true. However, let's now assume that the admin level is 5: 5 inverted becomes 0, 0 is greater than or equal to 0, statement is true.

Much simpler to just do:
pawn Код:
pInfo[playerid][pLevel] < 1
Reply
#4

There is a closed bracket that shouldn't be there under BanEx. Fix it like this:
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_FIRE && ForbiddenGuns(playerid) && !pInfo[playerid][pLevel] >= 0)) // firs this was IsPlayerAdmin but i need it to block admins, not rcon. ever since i changed it i got errors, help me fix
    {
        new pname[MAX_PLAYER_NAME];
        new zstr[124];
        GetPlayerName(playerid, pname, sizeof(pname));
        format(zstr, sizeof(string), "SERVER: %s has been banned! Reason: Forbidden weapon", pname);
        SendClientMessageToAll(0xFF1A00C8,zstr);
        print(zstr);
        BanEx(playerid,zstr);
    }
}
Reply
#5

And there's another bracket in plus in that if statement.

Код:
        if(newkeys & KEY_FIRE && ForbiddenGuns(playerid) && !pInfo[playerid][pLevel] >= 0))
Delete it
Reply
#6

So the final solution is:
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_FIRE && ForbiddenGuns(playerid) && !pInfo[playerid][pLevel] >= 0) // firs this was IsPlayerAdmin but i need it to block admins, not rcon. ever since i changed it i got errors, help me fix
    {
        new pname[MAX_PLAYER_NAME];
        new zstr[124];
        GetPlayerName(playerid, pname, sizeof(pname));
        format(zstr, sizeof(string), "SERVER: %s has been banned! Reason: Forbidden weapon", pname);
        SendClientMessageToAll(0xFF1A00C8,zstr);
        print(zstr);
        BanEx(playerid,zstr);
    }
}
Reply


Forum Jump:


Users browsing this thread: