Health & Armour problem
#1

Im making a stats thing with dialogs,
This is my code:

pawn Код:
new Float:health;
new Float:armour;
GetPlayerHealth(playerid, health);
GetPlayerHealth(playerid, armour);
format(string, sizeof(string), "Health: %f \nArmour: %f", health, armour);
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Player Stats", string, "Ok", "Cancel");
And on the dialog it dosent show as 100, It shows as 100.000000, Or something like that, How do i just make it to 100?
Reply
#2

pawn Код:
new Float:health;
new Float:armour;
GetPlayerHealth(playerid, health);
GetPlayerHealth(playerid, armour);
format(string, sizeof(string), "Health: %d \nArmour: %d", health, armour);
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Player Stats", string, "Ok", "Cancel");
Like that?
Reply
#3

Quote:
Originally Posted by wiki.sa-mp.com
Format Strings
Placeholder Meaning
%b Inserts a number at this position in binary radix
%c Inserts a single character.
%d Inserts an integer (WHOLE) number (That will mean the .000000's too :P)
%f Inserts a floating point number.
%i Inserts an integer.
%s Inserts a string.
%x Inserts a number in hexadecimal notation.
%% Inserts the literal '%'
Reply
#4

pawn Код:
new Float:health;
new Float:armour;
GetPlayerHealth(playerid, health);
GetPlayerArmour(playerid, armour);
format(string, sizeof(string), "Health: %d \nArmour: %d", floatround(health), floatround(armour));
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Player Stats", string, "Ok", "Cancel");
^^
Reply
#5

Reply
#6

Quote:
Originally Posted by Fedee!
Use quotes so we see whos message you facepalmed, i dont wanna get facepalmed :P
Reply
#7

Quote:
Originally Posted by [NWA
Hannes ]
Quote:
Originally Posted by Fedee!
Use quotes so we see whos message you facepalmed, i dont wanna get facepalmed :P
Yea, sure
Reply
#8

Whoever keeps saying to use %d there wrong..
That makes it even worse...
Reply
#9

https://sampwiki.blast.hk/wiki/Floatround

new Float:health;
new Float:armour;
GetPlayerHealth(playerid, floatround(health, floatround_round));
GetPlayerHealth(playerid, floatround(armour, floatround_round));
format(string, sizeof(string), "Health: %i \nArmour: %i", health, armour);
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Player Stats", string, "Ok", "Cancel");

Might work, not sure I don't really script XD.

or could be

new Float:health;
new Float:armour;
GetPlayerHealth(playerid, health);
GetPlayerHealth(playerid, armour);
format(string, sizeof(string), "Health: %i \nArmour: %i", floatround(health, floatround_round), floatround(armour, floatround_round);
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Player Stats", string, "Ok", "Cancel");
Reply
#10

Atleast tell me what to do :P
Reply
#11

I edited my post, tell me if it works, haven't tested it and as I said I have only just started learning how to script.
Reply
#12

pawn Код:
format(string, sizeof(string), "Health: %.00f \nArmour: %.00f", health, armour);
Reply
#13

Will try that, Will edit post when tested
Worked ty
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)