new mystring[10];
format(mystring,sizeof(mystring),"$%02d",pData[playerid][pCash]);
forward CheckMoney(playerid);
public CheckMoney(playerid)
{
new string[128];
if(GetPlayerMoney(playerid) < 10)
{
format(string, sizeof(string), "0000000%iFt", GetPlayerMoney(playerid));
TextDrawSetString(Ft[playerid], string);
TextDrawShowForPlayer(playerid, Ft[playerid]);
TextDrawShowForPlayer(playerid, Box[playerid]);
}
if(10 <= GetPlayerMoney(playerid) < 100)
{
format(string, sizeof(string), "000000%iFt", GetPlayerMoney(playerid));
TextDrawSetString(Ft[playerid], string);
TextDrawShowForPlayer(playerid, Ft[playerid]);
TextDrawShowForPlayer(playerid, Box[playerid]);
}
if(100 <= GetPlayerMoney(playerid) < 1000)
{
format(string, sizeof(string), "00000%iFt", GetPlayerMoney(playerid));
TextDrawSetString(Ft[playerid], string);
TextDrawShowForPlayer(playerid, Ft[playerid]);
TextDrawShowForPlayer(playerid, Box[playerid]);
}
if(1000 <= GetPlayerMoney(playerid) < 10000)
{
format(string, sizeof(string), "0000%iFt", GetPlayerMoney(playerid));
TextDrawSetString(Ft[playerid], string);
TextDrawShowForPlayer(playerid, Ft[playerid]);
TextDrawShowForPlayer(playerid, Box[playerid]);
}
if(10000 <= GetPlayerMoney(playerid) < 100000)
{
format(string, sizeof(string), "000%iFt", GetPlayerMoney(playerid));
TextDrawSetString(Ft[playerid], string);
TextDrawShowForPlayer(playerid, Ft[playerid]);
TextDrawShowForPlayer(playerid, Box[playerid]);
}
if(100000 <= GetPlayerMoney(playerid) < 1000000)
{
format(string, sizeof(string), "00%iFt", GetPlayerMoney(playerid));
TextDrawSetString(Ft[playerid], string);
TextDrawShowForPlayer(playerid, Ft[playerid]);
TextDrawShowForPlayer(playerid, Box[playerid]);
}
if(1000000 <= GetPlayerMoney(playerid) < 10000000)
{
format(string, sizeof(string), "0%iFt", GetPlayerMoney(playerid));
TextDrawSetString(Ft[playerid], string);
TextDrawShowForPlayer(playerid, Ft[playerid]);
TextDrawShowForPlayer(playerid, Box[playerid]);
}
if(10000000 <= GetPlayerMoney(playerid) < 999999999)
{
format(string, sizeof(string), "%iFt", GetPlayerMoney(playerid));
TextDrawSetString(Ft[playerid], string);
TextDrawShowForPlayer(playerid, Ft[playerid]);
TextDrawShowForPlayer(playerid, Box[playerid]);
}
return 1;
}
Just replace the 2 in "%02d" with whatever length you want it to be. What this means is: make sure the output is always 2 characters long. If it isn't, pad it with zeros.
|