PDA

View Full Version : Commas


JesusChrysler
29/07/2015, 08:28 PM
Could anyone tell me how to make it so it's $10,000 instead of $10000 or $7,500 instead of $7500? Like I wan't commas put into the numbers.
http://i58.tinypic.com/28b87xx.png

format(string, sizeof(string), "Money: $%d | Bank: $%d", PlayerInfo[playerid][pMoney], PlayerInfo[playerid][pBank]);
SendClientMessage(playerid, COLOR_WHITE, string);

Sjn
29/07/2015, 08:34 PM
https://wiki.sa-mp.com/wiki/AddCommas

Moudix
29/07/2015, 08:36 PM
https://wiki.sa-mp.com/wiki/AddCommas
Edit : someone was faster than me.

JesusChrysler
29/07/2015, 08:49 PM
Okay. How would I do that in my situation?

I tried doing this:
AddCommas(PlayerInfo[playerid][pMoney]);

But it didn't work.

Dan.
29/07/2015, 09:01 PM
How are you using it? Give some more code.

JesusChrysler
29/07/2015, 09:04 PM
How are you using it? Give some more code.

I'm using it in /stats.

AddCommas(PlayerInfo[playerid][pMoney]);

format(string, sizeof(string), "Money: $%d | Bank: $%d", PlayerInfo[playerid][pMoney], PlayerInfo[playerid][pBank]);
SendClientMessage(playerid, COLOR_WHITE, string);

Dan.
29/07/2015, 09:06 PM
It's not working for you because you are still showing the value of it, you should use it like this:

format(string, sizeof(string), "Money: $%s | Bank: $%d", AddCommas(PlayerInfo[playerid][pMoney]), PlayerInfo[playerid][pBank]);
SendClientMessage(playerid, COLOR_WHITE, string);

JesusChrysler
29/07/2015, 09:10 PM
It's not working for you because you are still showing the value of it, you should use it like this:

format(string, sizeof(string), "Money: $%s | Bank: $%d", AddCommas(PlayerInfo[playerid][pMoney]), PlayerInfo[playerid][pBank]);
SendClientMessage(playerid, COLOR_WHITE, string);

Okay. Thank you.