Raised This Month: $ Target: $400
 0% 

[ Solved ] is_user_in_file


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-22-2012 , 15:36  
Reply With Quote #3

Quote:
Originally Posted by Liverwiz View Post
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.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 06-22-2012 at 15:37.
Exolent[jNr] 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 06:10.


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