Raised This Month: $ Target: $400
 0% 

How to read file


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
RuleBreaker
Senior Member
Join Date: May 2011
Old 10-01-2011 , 13:32   How to read file
Reply With Quote #1

I'm making new plugin that has something like log file, how can I make command amx_checklogs that will read that file and print everything from it in console?
RuleBreaker is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-01-2011 , 13:39   Re: How to read file
Reply With Quote #2

Use read_file, its the easiest.

http://www.amxmodx.org/funcwiki.php?go=func&id=87
__________________
Bugsy is online now
RuleBreaker
Senior Member
Join Date: May 2011
Old 10-01-2011 , 14:28   Re: How to read file
Reply With Quote #3

Ok, but how to print in in console?
I tried this but it doesn`t work
new szLine[ 32 ] , iLen;
read_file( "log.ini" , 0 , szLine , charsmax( szLine ) , iLen );
client_print(id, print_console, "%s", szLine)

*Log.ini file is in config folder
RuleBreaker is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-01-2011 , 14:40   Re: How to read file
Reply With Quote #4

console_print

http://www.amxmodx.org/funcwiki.php?go=func&id=601
__________________
Bugsy is online now
Swisa
Senior Member
Join Date: Nov 2010
Location: Israel
Old 10-01-2011 , 16:58   Re: How to read file
Reply With Quote #5

how to print in the file/.?
Swisa is offline
Send a message via Skype™ to Swisa
Old 10-01-2011, 17:15
RuleBreaker
This message has been deleted by RuleBreaker. Reason: Mistake
RuleBreaker
Senior Member
Join Date: May 2011
Old 10-02-2011 , 12:21   Re: How to read file
Reply With Quote #6

I tried everything and it still doesn`t work, could anyone give me exaple?


*Log.ini file is in config folder
RuleBreaker is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 10-02-2011 , 13:02   Re: How to read file
Reply With Quote #7

Show your full code so we can see what's wrong with it.
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
RuleBreaker
Senior Member
Join Date: May 2011
Old 10-02-2011 , 13:56   Re: How to read file
Reply With Quote #8

Quote:
new szDirectory[ 128 ];
get_configsdir( szDirectory, charsmax( szDirectory ) );

add( szDirectory, charsmax( szDirectory ), "\log.ini" );

new szLine[ 128 ], iLen;
read_file( szDirectory, 0, szLine, charsmax( szLine ), iLen );
console_print( 0, szLine );
But it prints only first line
RuleBreaker is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-02-2011 , 14:10   Re: How to read file
Reply With Quote #9

size = file_size( "file" , 1 )

for ( new i = 0 ; i < size ; i++ )

Pass i as second param in read file
__________________
Bugsy is online now
RuleBreaker
Senior Member
Join Date: May 2011
Old 10-02-2011 , 14:18   Re: How to read file
Reply With Quote #10

Like this:

Quote:
new size = file_size( "file" , 1 )

for ( new i = 0 ; i < size ; i++ )
{
new szDirectory[ 128 ];
get_configsdir( szDirectory, charsmax( szDirectory ) );
add( szDirectory, charsmax( szDirectory ), "/log.ini" );
new szLine[ 128 ], iLen;
read_file( szDirectory, i, szLine, charsmax( szLine ), iLen );
console_print(id, "%s", szLine );
}
}
it doesn`t work :\
RuleBreaker is offline
Reply



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 19:42.


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