View Single Post
pr0mers
Junior Member
Join Date: May 2020
Old 08-16-2021 , 16:23   Re: Reading and displaying information from a file
Reply With Quote #2

Quote:
Originally Posted by Hennesy View Post
Hi everyone.

Who can help, need to read configs / rules.txt file

And display in the chat every line that is in the file
Code:
new String:g_sFilePath[PLATFORM_MAX_PATH];
BuildPath(Path_SM, g_sFilePath, sizeof(g_sFilePath), "configs/rules.txt"); // this is the csgo/addons/sourcemod/configs/rules.txt
new Handle:fileHandle = OpenFile( g_sFilePath, "r" );
new String:fileLine[256];
while( !IsEndOfFile( fileHandle ) && ReadFileLine( fileHandle, fileLine, sizeof( fileLine ) ) )
{
     TrimString( fileLine );
     PrintToChatAll(fileLine);
}
CloseHandle( fileHandle );
should do the trick
__________________
My Steam
My Youtube Channel
My Github
My Discord : pr0mers#0369
-I always write unnecessary plugins-
(you can tell me better ways to do something, thank you)

Last edited by pr0mers; 08-16-2021 at 16:53. Reason: added config/rules.txt
pr0mers is offline