Raised This Month: $ Target: $400
 0% 

Read File...


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 05-16-2013 , 23:30   Read File...
Reply With Quote #1

is this the correct way to read file select random line then show motd from that random line?

in the cfg file the lines are
file name motd header name
"motd1.txt" "MOTD NAME 1"

Code:
new configsdir[200];     new configfile[200];     get_configsdir( configsdir, charsmax( configsdir ) );     format( configfile, charsmax( configsdir ), "%s/motds/motds.cfg", configsdir);         new size = file_size( configfile, 1 ); //Get the number of lines the file has     new random = random_num( 0, size ); //Get any line between 0 and the number of line     new trash; //Useless     new text[256]; //Where the line will be kept     if( file_exists( configfile ) ) read_file( configfile, random, text, charsmax( text ), trash);     else {         log_amx( "%s File Was Not Found", configfile );         return;     }         new Left[ 64 ], Right[ 64 ];     //strbreak( text, Left, charsmax( Left ), Right, charsmax( Right ) );     strbreak( text, Left, 63, Right, 63 );         remove_quotes( Left );     remove_quotes( Right );         new Motd[ 64 ];     format( Motd, charsmax( Motd ), "%s/motds/%s", configsdir, Left );     show_motd( id, Motd, Right );     return;
__________________
Blizzard_87 is offline
 



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 16:25.


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