Quote:
Originally Posted by Liverwiz
Code:
while( !feof(fh) && !found )
Code:
found = ( equal( auth , line , strlen( auth ) ) )
Just a few suggestions to keep the code lines down...might actually make it faster. In fact, i'm pretty sure it will make it faster.
|
No it won't. Actually makes it slower.
@OP
Code:
( auth[ ] ) // What is auth[ ] ? Why they are this param ?
It is the auth string for the user. Could be a name, SteamID, or IP.
Code:
new ConfigsDir[ 64 ] , line[ 46 ]; // Why an array with 64 and one with 46 ? Why the name of the variable is ConfigsDir ?
64 is for a path size.
46 is the maximum length an auth key can have in the users.ini (see admin.sma)
ConfigsDir is named that way because... it is the location of the configs directory (addons/amxmodx/configs)
Code:
get_localinfo( "amxx_configsdir" , ConfigsDir , charsmax( ConfigsDir ) );
/*
I reade it : <a href="http://www.amxmodx.org/funcwiki.php?search=get_localinfo&go=search" target="_blank" rel="nofollow noopener">http://www.amxmodx.org/funcwiki.php?...info&go=search</a>
but i do not understand the objective of that. If someone can help me ^^
*/
It gets the location of addons/amxmodx/configs and stores it in a string.
It is used to avoid hard-coding the string to be that path.
Code:
format( ConfigsDir , charsmax( ConfigsDir ) , "%s/vip.ini" , ConfigsDir );
// It is the location of my .ini filesi think its only that ?
It locates the file in the configs directory and completes the whole path to the file:
addons/amxmodx/configs/vip.ini
Code:
new fh; // why the name is fh ?
fh would mean file handle.
Code:
fh = fopen( ConfigsDir , "r" );
/*
I reade it : <a href="http://www.amxmodx.org/funcwiki.php?go=func&id=92" target="_blank" rel="nofollow noopener">http://www.amxmodx.org/funcwiki.php?go=func&id=92</a>
But why it is a r and not a w ?
*/
r = read
w = write
This function looks inside a file for a string, so obviously you'll be reading, not writing.
Code:
if( fh ) // If fh = ? what ? I do not understand this variable
It checks if the file handle is valid and that the file is opened.
Code:
break; // why they are a break; ?
Code:
// Why they are no break; ?
It only stops looping (break) if the string was found in the file.
Code:
return found; // Why not return 0; ?
Because it returns whether or not it found it in the file.
__________________