Oldkeys not being called. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Oldkeys not being called. (
/showthread.php?tid=458802)
Oldkeys not being called. -
Binx - 18.08.2013
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;
}
Re: Oldkeys not being called. -
Vince - 18.08.2013
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'.
Re: Oldkeys not being called. -
Binx - 18.08.2013
Not the problem. The problem is, Oldkeys isn't being called. However, Newkeys is.