View Full Version : OnPlayerTakeDamage

09/05/2016, 12:57 PM
For some reason this doesn't work:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
if (GodMode[playerid] == 1)
new Float:health;
if (health < 150.0)
SetPlayerHealth(playerid, 200.0);
I have a /god command for level 3+ admins which enables god mode, but the code above doesn't seem to work. Also don't suggest making it SetPlayerHealth(playerid, 9999999) when typing /god, because this doesn't work for some reason in my server. :) Does anybody know what is the issue?

09/05/2016, 01:01 PM
maybe this need be under OnPlayerUpdate (https://wiki.sa-mp.com/wiki/OnPlayerUpdate)

09/05/2016, 01:04 PM
I'm not sure if GetPlayerHealth returns the old health so the if statement is always false but I will suggest something else:

SetPlayerHealth(playerid, Float: 0x7F800000);

for infinity health.

09/05/2016, 01:39 PM
OnPlayerUpdate worked, thanks. :)