View Full Version : Anti lag shoot

08/12/2013, 12:43 AM
Should this work as an anti lag shoot. Can't test since I'm not home

public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid)
if(damagedid != INVALID_PLAYER_ID)
new Float:heath, Float:armour;
GetPlayerArmour(damagedid, armour);
GetPlayerHealth(damagedid, heath);
if(armour > 0)
if(amount > armour) {
SetPlayerArmour(damagedid, 0);
else SetPlayerArmour(damagedid, armour-amount);
else SetPlayerHealth(damagedid, heath-amount);
return 1;

08/12/2013, 12:47 AM
Theoretically yes..

08/12/2013, 12:51 AM
Anything I could add to improve it?

08/12/2013, 03:11 AM
Ain't gonna work properly at all how is OnPlayerDeath() to know who killed the player.

08/12/2013, 03:48 AM
with that script, if a player has 10 armour and takes 40 damage, he'll only suffer 10 damage since it'll only take off his armour

here's another example, two players shoot the same guy call them player A and player B, player X is the one getting shot

player X is on 100 health
player A deals 30 damage to player X
server gets his health and sends the message to lower his health to 70
player B deals 10 damage a split second later to player X
server gets his health, player X has not yet updated his new health, so server thinks he's still on 100 health
server sends message to player X to set the health to 90

what others see is player x getting shot multiple times and his health goes down to 70 and then jumps back up to 90

there are some scripts about anti lag already, you should check them out and have server side variables to track the health values