Please help me with this format
#1

Hello,

I am trying to print this values into a dialog like this;
pawn Код:
format(strings,sizeof(strings), "CrazyCock\t%d\nPizzaStack\t%d\nCluckinBell\t%d",Companies[0][Sold],Companies[1][Sold],Companies[2][Sold]);
ShowPlayerDialog(playerid,BANK_DIALOGID,DIALOG_STYLE_LIST,"Company's sold or not",strings,"Buy","Exit");
This works great!
BUT... Right now the values from 'Companies' will show as 0 or 1.
i want the 0 to be shown as "For Sale" and the 1 to be shown as "Sold". I know that i need to use %s for that but i dont know how to format into a format.

Answers would be just awesome ...thanks in advance
Reply
#2

pawn Код:
format(strings, sizeof(strings),
"CrazyCock\t%s\nPizzaStack\t%s\nCluckinBell\t%s",
(Companies[0][Sold] == 0 ? ("For Sale") : ("Sold")),
(Companies[1][Sold] == 0 ? ("For Sale") : ("Sold")),
(Companies[2][Sold] == 0 ? ("For Sale") : ("Sold"))
);

ShowPlayerDialog(playerid,BANK_DIALOGID,DIALOG_STYLE_LIST,"Company's sold or not",strings,"Buy","Exit");
Reply
#3

Try this:
pawn Код:
format(strings,sizeof(strings), "CrazyCock\t%s\nPizzaStack\t%s\nCluckinBell\t%s", (Companies[0][Sold] == 0) ? ("For Sale") : ("Sold"), (Companies[1][Sold] == 0) ? ("For Sale") : ("Sold"), (Companies[2][Sold] == 0) ? ("For Sale") : ("Sold"));
ShowPlayerDialog(playerid,BANK_DIALOGID,DIALOG_STYLE_LIST,"Company's sold or not",strings,"Buy","Exit");
Reply
#4

For the looks of it (both of the answers), it seems logical but i get these errors;

pawn Код:
warning 215: expression has no effect
error 001: expected token: ";", but found ")"
error 029: invalid expression, assumed zero
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line

EDIT: NVM FIXED!!!

Thanks both of you
Reply
#5

I edited my post
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)