SA-MP Forums Archive
OnPlayerTakeDamage. - 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: OnPlayerTakeDamage. (/showthread.php?tid=388442)



OnPlayerTakeDamage. - budelis - 28.10.2012

Hi,

Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
if( issuerid != INVALID_PLAYER_ID )
{
GetPlayerHealth( playerid, HealthSave[ issuerid ] );
SetPlayerHealth( playerid, HealthSave[ issuerid ]-floatround( LEVEL[ issuerid ]/2 )  );
}
return 1;
}
Whats bad in this code? when i shoot to player he is invinsible? player level is 1.


Re: OnPlayerTakeDamage. - PrawkC - 28.10.2012

That code makes it so when a player takes damage and the person who caused the damage is not an invalid player, it will heal the person who took damage.

So that'd be why.


Re: OnPlayerTakeDamage. - budelis - 28.10.2012

But how it can plus (+) health player if i minus (-) health?

Код:
SetPlayerHealth( playerid, HealthSave[ issuerid ]    ( HERE   -floatround( LEVEL[ issuerid ]/2 )  );



Re: OnPlayerTakeDamage. - PrawkC - 28.10.2012

You're setting the persons health to the shooters health minus 1.. every shot, so you're always just setting his health.


Re: OnPlayerTakeDamage. - budelis - 28.10.2012

Ok then how i have to do, i want when i shoot to another player that player will lose hp that how much is my level ( LEVEL variable ) divide by 2.


Re: OnPlayerTakeDamage. - PrawkC - 28.10.2012

Well, its probably working.. but each shot is only taking 1 health away.. so you wont really notice it.. try and set your level to like 20 and then see.


Re: OnPlayerTakeDamage. - budelis - 29.10.2012

But my code is not working. When i shoot to another player he get health i can't kill him, when i remove this code all is well.