SA-MP Forums Archive
String in a dialog - 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 a dialog (/showthread.php?tid=369933)



String in a dialog - Shredmaster - 18.08.2012

Hi.
I have a few questions.

1. How to put a new line in: format(string... ?

For example:
format(string,sizeof(string), "ID: %i Level: %i", id, level);

I want it to print:
ID: 10
Level: 3

I tried \n and \r but nothing worked...


2. How to put string in dialog (messagebox style).



Let's say I wan't to print:
ID: 10
Level: 3

inside a dialog.


Re: String in a dialog - THE_KING$5$ - 18.08.2012

See this then you can understand Example:
Код:
 	new string[318];
	format(string,sizeof(string),"Example Number :%i",Example);
	ShowPlayerDialog(playerid,Example,DIALOG_STYLE_MSGBOX,"Example",string,"Nice","Huh?");
use the string in showplayerdialog.


Re: String in a dialog - Dan. - 18.08.2012

String size 318.. lol. Anyways, you can use string in dialogs like this:

pawn Код:
new string[128];
format(string, sizeof string, "ID: 10\nLevel: 3");
ShowPlayerDialog(playerid, 1000, DIALOG_STYLE_MSGBOX, "Stats", string, "Ok", "Cancel");
The \n splits it.

E:// The_King, your code wont work because dialogid cant be "example", it has to be an integer.


Re: String in a dialog - THE_KING$5$ - 18.08.2012

Quote:

String size 318.. lol. Anyways, you can use string in dialogs like this:

pawn Code:
new string[128];
format(string, sizeof string, "ID: 10\nLevel: 3");
ShowPlayerDialog(playerid, 1000, DIALOG_STYLE_MSGBOX, "Stats", string, "Ok", "Cancel");

The \n splits it.

:O i was In Hurry. hehehe


Re: String in a dialog - Shredmaster - 18.08.2012

Thanks, that was helpful.

But what about new line in string?

If I put like this:
format(string,sizeof(string), "ID: %i \nLevel: %i", id, level);
SendClientMessage(playerid, -1, string);

It writes this:
ID: 6 Level: 20

I want level in new line... :/


Re: String in a dialog - THE_KING$5$ - 18.08.2012

Quote:

Thanks, that was helpful.

But what about new line in string?

If I put like this:
format(string,sizeof(string), "ID: %i \nLevel: %i", id, level);
SendClientMessage(playerid, -1, string);

It writes this:
ID: 6 Level: 20

I want level in new line... :/

You are useing SendClientmessage and SendClientMessage Cant split 2 lines by using \n you have to use

format(string,sizeof(string),"ID: %i",id);
format(string2,sizeof(string2),"Level: %i",Level);
SendClientMessage(playerid, -1, string);
SendClientMessage(playerid, -1, string2);


Re: String in a dialog - milanosie - 18.08.2012

Quote:
Originally Posted by THE_KING$5$
Посмотреть сообщение
You are useing SendClientmessage and SendClientMessage Cant split 2 lines by using \n you have to use

format(string,sizeof(string),"ID: %i",id);
format(string2,sizeof(string2),"Level: %i",Level);
SendClientMessage(playerid, -1, string);
SendClientMessage(playerid, -1, string2);
or even easyer and more efficient

pawn Код:
new string[64];
format(string,sizeof(string),"ID: %i",id);
SendClientMessage(playerid, -1, string);
format(string,sizeof(string),"Level: %i",Level);
SendClientMessage(playerid, -1, string);
No need to create two different strings


Re: String in a dialog - Dan. - 18.08.2012

You cant use that in SendClientMessage, and THE_KING, why to use 2 strings when you can use one?

pawn Код:
format(string, sizeof string, "ID: %i",id);
SendClientMessage(playerid, -1, string);
format(string, sizeof string, "Level: %i", Level);
SendClientMessage(playerid, -1, string);



Respuesta: String in a dialog - HydraX - 18.08.2012

When making a dialog, Splitting a string when you have variables will not work and will only show the last string made.


Re: String in a dialog - Shredmaster - 19.08.2012

Thanks everybody. You helped me a lot.

Quote:
Originally Posted by Dan.
Посмотреть сообщение
You cant use that in SendClientMessage, and THE_KING, why to use 2 strings when you can use one?

pawn Код:
format(string, sizeof string, "ID: %i",id);
SendClientMessage(playerid, -1, string);
format(string, sizeof string, "Level: %i", Level);
SendClientMessage(playerid, -1, string);
I really didn't know you can do that. Thanks.