SA-MP Forums Archive
Health Stats freaking out. - 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)
+--- Thread: Health Stats freaking out. (/showthread.php?tid=312881)



Health Stats freaking out. - milanosie - 23.01.2012

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;
}



Re: Health Stats freaking out. - Vince - 23.01.2012

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


Re: Health Stats freaking out. - T0pAz - 23.01.2012

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.




Re: Health Stats freaking out. - [ABK]Antonio - 23.01.2012

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


Re: Health Stats freaking out. - milanosie - 23.01.2012

ok thanks