GetPlayerHealth
#1

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.
Reply
#2

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
Reply
#3

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.
Reply
#4

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]);
Reply
#5

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)