Raised This Month: $ Target: $400
 0% 

Reading from a .txt file...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PvtSmithFSSF
Senior Member
Join Date: Jul 2008
Old 07-26-2008 , 22:49   Reading from a .txt file...
Reply With Quote #1

Hey there! New scripter here learning a ton of new things.
What I'm trying to do is create a plugin that displays random messages from a txt file. How do I read lines from a .txt file? I need some1 to please give me some noob-friendly advice if it's possible ;)
Thanks!
PvtSmithFSSF is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-26-2008 , 22:54   Re: Reading from a .txt file...
Reply With Quote #2

Wrong section. Moved to scripting help.

Code:
new filename[64]; // this is the name of your file to read from copy(filename, 63, "motd.txt"); // lets use motd.txt for the example if( file_exists(filename) ) {     new file = fopen(filename, "rt");         new data[64]; // information taken from the file, 1 line at a time     while( !feof(file) ) // keep looping until we find the end of the file     {         fgets(file, data, 63); // retrieve information         // Note: it will automatically go to the next line                 // data contains the information from the line read     }         // close file     fclose(file); }

Use the funcwiki for information about the natives.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
PvtSmithFSSF
Senior Member
Join Date: Jul 2008
Old 07-26-2008 , 22:57   Re: Reading from a .txt file...
Reply With Quote #3

thank you very much!
btw i meant to post it here in scripting help sorry.
PvtSmithFSSF 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 05:37.


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