Float help (First attempt) -
-Rebel Son- - 27.04.2010
Ok so. first attempt with floats. Ive used floats only to get playerposition and that was it..
Now i'm really working with them. trying to make basic command to show my health and armour.
my command compiles, looks right. but ingame i type it. nothing happends..
Take a look.
Код:
if (strcmp("/orly", cmdtext, true, 10) == 0)
{
new string[256];
new Float:HP;
new Float:AP;
GetPlayerHealth(playerid, HP);
GetPlayerArmour(playerid, AP);
format(string, sizeof(string), "Health: %d Armour: %d", floatround(HP), floatround(AP));
return 1;
}
I thought i did everything right? but the message doesn't appear.
Re: Float help (First attempt) -
ettans - 27.04.2010
Although you format the string, you don't actually send it. Add SendClientMessage(playerid,0xffffff,string); before the return.
Re: Float help (First attempt) -
-Rebel Son- - 27.04.2010
I just realised that.. *facepalm*
Re: Float help (First attempt) -
cessil - 27.04.2010
%f are floats %d are whole numbers
Re: Float help (First attempt) -
Calgon - 27.04.2010
Quote:
Originally Posted by cessil
%f are floats %d are whole numbers
|
He's rounding them up and in to integers, yet he's still going about it in the wrong way.
https://sampwiki.blast.hk/wiki/Floatround
You're missing the method.
Re: Float help (First attempt) -
aircombat - 27.04.2010
use this , tested and working :
Код:
if (strcmp("/orly", cmdtext, true, 10) == 0)
{
new string[256];
new Float:HP;
new Float:AP;
GetPlayerHealth(playerid, HP);
GetPlayerArmour(playerid, AP);
format(string, sizeof(string), "Health: %f Armour: %f", HP, AP);
SendClientMessage(playerid,0x33AAFFFF,string);
return 1;
}
Re: Float help (First attempt) -
Hiddos - 27.04.2010
Another note: For text strings use a size of [128], since it's the maximum string size to type or to show in a single chat message.
Re: Float help (First attempt) -
Correlli - 27.04.2010
You don't even need 128 cells.
pawn Код:
if(!strcmp(cmdtext, "/orly", true))
{
new
string[24], Float:var[2];
GetPlayerHealth(playerid, var[0]);
GetPlayerArmour(playerid, var[1]);
format(string, sizeof(string), "Health:%i, armor:%i", floatround(var[0]), floatround(var[1]));
SendClientMessage(playerid, 0xFFFFFFFF, string);
return true;
}
Re: Float help (First attempt) -
-Rebel Son- - 27.04.2010
Thanks guys, i understand floats now. I spent a good two hours messin around with them. and last night around 4AM i create a nice STAT Bar for my DM server build. Hold health armour cash score and currentgunID and ammo. I Apriciate the help!