string in txt
#1

Hey, im making string for bank money, so i want that string is full, and as u can see, i want if player have have 1250 then in text draw will be 00001250, but i dont know how to insert string in that text where is novac = "0000%d";
and then instead of %d write my money and then in the end of it be: 0000mymoney
i think u understand me

Код:
new MoneyString[50], novac[50];
if(PlayerInfo[playerid][pBanka] >= 1) novac = "000000%d";
if(PlayerInfo[playerid][pBanka] >= 10) novac = "00000%d";
if(PlayerInfo[playerid][pBanka] >= 100) novac = "0000%d";
if(PlayerInfo[playerid][pBanka] >= 1000) novac = "0000%d";
if(PlayerInfo[playerid][pBanka] >= 10000) novac = "000%d";
if(PlayerInfo[playerid][pBanka] >= 100000) novac = "00%d";
if(PlayerInfo[playerid][pBanka] >= 1000000) novac = "0%d";
if(PlayerInfo[playerid][pBanka] >= 10000000) novac = "%d";
format(MoneyString,sizeof(MoneyString), "$%s", novac);
TextDrawSetString(TDMoney, MoneyString);
TextDrawShowForPlayer(playerid, TDMoney);
Reply
#2

pawn Код:
new MoneyString[10];
format(MoneyString,sizeof(MoneyString), "$%08d", PlayerInfo[playerid][pBanka]);
TextDrawSetString(TDMoney, MoneyString);
TextDrawShowForPlayer(playerid, TDMoney);
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
pawn Код:
new MoneyString[10];
format(MoneyString,sizeof(MoneyString), "$%08d", PlayerInfo[playerid][pBanka]);
TextDrawSetString(TDMoney, MoneyString);
TextDrawShowForPlayer(playerid, TDMoney);
i have 16912 in my bank but it shows $00000000

maybe problem in this? :

Код:
	TDMoney = TextDrawCreate(498.000000, 96.000000, "$00000000");
	TextDrawBackgroundColor(TDMoney, 255);
	TextDrawFont(TDMoney, 3);
	TextDrawLetterSize(TDMoney, 0.589999, 2.200000);
	TextDrawColor(TDMoney, 4491519);
	TextDrawSetOutline(TDMoney, 1);
	TextDrawSetProportional(TDMoney, 1);
	TextDrawSetShadow(TDMoney, 0);
Reply
#4

Are you sure PlayerInfo[playerid][pBanka] is 16912? Debug it:
pawn Код:
printf("PlayerInfo[playerid][pBanka] is %d", PlayerInfo[playerid][pBanka]); // It will print to the console
new MoneyString[10];
format(MoneyString,sizeof(MoneyString), "$%08d", PlayerInfo[playerid][pBanka]);
TextDrawSetString(TDMoney, MoneyString);
TextDrawShowForPlayer(playerid, TDMoney);
And tell us what it printed to the screen and to the console/server log.

I don't see any other problem, it should work since you change the text using TextDrawSetString.
Reply
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Are you sure PlayerInfo[playerid][pBanka] is 16912? Debug it:
pawn Код:
printf("PlayerInfo[playerid][pBanka] is %d", PlayerInfo[playerid][pBanka]); // It will print to the console
new MoneyString[10];
format(MoneyString,sizeof(MoneyString), "$%08d", PlayerInfo[playerid][pBanka]);
TextDrawSetString(TDMoney, MoneyString);
TextDrawShowForPlayer(playerid, TDMoney);
And tell us what it printed to the screen and to the console/server log.

I don't see any other problem, it should work since you change the text using TextDrawSetString.
sorry, my fault, i set it in onplayerconnect, but i set player's money onplayerspawn, thanks, its working
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)