Raised This Month: $ Target: $400
 0% 

Reading from a file


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 02-05-2007 , 15:25   Re: Reading from a file
Reply With Quote #1

Code:
    fgets(file, mAuth, 19);             if ( equal(pAuth, mAuth) ) {

fgets returns ^n if one is reached. So you need to do one of the two below.

Code:
    new len = strlen(pAuth); // Outside of loop     fgets(file, mAuth, 19);             if ( equal(pAuth, mAuth, len) ) {

or

Code:
    fgets(file, mAuth, 19);     new len = strlen(mAuth);     if (mAuth[len-1] == '^n')         mAuth[--len] = 0;     if ( equal(pAuth, mAuth) ) {
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 02-05-2007 , 15:44   Re: Reading from a file
Reply With Quote #2

Oh, right ^^ I forgot that.
[ --<-@ ] Black Rose is offline
Paladinrocker
Junior Member
Join Date: Jan 2007
Old 02-06-2007 , 08:15   Re: Reading from a file
Reply With Quote #3

Ok once again, thanks guys, I'll test it out definitely.
Paladinrocker is offline
Paladinrocker
Junior Member
Join Date: Jan 2007
Old 02-06-2007 , 08:41   Re: Reading from a file
Reply With Quote #4

WOO!! Haha, it works. Thanks guys. But, rose, isn't the code

if ( ! pAuth[0] )
return 0;

reduntant? All that's saying is if the player doesn't have an id (no players), then it won't check for your steam id, but it wouldn't make sense cause the function wouldn't run without a player in the first place. Oh well, thansk a lot guys.
Paladinrocker is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 02-06-2007 , 09:14   Re: Reading from a file
Reply With Quote #5

ooo if this subject is open..How i can reading from a ".ini" "names" and if that names are there Kick player with that name when connect and show "Change yor Name!" ?? Thanks...
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 02-06-2007 , 12:24   Re: Reading from a file
Reply With Quote #6

Quote:
Originally Posted by Paladinrocker View Post
WOO!! Haha, it works. Thanks guys. But, rose, isn't the code

if ( ! pAuth[0] )
return 0;

reduntant? All that's saying is if the player doesn't have an id (no players), then it won't check for your steam id, but it wouldn't make sense cause the function wouldn't run without a player in the first place. Oh well, thansk a lot guys.
There can be errors, resulting in steamid string is empty.

Quote:
Originally Posted by Alka View Post
ooo if this subject is open..How i can reading from a ".ini" "names" and if that names are there Kick player with that name when connect and show "Change yor Name!" ?? Thanks...
Code:
#include <amxmodx> #include <amxmisc> new namefile[128] public plugin_init() {     register_plugin("Read SteamID","1.0","")         get_configsdir(namefile, 127)     new len = strlen(namefile)         formatex(namefile[len], 127-len, "/names.ini")         if ( ! file_exists(namefile) ) {         write_file(namefile,"");         } } public client_putinserver(id) {     if ( is_name_in_file(id) )         server_cmd("kick #%d ^"Change Your Name!^"", get_user_userid(id)); } public is_name_in_file(id) {     new file = fopen(namefile,"r")         if ( ! file )         return 0         new mName[20], pName[20]     get_user_authid(id, pName, 19) // We don't want to get this every loop.         if ( ! pName[0] )         return 0;         while ( ! feof(file) ) {                 fgets(file, mName, 19);         new len = strlen(pName);                 if ( equal(pName, mName, len) ) {             fclose(file)             return 1; // We don't want to keep reading if we found it.         }     }     fclose(file)     return 0; }

Last edited by [ --<-@ ] Black Rose; 02-07-2007 at 06:01.
[ --<-@ ] Black Rose is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 02-06-2007 , 13:19   Re: Reading from a file
Reply With Quote #7

not working Thanks again Rose you help me...

PHP Code:
/home/groups/amxmodx/tmp3/phpe6e4qC.sma(9) : error 017undefined symbol "namefile"
/home/groups/amxmodx/tmp3/phpe6e4qC.sma(9) : warning 215expression has no effect
/home/groups/amxmodx/tmp3/phpe6e4qC.sma(9) : error 001expected token";"but found ")"
/home/groups/amxmodx/tmp3/phpe6e4qC.sma(9) : error 029invalid expressionassumed zero 
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
SweatyBanana
BANNED
Join Date: Sep 2005
Location: LOL
Old 02-06-2007 , 18:57   Re: Reading from a file
Reply With Quote #8

Change:

PHP Code:
new steamfile[128
to:

PHP Code:
new namefile[128
SweatyBanana is offline
Send a message via AIM to SweatyBanana Send a message via Yahoo to SweatyBanana
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 02-07-2007 , 04:26   Re: Reading from a file
Reply With Quote #9

Thanks...but still one error =>>
PHP Code:
error 017undefined symbol "is_name_in_file" 
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 02-07-2007 , 06:01   Re: Reading from a file
Reply With Quote #10

updated.
[ --<-@ ] Black Rose 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 00:44.


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