Oldkeys not being called.
#1

I'm working on an anti cheat which works however, oldkeys does not get called. Could someone please tell me how I'd fix this.
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    //Order in likeliness NEVER define a state more than once (Unless its in old keys not new keys. Vice Versa)
    //Another example could be where you check multiple keys, in this case do these at the top! Never return in these.
    //New Key checks
    switch(newkeys)
    {
        //Anti-Cheat (Weapon Checks)
        case KEY_AIM, KEY_FIRE:
        {
            new WeaponData[2];
            for(new i = 0; i < 12; i++)
            {
                GetPlayerWeaponData(playerid, i, WeaponData[0], WeaponData[1]);
                if(WeaponData[0] != Weapons[playerid][i][0]) BanPlayer(playerid, "Anti-Cheat", "Weapon Hacking");
                if(WeaponData[1] > Weapons[playerid][i][1]) BanPlayer(playerid, "Anti-Cheat", "Ammo Hacking");
            }
        }
    }
    //Old Key Checks
    switch(oldkeys)
    {
        //Anti-Cheat (After Firing (Collect new values)
        case KEY_FIRE:
        {
            new WeaponData[2];
            GetPlayerWeaponData(playerid, GetWeaponSlot(GetPlayerWeapon(playerid)), WeaponData[0], WeaponData[1]);
            Weapons[playerid][GetWeaponSlot(GetPlayerWeapon(playerid))][1] = WeaponData[1];
            printf("Ammo %s", WeaponData[1]); //Something tell me its the samp call back being slow, test this.
        }
    }
    return 1;
}
Reply
#2

This doesn't work because newkeys and oldkeys are binary maps that contain the state of all keys. 'KEY_FIRE' is not the same as 'KEY_FIRE combined with KEY_AIM'.
Reply
#3

Not the problem. The problem is, Oldkeys isn't being called. However, Newkeys is.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)