Health set - 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: Health set (
/showthread.php?tid=380315)
Health set -
DaRk_RaiN - 24.09.2012
Hi samp i have a question with SetPlayerHealth
I need the player to lose 50hp with each sniper shot and yes i did use OnPlayerTakeDamage before the following code
//================================================== ========
if(issuerid != INVALID_PLAYER_ID && weaponid == 34)
{
new Float:health;
SetPlayerHealth(playerid,GetPlayerHealth(playerid, health-50));//wouldn't compile and even if it did it ouldn't work proparly
}
return 1;
}
//================================================== =====================
Thanks for reading!
Re: Health set -
clarencecuzz - 24.09.2012
Syntax for GetPlayerHealth:
Код:
GetPlayerHealth(playerid, Float:&Health);
You need to save the parameter 'Health' to another variable like so.
pawn Код:
if(issuerid != INVALID_PLAYER_ID && weaponid == 34)
{
new Float:health;
GetPlayerHealth(playerid, health); //We're saving it to our new Float:health variable.
SetPlayerHealth(playerid, (health - 50));
return 1;
}
Re: Health set -
DaRk_RaiN - 25.09.2012
Wouldn't work
Re: Health set -
clarencecuzz - 26.09.2012
Try it now...
pawn Код:
if(issuerid != INVALID_PLAYER_ID)
{
if(weaponid == 34)
{
new Float:health;
GetPlayerHealth(playerid, health); //We're saving it to our new Float:health variable.
SetPlayerHealth(playerid, ((health + amount) - 50));
}
return 1;
}
Re: Health set -
ikbenremco - 26.09.2012
pawn Код:
if(issuerid != INVALID_PLAYER_ID)
{
if(weaponid == 34)
{
new Float:health;
GetPlayerHealth(playerid, health); //We're saving it to our new Float:health variable.
SetPlayerHealth(playerid, (health)-50);
}
return 1;
}
or replace
SetPlayerHealth(playerid, (health)-50);
with
SetPlayerHealth(playerid, -50);
Re: Health set -
DaRk_RaiN - 26.09.2012
Quote:
Originally Posted by clarencecuzz
Try it now...
pawn Код:
if(issuerid != INVALID_PLAYER_ID) { if(weaponid == 34) { new Float:health; GetPlayerHealth(playerid, health); //We're saving it to our new Float:health variable. SetPlayerHealth(playerid, ((health + amount) - 50)); } return 1; }
|
Works!
Thanks again