Raised This Month: $138 Target: $400
 34% 

File Read Help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Acid Pilz
New Member
Join Date: Oct 2008
Old 10-02-2008 , 16:25   File Read Help
Reply With Quote #1

i need to know can i read a lines from file and get a line count from a file

Last edited by Acid Pilz; 10-02-2008 at 16:32.
Acid Pilz is offline
Acid Pilz
New Member
Join Date: Oct 2008
Old 10-02-2008 , 16:32   Re: File Read Help
Reply With Quote #2

can me anyboy help?
__________________
Acid Pilz is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 10-02-2008 , 17:10   Re: File Read Help
Reply With Quote #3

PHP Code:
decl String:buffer[1];
new 
Handle:file OpenFile("mapcycle.txt""r");
new 
count 0;

while (
ReadFileLine(filebuffersizeof(buffer)))
    
count++;

PrintToChatAll("There %s %i %s in mapcycle.txt", (count == 1)?"is":"are"count, (count == 1)?"line":"lines"); 
Now obviously you don't have to be as anal as I was with the text formatting, but you should get the general idea.
bl4nk is offline
Acid Pilz
New Member
Join Date: Oct 2008
Old 10-02-2008 , 22:55   Re: File Read Help
Reply With Quote #4

ít dont work
__________________
Acid Pilz is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 10-02-2008 , 23:06   Re: File Read Help
Reply With Quote #5

What doesn't work about it?

[edit]

Testing it out, hold on for a fix.

Last edited by bl4nk; 10-02-2008 at 23:25.
bl4nk is offline
Acid Pilz
New Member
Join Date: Oct 2008
Old 10-02-2008 , 23:26   Re: File Read Help
Reply With Quote #6

i want to compile it but its says me it have 6 errors
__________________
Acid Pilz is offline
bl4nk
SourceMod Developer
Join Date: Jul 2007
Old 10-02-2008 , 23:39   Re: File Read Help
Reply With Quote #7

Old code deleted.

[edit]

PHP Code:
decl String:buffer[64];
new 
countHandle:file OpenFile("mapcycle.txt""r");

while (!
IsEndOfFile(file))
{
    if (!
ReadFileLine(filebuffersizeof(buffer)))
        break;
    else
        
count++;
}

PrintToServer("There %s %i %s in mapcycle.txt", (count == 1)?"is":"are"count, (count == 1)?"line":"lines");

CloseHandle(file); 
Here's how to properly do it.

Last edited by bl4nk; 10-02-2008 at 23:57.
bl4nk is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:40.


Powered by vBulletin®
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Theme made by Freecode