Raised This Month: $ Target: $400
 0% 

Reading from a file


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 02-05-2007 , 05:17   Re: Reading from a file
Reply With Quote #1

Quote:
Originally Posted by Paladinrocker View Post
By the way, where do I place that .txt file? Do I place it in the main mod directory, or do I place it elsewhere? I'm right in the middle of testing so I don't know if making an integer helped it.
In amxx configsdir.
.ini, not .txt.
The plugin creates it for you.

Code:
#include <amxmodx> #include <amxmisc> new steamfile[128] public plugin_init() {     register_plugin("Read SteamID","1.0","")         get_configsdir(steamfile, 127)     new len = strlen(steamfile)         formatex(steamfile[len], 127-len, "/steamids.ini")         if ( ! file_exists(steamfile) ) {         write_file(steamfile,"");         } } public client_putinserver(id) {     if ( valid_steamid(id) )         set_hudmessage(255, 0, 0, 0.0, 0.13, 0, 2.0, 12.0);     else         set_hudmessage(0, 255, 0, 0.0, 0.13, 0, 2.0, 12.0);         new pName[32], pAuth[20]         get_user_authid(id, pAuth, 19)     get_user_name(id, pName, 31)         new players[32], pNum     get_players(players, pNum, "c")     for ( new i ; i < pNum ; i++ )         show_hudmessage(players[i], "%s (%s) connected", pName, pAuth); } public valid_steamid(id) {     new file = fopen(steamfile,"r")         if ( ! file )         return 0         new mAuth[20], pAuth[20]     get_user_authid(id, pAuth, 19) // We don't want to get this every loop.         if ( ! pAuth[0] )         return 0;         while ( ! feof(file) ) {                 fgets(file, mAuth, 19);         new len = strlen(pAuth);                 if ( equal(pAuth, mAuth, len) ) {             fclose(file)             return 1; // We don't want to keep reading if we found it.         }     }     fclose(file)     return 0; }
Code:
parse(read,steamid,32)
Aaah, my eyes are burning!

Last edited by [ --<-@ ] Black Rose; 02-05-2007 at 15:45.
[ --<-@ ] 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