PDA

View Full Version : OnPlayerKeyStateChange


Yvax
17/01/2012, 02:59 PM
Hi,

So I have this problem..I'm using OnPlayerKeyStateChange to detect if a player is weapon or ammo cheating.I'm doing it by saving all the weapons in variables and then comparing them with the actual player stats.The problem is(I think) that OPKSC is too slow, or there's something wrong I'm doing.

When a player starts shooting, ammo hack is detected because variables are not updated as fast as the player shoots.

Here's an example:

OnPlayerKeyStateChange

AntiWeaponCheat(playerid);
new weapon = GetPlayerWeapon(playerid);
new slot = GetWeaponSlot(weapon);
PlayerInfo[playerid][WP][0][slot] = weapon;//[WP][0] = Weapon | [WP][1] = Ammo
PlayerInfo[playerid][WP][1][slot] = GetPlayerAmmo(playerid);


public AntiWeaponCheat(playerid)
{
new weapon = GetPlayerWeapon(playerid);
new slot = GetWeaponSlot(weapon);
if(weapon != PlayerInfo[playerid][WP][0][slot] || GetPlayerAmmo(playerid) != PlayerInfo[playerid][WP][1][slot])
{
Ban(playerid);
}
}

Yvax
17/01/2012, 03:44 PM
And another thing, when someone presses KEY_FIRE very fast, many times, it just doesn't update the variables that fast..so it bans the player :|

Vince
17/01/2012, 04:27 PM
4-dimensional arrays are not supported as far as I know, the maximum is 3.

Yvax
17/01/2012, 04:31 PM
Yeah, ignore that, it's the first version, I changed that a while ago.Now its Players[playerid][Weapons][slot] and Players[playerid][Ammo][slot]