String on DIALOG_STYLE_LIST
#8

Quote:
Originally Posted by Ritzy
Посмотреть сообщение
Код:
if (strcmp("/kviesti", cmdtext, true, 8) == 0)
	{
		new string[125];
		format(string, sizeof(string), "Taksi: %s", taksiConnected);
		format(string, sizeof(string), "Mechanikai: %s", mechanikaiConnected);
		format(string, sizeof(string), "Policija: %s", policijaConnected);
		format(string, sizeof(string), "Narko: %s", narkoConnected);
		format(string, sizeof(string), "Medikai: %s", medikaiConnected);
		
		ShowPlayerDialog(playerid, 202, DIALOG_STYLE_LIST, string , "Pasirinkti", "Atsaukti");
		return 1;
	}
Your cell size for string was too small. Also, The way you wrote it, it doesn't work like that. You added an extra arguement in ShowPlayerDialog function. The previous words which were in your dialog is supposed to be written in formatted function itself.
I guess you were asleep when you did this code.

Have a close look, what happens to the string, every time you format it? Yes, you overwrite it.


To the thread starter:
Look at the code. You tell the code to "format" a variable called "string". Imagine that string is a box with information. When you do "format(string, sizeof(string), "....", "..."); - you always place new information into it.

You can either use many different string variables and save it to them like this:
PHP код:
new string[30], string2[30]; //This defines a new Array. it also explains [30]: it will be 29 characters long. (not 30)
//do the same for all the variables you need. Variables without [] is normal vars. They can contain a value, such as a number.
format(stringsizeof(string), "Taksi: %s"taksiConnected);
format(string2sizeof(string2), "Mechanikai: %s"mechanikaiConnected);
format(string3sizeof(string3), "Policija: %s"policijaConnected);
format(string4sizeof(string4), "Narko: %s"narkoConnected);
format(string5sizeof(string5), "Medikai: %s"medikaiConnected); 
Then you have saved information to 5 different arrays, right? (They are actually called Arrays, not boxes, remember that)

OR you can use a function called "strcat" in order to place text to the end of an already formatted string.


Let's continue:

PHP код:
ShowPlayerDialog(playerid202DIALOG_STYLE_LIST,"Kviesti tarnyba""Taksi [%s]\nMedikai [%s]\nPolicija [%s]\nMechanikai [%s]\nNarkotiku prekeiviai [%s]"string"Pasirinkti""Atsaukti"); 
This is not right either, because what you do here - should be done in a "format". Only format understands %s and %d (of course with some exceptions).

I would try the following code:
PHP код:
new ResultString[170];
format(ResultStringsizeof(ResultString), "Taksi [%s]\nMedikai [%s]\nPolicija [%s]\nMechanikai [%s]\nNarkotiku prekeiviai [%s]"stringstring5string3string2string4);
//then show the dialog:
ShowPlayerDialog(playerid202DIALOG_STYLE_LIST"TITLE HERE"ResultString"Pasirinkti""Atsaukti"); 
Reply


Messages In This Thread
String on DIALOG_STYLE_LIST - by LI0LIKAS - 22.01.2018, 16:51
Re: String on DIALOG_STYLE_LIST - by Ritzy2K - 22.01.2018, 16:56
Re: String on DIALOG_STYLE_LIST - by LI0LIKAS - 22.01.2018, 17:11
Re: String on DIALOG_STYLE_LIST - by Ritzy2K - 22.01.2018, 17:13
Re: String on DIALOG_STYLE_LIST - by Stev - 22.01.2018, 17:32
Re: String on DIALOG_STYLE_LIST - by LI0LIKAS - 22.01.2018, 17:36
Re: String on DIALOG_STYLE_LIST - by Kane - 22.01.2018, 17:42
Re: String on DIALOG_STYLE_LIST - by denNorske - 22.01.2018, 17:52
Re: String on DIALOG_STYLE_LIST - by LI0LIKAS - 22.01.2018, 18:08
Re: String on DIALOG_STYLE_LIST - by denNorske - 22.01.2018, 20:30

Forum Jump:


Users browsing this thread: 6 Guest(s)