-
Sziasztok!
Van egy parancsom, ami egy fájlt nyit meg dialogba. Ezzel az a problémám, hogy csak az első sort jeleníti meg. Mi lehet a hiba?
CMD:varoslog(playerid, params[])
{
if(pInfo[playerid][pAdmin] >= 1 || pInfo[playerid][pOnkTag] == 1 && pInfo[playerid][pOnkRang] >= 4)
{
new string[1000]; // Create the string to store the read text in
new File:example = fopen(\"VAROS.log\", io_read); // Open the file
fread(example, string); // Fread from the file and store what\'s read in \'string\'
fclose(example); // Close the file
ShowPlayerDialog(playerid,51,DIALOG_STYLE_LIST,\"A város tevékenységei:\",string,\"Rendben\",\"\");
}
else
{
SendClientMessage(playerid, PIROS, \"Nem vagy 1* Admin/Polgármester!\");
}
return 1;
}
-
DIALOG_STYLE_LIST lesz a baja. Oda soronként kell beírni a szöveget, pontosabban tagolni kell \' \\n \'-el.
Pl.:
ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, \"Cím\",
\"Első sor\\nMásodik sor\\nHarmadik sor\\n\", \"Gomb1\", \"Gomb2\");
Ha DIALOG_STYLE_MSGBOX-ba írod, akkor elvileg az kezeli a sortörést, tehát kitudja írni a teljes szöveget.
-
Sajnos így is csak az első sort írja le.
-
Bocsi, hülye voltam. MSGBOX-ba is kell a \' \\n \'.
De akkor próbáljunk egy kis trükköt belevinni:
CMD:varoslog(playerid, params[])
{
if(pInfo[playerid][pAdmin] >= 1 || pInfo[playerid][pOnkTag] == 1 && pInfo[playerid][pOnkRang] >= 4)
{
new string[1000], line[100]; // A string-be mentjük a teljes tartalmat és line-ba pedig az aktuális sort
new File:example = fopen(\"VAROS.log\", io_read); // Open the file
while(fread(example, line)) // Beolvassuk a fájlt soronként, hogy majd egymáshoz fűzzük őket
{
format(string, sizeof(string), \"%s\\n%s\", string, line);
}
fclose(example); // Close the file
ShowPlayerDialog(playerid, 51, DIALOG_STYLE_LIST, \"A város tevékenységei:\", string, \"Rendben\", \"\");
}
else SendClientMessage(playerid, PIROS, \"Nem vagy 1* Admin/Polgármester!\");
return 1;
}
-
Mostmár tökéletes. Köszi szépen! ;D