SA-MP Forums Archive
Health & Armour problem - 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: Health & Armour problem (/showthread.php?tid=129632)



Health & Armour problem - Torran - 22.02.2010

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?


Re: Health & Armour problem - Fedee! - 22.02.2010

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?


Re: Health & Armour problem - bajskorv123 - 22.02.2010

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 '%'



Re: Health & Armour problem - CJ101 - 22.02.2010

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");
^^


Re: Health & Armour problem - Fedee! - 22.02.2010




Re: Health & Armour problem - bajskorv123 - 22.02.2010

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


Re: Health & Armour problem - Fedee! - 22.02.2010

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


Re: Health & Armour problem - Torran - 22.02.2010

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


Re: Health & Armour problem - gotenks918 - 22.02.2010

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");


Re: Health & Armour problem - Torran - 22.02.2010

Atleast tell me what to do :P


Re: Health & Armour problem - gotenks918 - 22.02.2010

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.


Re: Health & Armour problem - Joe Staff - 23.02.2010

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



Re: Health & Armour problem - Torran - 23.02.2010

Will try that, Will edit post when tested
Worked ty