Health Stats freaking out.
#1

Hello there, I made a simple /stats but for some reason it shows health as like "1937365763"... any idea why? it doesnt do that with armour

pawn Код:
CMD:stats(playerid, params[])
{
    new string[256], string2[128], string3[128], string4[128], string5[128], string6[128];
    new name[MAX_PLAYER_NAME];
    new Float:armour;
    new Float:phealth;
    GetPlayerName(playerid, name, sizeof(name));
    GetPlayerHealth(playerid, phealth);
    GetPlayerArmour(playerid, armour);
    format(string, sizeof(string), "||==================================|| %s ||==================================|| ", name);
    format(string2, sizeof(string2), "Money %d || Level %d || Phone %s || Admin Rank %d ",GetPlayerMoney(playerid), GetPlayerScore(playerid), PlayerInfo[playerid][PhoneNumber], PlayerInfo[playerid][AdminLevel] );
    format(string3, sizeof(string3), "Faction %d || Faction Rank %d || Job %d ", PlayerInfo[playerid][Fmember], PlayerInfo[playerid][Frank], PlayerInfo[playerid][pJob]);
    format(string4, sizeof(string4), "Warnings %d || Health %d || Armour %d ", PlayerInfo[playerid][Warns], phealth, armour );
    format(string5, sizeof(string5), "Interior %d || Virtual World %d || Skin %d ",GetPlayerInterior(playerid), GetPlayerVirtualWorld(playerid), GetPlayerSkin(playerid));
    format(string6, sizeof(string6), "Materials %d || Business %d", PlayerInfo[playerid][Materials], PlayerInfo[playerid][Biz]);
    SendClientMessage(playerid, COLOR_GREY, string);
    SendClientMessage(playerid, COLOR_GREEN, string2);
    SendClientMessage(playerid, COLOR_GREY, string3);
    SendClientMessage(playerid, COLOR_GREEN, string4);
    SendClientMessage(playerid, COLOR_GREY, string5);
    SendClientMessage(playerid, COLOR_GREEN, string6);
    return 1;
}
Reply
#2

Health and armor are both float values, so use the %f placeholder in your string.
Reply
#3

Health and Armor should be float as %f specifier.

Quote:

This forum requires that you wait 120 seconds between posts. Please try again in 55 seconds.

Reply
#4

pawn Код:
format(string4, sizeof(string4), "Warnings %d || Health %d || Armour %d ", PlayerInfo[playerid][Warns], floatround(phealth), floatround(armour) );
If you want to keep them a whole number
Reply
#5

ok thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)