Need help this this /hptest - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Need help this this /hptest (
/showthread.php?tid=64774)
Need help this this /hptest -
Celson - 07.02.2009
I'm working on a command for admins called /hptest. Once typed it will send a client message saying "Current HP: 100" then minus hp by 2, then wait 1 second, then "New Hp: 98"
Although it doesn't do that, it does this
Current HP: 100
(Waits one second)
New Hp: 100
But then I check my hp and it says I have 98, and my health bar had gone down but it thought my hp was 100.
Код:
if(IsPlayerConnected(pid))
{
new Float:Health;
new Float:Health2;
GetPlayerHealth(pid,Health);
format(message,128,"Current HP: %f",Health);
SendClientMessage(playerid,COLOR_YELLOW,message);
SetPlayerHealth(pid,Health-2);
wait(1000);
GetPlayerHealth(pid,Health2);
format(message2,128,"New HP: %f",Health2);
SendClientMessage(playerid,COLOR_YELLOW,message2);
return 1;
}
Any ideas of why it's not working?
Re: Need help this this /hptest -
luby - 07.02.2009
Try to use SetTimer.
Or try to use SetPlayerHealth after wait(1000);.
Re: Need help this this /hptest -
Celson - 07.02.2009
Quote:
Originally Posted by Luby
Try to use SetTimer.
Or try to use SetPlayerHealth after wait(1000);.
|
Tried putting the SetHealth after the wait but had no luck, still the same problem. And a settimer is the last thing I'll do.
But thanks anyway
Re: Need help this this /hptest -
Celson - 08.02.2009
Comon does anybody have any suggestions, or does anybody know how I could do it with a timer?
Re: Need help this this /hptest -
luby - 08.02.2009
Quote:
Originally Posted by Celson
Comon does anybody have any suggestions, or does anybody know how I could do it with a timer?
|
You can use wait func.
try to make it like this :
Код:
if(IsPlayerConnected(pid))
{
new Float:Health;
new Float:Health2;
GetPlayerHealth(pid,Health);
format(message,128,"Current HP: %f",Health);
SendClientMessage(playerid,COLOR_YELLOW,message);
SetPlayerHealth(pid,Health-2);
if(wait(1000)){
GetPlayerHealth(pid,Health2);
format(message2,128,"New HP: %f",Health2);
SendClientMessage(playerid,COLOR_YELLOW,message2);
}
return 1;
}
Re: Need help this this /hptest -
Extremo - 08.02.2009
Just a little note, if i am right, this will freeze your script for a whole second which can obvisiously fuck up alot. I would really suggest you to use SetTimer.