26.10.2009, 20:30
Hey,
I'm trying to create a money textdraw, I want it like the one built in to GTA.
To do this, if the players amount of money is only 2 digits (For example 25) I need to add another 8(?) digits of zeroes in front, this is what I had, but this fails, pretty bad.
If anyone can show me a better way of doing this I would really appreciate it.
I'm trying to create a money textdraw, I want it like the one built in to GTA.
To do this, if the players amount of money is only 2 digits (For example 25) I need to add another 8(?) digits of zeroes in front, this is what I had, but this fails, pretty bad.
pawn Код:
stock GivePlayerMoneyEx(playerid, money)
{
new mstring[56];
PlayerInfo[playerid][Money] += money;
if(PlayerInfo[playerid][Money] <= 10000000000)
{
format(mstring, sizeof(mstring), "$%i", PlayerInfo[playerid][Money]);
}
if(PlayerInfo[playerid][Money] <= 1000000000)
{
format(mstring,sizeof(mstring), "$0%i", PlayerInfo[playerid][Money]);
}
if(PlayerInfo[playerid][Money] <= 100000000)
{
format(mstring,sizeof(mstring), "$00%i", PlayerInfo[playerid][Money]);
}
if(PlayerInfo[playerid][Money] <= 10000000)
{
format(mstring,sizeof(mstring), "$000%i", PlayerInfo[playerid][Money]);
}
if(PlayerInfo[playerid][Money] <= 1000000)
{
format(mstring,sizeof(mstring), "$0000%i", PlayerInfo[playerid][Money]);
}
if(PlayerInfo[playerid][Money] <= 100000)
{
format(mstring,sizeof(mstring), "$00000%i", PlayerInfo[playerid][Money]);
}
if(PlayerInfo[playerid][Money] <= 10000)
{
format(mstring,sizeof(mstring), "$000000%i", PlayerInfo[playerid][Money]);
}
if(PlayerInfo[playerid][Money] <= 1000)
{
format(mstring,sizeof(mstring), "$0000000%i", PlayerInfo[playerid][Money]);
}
if(PlayerInfo[playerid][Money] <= 100)
{
format(mstring,sizeof(mstring), "$00000000%i", PlayerInfo[playerid][Money]);
}
if(PlayerInfo[playerid][Money] <= 10)
{
format(mstring,sizeof(mstring), "$000000000%i", PlayerInfo[playerid][Money]);
}
TextDrawSetString(Moneybar, mstring);
return 1;
}