22.01.2018, 17:52
Quote:
Код:
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; } |
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(string, sizeof(string), "Taksi: %s", taksiConnected);
format(string2, sizeof(string2), "Mechanikai: %s", mechanikaiConnected);
format(string3, sizeof(string3), "Policija: %s", policijaConnected);
format(string4, sizeof(string4), "Narko: %s", narkoConnected);
format(string5, sizeof(string5), "Medikai: %s", medikaiConnected);
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(playerid, 202, DIALOG_STYLE_LIST,"Kviesti tarnyba", "Taksi [%s]\nMedikai [%s]\nPolicija [%s]\nMechanikai [%s]\nNarkotiku prekeiviai [%s]", string, "Pasirinkti", "Atsaukti");
I would try the following code:
PHP код:
new ResultString[170];
format(ResultString, sizeof(ResultString), "Taksi [%s]\nMedikai [%s]\nPolicija [%s]\nMechanikai [%s]\nNarkotiku prekeiviai [%s]", string, string5, string3, string2, string4);
//then show the dialog:
ShowPlayerDialog(playerid, 202, DIALOG_STYLE_LIST, "TITLE HERE", ResultString, "Pasirinkti", "Atsaukti");