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



GetPlayerHealth - =WoR=Varth - 03.09.2011

pawn Код:
new Float:Health[2];
GetPlayerHealth(playerid,Health[0]);
SetPlayerHealth(playerid,Health[0] - 5);
GetPlayerHealth(playerid,Health[1]);
printf("Old:%f New:%f",Health[0],Health[1]);

Old: 100.00000
New: 100.00000//?????
EDIT:
But if I make a timer with (Above)100ms interval, GetPlayerHealth give me the correct health.


Re: GetPlayerHealth - cessil - 03.09.2011

it's not a bug, GetPlayerHealth returns the value the client sent last, since you're script isn't waiting for the client to update it's not returning the newly updated variable


Re: GetPlayerHealth - =WoR=Varth - 03.09.2011

Quote:
Originally Posted by cessil
Посмотреть сообщение
it's not a bug, GetPlayerHealth returns the value the client sent last, since you're script isn't waiting for the client to update it's not returning the newly updated variable
My bad.


Re: GetPlayerHealth - Phanto90 - 03.09.2011

SetPlayerHealth set player's health not the Health[0] value!

So you should have done:
Код:
new Float:Health[2];
GetPlayerHealth(playerid,Health[0]);
Health[0] -= 5.0;
SetPlayerHealth(playerid,Health[0]);
GetPlayerHealth(playerid,Health[1]);
printf("Old:%f New:%f",Health[0],Health[1]);



Re: GetPlayerHealth - =WoR=Varth - 03.09.2011

Quote:
Originally Posted by Phanto90
Посмотреть сообщение
SetPlayerHealth set player's health not the Health[0] value!

So you should have done:
Код:
new Float:Health[2];
GetPlayerHealth(playerid,Health[0]);
Health[0] -= 5.0;
SetPlayerHealth(playerid,Health[0]);
GetPlayerHealth(playerid,Health[1]);
printf("Old:%f New:%f",Health[0],Health[1]);
Nothing wrong with my code. And I don't get what you mean.
I know how to solve it already.