Problem with my code[Textdraw]
#1

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

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

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

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

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?
Reply
#6

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

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);
?
Reply
#8

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

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)