24.09.2017, 12:19
What about this way? using OnPlayerUpdate:
I've tested it in localhost and as far as I can see it works flawless, debugged it and the values seems accurate.
Will it work the same in the VPS? with +20 players?
PHP код:
public OnPlayerUpdate(playerid) {
new player_weapon = GetPlayerWeapon(playerid);
if(player_weapon)
DetectAmmoCheats(playerid, player_weapon);
return 1;
}
DetectAmmoCheats(playerid, weaponid) {
new weapon_id, weapon_ammo;
GetPlayerWeaponData(playerid, GetWeaponSlot(weaponid), weapon_id, weapon_ammo);
if(Info[playerid][Logged] && !InEvent[playerid] && !InDerby[playerid] && !InTDM[playerid] && !InParkour[playerid] && !InSkydive[playerid] && !InDuel[playerid] && !Info[playerid][InDM] && !InShooter[playerid]) {
if(weapon_ammo > 0 && weapon_ammo > gPlayerAmmo[playerid][GetWeaponSlot(weaponid)] + 10 && GetPlayerVirtualWorld(playerid) == 0) {
RemovePlayerWeapon(playerid, weaponid);
Info[playerid][Logged] = 0;
format(string, sizeof string, "{FF0000}<!> {CC6699}%s has been kicked for ammo hack", GetName(playerid));
SendClientMessageToAll(red, string);
return DelayKick(playerid);
}
else gPlayerAmmo[playerid][GetWeaponSlot(weaponid)] = weapon_ammo;
}
return 1;
}
Will it work the same in the VPS? with +20 players?