string in txt - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: string in txt (
/showthread.php?tid=469719)
string in txt -
xyzcod2 - 14.10.2013
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);
Re: string in txt -
Konstantinos - 14.10.2013
pawn Код:
new MoneyString[10];
format(MoneyString,sizeof(MoneyString), "$%08d", PlayerInfo[playerid][pBanka]);
TextDrawSetString(TDMoney, MoneyString);
TextDrawShowForPlayer(playerid, TDMoney);
Re: string in txt -
xyzcod2 - 14.10.2013
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);
Re: string in txt -
Konstantinos - 14.10.2013
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.
Re: string in txt -
xyzcod2 - 14.10.2013
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