AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to read file (https://forums.alliedmods.net/showthread.php?t=168609)

RuleBreaker 10-01-2011 13:32

How to read file
 
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?

Bugsy 10-01-2011 13:39

Re: How to read file
 
Use read_file, its the easiest.

http://www.amxmodx.org/funcwiki.php?go=func&id=87

RuleBreaker 10-01-2011 14:28

Re: How to read file
 
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

Bugsy 10-01-2011 14:40

Re: How to read file
 
console_print

http://www.amxmodx.org/funcwiki.php?go=func&id=601

Swisa 10-01-2011 16:58

Re: How to read file
 
how to print in the file/.?

RuleBreaker 10-02-2011 12:21

Re: How to read file
 
I tried everything and it still doesn`t work, could anyone give me exaple?


*Log.ini file is in config folder

nikhilgupta345 10-02-2011 13:02

Re: How to read file
 
Show your full code so we can see what's wrong with it.

RuleBreaker 10-02-2011 13:56

Re: How to read file
 
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 :|

Bugsy 10-02-2011 14:10

Re: How to read file
 
size = file_size( "file" , 1 )

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

Pass i as second param in read file

RuleBreaker 10-02-2011 14:18

Re: How to read file
 
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 :\


All times are GMT -4. The time now is 19:42.

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