can someone add comma's here for me?
#8

Quote:
Originally Posted by SetPlayerNameTag
Посмотреть сообщение
Try create a stock, and using switch to format it if the money is over 1m

for ex: format(string, sizeof(string), "%s", FormatMoney(BizInfo[idx][bValue]));

credits goes to Mariciuc223
Код HTML:
stock FormatMoney(Number)
{
	new str[16];
	format(str, 16, "$%i", Number);
	new l = strlen(str);

	if(Number < 0)
	{
	  	if (l > 5) strins(str, ".", l-3);
		if (l > 8) strins(str, ".", l-6);
		if (l > 11) strins(str, ".", l-9);
	}
	else
	{
		if (l > 4) strins(str, ".", l-3);
		if (l > 7) strins(str, ".", l-6);
		if (l > 10) strins(str, ".", l-9);
	}

	return str;
}
This is such a naive approach and it can be written way shorter: https://sampwiki.blast.hk/wiki/AddThousa...ors#Definition

Also the integer limit (for 32 bit signed integers as used by SA-MP) is 2.1 billion and something. It's impossible to store values larger than that.
Reply


Messages In This Thread
COMMAS in BUSINESS PRICE +REP - by BadJih - 08.09.2017, 15:22
Re: can someone add comma's here for me? - by SetPlayerNameTag - 08.09.2017, 15:25
Re: can someone add comma's here for me? - by BadJih - 08.09.2017, 15:37
Re: can someone add comma's here for me? - by SetPlayerNameTag - 08.09.2017, 15:39
Re: can someone add comma's here for me? - by thegamer355 - 08.09.2017, 15:41
Re: can someone add comma's here for me? - by BadJih - 08.09.2017, 15:45
Re: can someone add comma's here for me? - by BadJih - 08.09.2017, 16:08
Re: can someone add comma's here for me? - by Vince - 08.09.2017, 16:49

Forum Jump:


Users browsing this thread: 1 Guest(s)