18.08.2013, 16:53
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;
}