After formatting string it won't print string out - 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: After formatting string it won't print string out (
/showthread.php?tid=448321)
After formatting string it won't print string out -
Typhome - 03.07.2013
Fixed. Thanks to Nero_3D.
Re: After formatting string it won't print string out -
iPoisonxL - 03.07.2013
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.
AW: After formatting string it won't print string out -
Nero_3D - 04.07.2013
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");
Re: After formatting string it won't print string out -
Typhome - 04.07.2013
Nero_3D, thanks! Just this "Contact
[]" fixed this problem.