need help with fread. - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: need help with fread. (
/showthread.php?tid=177368)
need help with fread. -
titanak - 17.09.2010
Thanks For Everyone Who Helped ! got work this now
Re: need help with fread. -
Hiddos - 17.09.2010
You'll need to use "while":
pawn Код:
while(fread(example, string))
{
new string235[256];
format(string235, 256, "%s\r\n", string);
//Other code
}
fclose(example);
Re: need help with fread. -
titanak - 17.09.2010
pawn Код:
if(strcmp(cmd, "/chatlog", true) == 0) {
new string[64]; // Create the string to store the read text in
new File:example = fopen("text.txt", io_read); // Open the file
fread(example, string); // Fread from the file and store what's read in 'string'
while(fread(example, string))
{
new string235[256];
format(string235,sizeof string235,"%s\r\n",string);
ShowPlayerDialog(playerid,8329,DIALOG_STYLE_LIST,"Text",string235,"Okei","Cancel");
}
fclose(example);
return 1;
}
something like that ?
Re: need help with fread. -
Hiddos - 17.09.2010
I guess so.. I'm not fully functional in fread ^^. Oh and: Show the dialog AFTER the "while {....}" loop has been done, else it'll most probably bug up.
Re: need help with fread. -
titanak - 17.09.2010
thanks working but i want to add whole text history to the Dialog but now it shows the last one writed text.
atm code
pawn Код:
if(strcmp(cmd, "/chatlog", true) == 0) {
new string[64]; // Create the string to store the read text in
new File:example = fopen("text.txt", io_read); // Open the file
fread(example, string); // Fread from the file and store what's read in 'string'
new string235[256];
while(fread(example, string))
{
format(string235,sizeof string235,"%s\r\n",string);
}
ShowPlayerDialog(playerid,8329,DIALOG_STYLE_LIST,"Chat Logs",string235,"Okei","Cancel");
fclose(example);
return 1;
}
Re: need help with fread. -
titanak - 18.09.2010
have tryd much times to fix this but i cant understand what i have to do to get whole text from text.txt to dialog
Re: need help with fread. -
MadeMan - 18.09.2010
pawn Код:
if(strcmp(cmd, "/chatlog", true) == 0)
{
new string[128];
new string235[512];
new File:example = fopen("text.txt", io_read);
while(fread(example, string))
{
strcat(string235, string, sizeof(string235));
}
fclose(example);
ShowPlayerDialog(playerid,8329,DIALOG_STYLE_LIST,"Chat Logs",string235,"Okei","Cancel");
return 1;
}
Re: need help with fread. -
titanak - 19.09.2010
thanks got fixed now the problem