After formatting string it won't print string out
#1

Fixed. Thanks to Nero_3D.
Reply
#2

You can't use printf(); to print text in game, use SendClientMessage(playerid, text); or read up and learn about more methods of sending text.
Reply
#3

Its not printf, the problem is that your code crashes due to an array out of bounds error
Next time try the crashdetect plugin which would have told you

In both loops you do
pawn Code:
for(new i; i < sizeof(Contact); i++) // i < MAX_PLAYERS
But you actually wanted to do
pawn Code:
for(new i; i < sizeof(Contact[]); i++) // i < MAX_CONTACTS
So fixed it could look like
pawn Code:
//
    for(new i, text[32] = "None"; i < sizeof Contact[]; i++) {
        Contact[playerid][i][ContactName] = text;
        Contact[playerid][i][ContactNumber] = 0;
    }
pawn Code:
//
    new
        str[MAX_CONTACTS * 38] = "Lisa uus kontakt"
    ;
    for(new i; i < sizeof Contact[]; i++) {
        format(str, sizeof str, "%s\n%s (%d)", str, Contact[playerid][i][ContactName], Contact[playerid][i][ContactNumber]);
    }
    TELEFON_valik[playerid] = 10;
    ShowPlayerDialog(playerid, DIALOG_TELEFON, DIALOG_STYLE_LIST, "Telefon (Kontaktid)", str, "Vali", "Katkesta");
Reply
#4

Nero_3D, thanks! Just this "Contact[]" fixed this problem.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)