SA-MP Forums Archive
Problem with my code[Textdraw] - 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: Problem with my code[Textdraw] (/showthread.php?tid=161048)



Problem with my code[Textdraw] - Jay. - 18.07.2010

Well, I've made a health: Thing thats ment to show your health but its not working..


heres my code

pawn Code:
new Float:health;
format(string, sizeof(string), "Health: %d", GetPlayerHealth(playerid, health));
Health = TextDrawCreate(473, 382, string);
I don't know whats wrong can anyone help?


Re: Problem with my code[Textdraw] - Stepashka - 18.07.2010

PHP Code:
new Float:health;
GetPlayerHealth(playeridhealth)
format(stringsizeof(string), "Health: %.0f",health);
Health TextDrawCreate(473382string); 



Re: Problem with my code[Textdraw] - Jay. - 18.07.2010

Quote:
Originally Posted by Stepashka
View Post
PHP Code:
new Float:health;
GetPlayerHealth(playeridhealth)
format(stringsizeof(string), "Health: %.0f",health);
Health TextDrawCreate(473382string); 

I thought i'll need to update it with a timer am i wrong?



And what does "0f" do?


EDIT: I get error



pawn Code:
C:\Users\(lewis)\Desktop\New Folder (11)\area51.pwn(192) : error 001: expected token: ";", but found "-identifier-"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.



Re: Problem with my code[Textdraw] - ReVo_ - 18.07.2010

LOL?
pawn Code:
new Float: Health, Text:Textdraw, string[128];
GetPlayerHealth(playerid, Health);
format(string, sizeof(string), "Health: %d", floatround(Health));
Textdraw = TextDrawCreate(473, 382, string);



Re: Problem with my code[Textdraw] - Virtual1ty - 18.07.2010

Well firstly, use floatround when you want to round the 'health' variable which is a float
Secondly, is 'Health' variable defined as
pawn Code:
new text:Health;
?

Also do you use TextDrawShowForPlayer anywhere?


Re: Problem with my code[Textdraw] - Jay. - 18.07.2010

Quote:
Originally Posted by Virtual1ty
View Post
Well firstly, use floatround when you want to round the 'health' variable which is a float
Secondly, is 'Health' variable defined as
pawn Code:
new text:Health;
?

Also do you use TextDrawShowForPlayer anywhere?

Yes i do use "TextDrawShowForPlayer".


Under OnPlayerSpawn


Re: Problem with my code[Textdraw] - Virtual1ty - 18.07.2010

Well then show the whole public function, also say does the textdraw even show?
Also, did you use TextDrawShowForPlayer this way :
pawn Code:
TextDrawShowForPlayer(playerid, Health);
?


Re: Problem with my code[Textdraw] - Jay. - 18.07.2010

Quote:
Originally Posted by Virtual1ty
View Post
Well then show the whole public function, also say does the textdraw even show?
Also, did you use TextDrawShowForPlayer this way :
pawn Code:
TextDrawShowForPlayer(playerid, Health);
?
Yes the Textdraw shows.

And yes i use that:

TextDrawShowForPlayer(playerid, Health);


Re: Problem with my code[Textdraw] - Virtual1ty - 18.07.2010

So the problem is the health in the textdraw box doesn't update?
Did you even setup a timer?


Re: Problem with my code[Textdraw] - Stepashka - 18.07.2010

Quote:
Originally Posted by [BADBOY]
View Post
And what does "0f" do?
% [Flags] [width] [. Precision] [size] type

format(string,sizeof(string),"%0*.*f",3,2,12.34567 );
explanation:
0 - add zeros to the desired width (character can be any) - in pawno to float is not working
* and note the number of 3 - width, to which the characters fill
* and note the number of 2 - many characters after the comma
result: 012.34

format(string,sizeof(string),"%3.2f",1234.567;
explanation:
the same thing only without the fill characters
result: 234.56

applies to the %d
!!! filled symbols for her work!
PHP Code:
new hour,minute,second,string[10];
gettime(hour,minute,second);
format(stringsizeof(string), "%02d:%02d:%02d"hourminute,second);
SendClientMessageToAll(0xFF0000FF,string); 
- alternatiny to write, without footnotes

for string: %.5s - number of displayed characters, not tested!

sorry for my english