Raised This Month: $32 Target: $400
 8% 

SteamID check with File Problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
atomen
Veteran Member
Join Date: Oct 2006
Location: Stockholm, Sweden
Old 06-11-2008 , 12:07   SteamID check with File Problem
Reply With Quote #1

Hi, I've been testing file system with checking
peoples steam ids. I got a function so I don't
have to include all the messy code in the main code.

The problem is that with this script the function
is only reading the first line in the "people.ini" file.

The first line is a BOT steamid, the second line
is holding my steamid. The rest is just miscellaneous steamid's.

I've tried without the function by having it in the
main script but I receive same results there.

As you can see I'm using old file system but
I've tried with each of the systems.

Smart old system, old system, new system.
Well, everything gets f****d.

Here's the script :
Code:
#include <amxmodx> #include <amxmisc> #pragma semicolon 1 #define DEBUG_MODE enum {     PARSED,     ACTIVE }; new filename[256]; new amx_vips; public plugin_init() {     register_plugin("Testing", "1.0", "[A]tomen");     register_concmd("amx_hi", "hi_func", -1, "Say hi to the people");     get_configsdir(filename, 255);     format(filename, 255, "%s/people.ini", filename);     amx_vips    =    register_cvar("amx_vip", "1"); } public hi_func(id) {
    if(check_steamid(id) == 1) //Notice that I check if it returns the value '1'
        server_cmd("say Hello there");     return 1; }
public check_steamid(id) //Function to check the ids authority's.
{     if(get_pcvar_num(amx_vips))     {         if(file_exists(filename))         {             new readdata[128], txtlen;             new steamid[2][33];             new fsize = file_size(filename, 1);             for(new line = 0; line <= fsize; line++)             {                 read_file(filename, line, readdata, 127, txtlen);                 parse(readdata, steamid[PARSED], 32);                 get_user_authid(id, steamid[ACTIVE], 32);                 #if defined DEBUG_MODE                  log_amx("!!!!!! PARSED : %s !!!!!! STEAMID : %s !!!!!! END", steamid[PARSED], steamid[ACTIVE]);                 #endif
                if(!equal(steamid[ACTIVE], steamid[PARSED])) //Only the first line in the file is checked.
                {                     #if defined DEBUG_MODE                      client_print(id, print_chat, "[AMXX] SteamID's wasn't Equal ! SteamID : [%s] | Parsed : [%s]", steamid[ACTIVE], steamid[PARSED]);                      log_amx("[AMXX] SteamID's wasn't Equal ! SteamID : [%s] | Parsed : [%s]", steamid[ACTIVE], steamid[PARSED]);                     #endif
                    return -1; //Notice the return results
                }                 else                 {                     #if defined DEBUG_MODE                      client_print(id, print_chat, "[AMXX] SteamID's was Equal ! SteamID : [%s] | Parsed : [%s]", steamid[ACTIVE], steamid[PARSED]);                      log_amx("[AMXX] SteamID's was Equal ! SteamID : [%s] | Parsed : [%s]", steamid[ACTIVE], steamid[PARSED]);                     #endif
                    return 1; //Notice the return results
                }             }         }         else if(!file_exists(filename))         {             #if defined DEBUG_MODE              log_amx("File [%s] is not Created !", filename);             #endif             server_print("File [%s] is not Created !", filename);             client_print(id, print_chat, "File [%s] is not Created !", filename);         }     }
    return 0; //Notice the return results
}
__________________

Last edited by atomen; 06-11-2008 at 14:06.
atomen is offline
Send a message via MSN to atomen
Lee
AlliedModders Donor
Join Date: Feb 2006
Old 06-11-2008 , 13:12   Re: SteamID check with File Problem
Reply With Quote #2

http://forums.alliedmods.net/showthread.php?t=46218

What's with the deliberately misleading named constants?
__________________
No support via PM.

Last edited by Lee; 06-11-2008 at 13:17.
Lee is offline
atomen
Veteran Member
Join Date: Oct 2006
Location: Stockholm, Sweden
Old 06-11-2008 , 13:24   Re: SteamID check with File Problem
Reply With Quote #3

What do you mean by intentional misleading named constants ?
__________________
atomen is offline
Send a message via MSN to atomen
Lee
AlliedModders Donor
Join Date: Feb 2006
Old 06-11-2008 , 13:39   Re: SteamID check with File Problem
Reply With Quote #4

You used MAX_PLAYERS as the maximum length of a few strings.

So.. did my link solve your problem or not?
__________________
No support via PM.

Last edited by Lee; 06-11-2008 at 13:42.
Lee is offline
Old 06-11-2008, 13:49
atomen
This message has been deleted by atomen.
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 06-11-2008 , 14:28   Re: SteamID check with File Problem
Reply With Quote #5

Both file system works fine, and new one is cool, easy...i prefer to save data for plugins in file instead of [n]vault/sql/mysql...but anyway,don't return -1 or 1 after first check because your loop will be ended after first check so only the first line is compared. When the line is finded with specified steamid then return 1 else make continue.

Something like:

Code:
public check_steamid(id) //Function to check the ids authority's. {  if(get_pcvar_num(amx_vips))  {   if(file_exists(filename))   {    new readdata[128], txtlen;    new steamid[2][33];        new fsize = file_size(filename, 1);    for(new line = 0; line <= fsize; line++)    {     read_file(filename, line, readdata, 127, txtlen);         parse(readdata, steamid[PARSED], 32);     get_user_authid(id, steamid[ACTIVE], 32);         #if defined DEBUG_MODE     log_amx("!!!!!! PARSED : %s !!!!!! STEAMID : %s !!!!!! END", steamid[PARSED], steamid[ACTIVE]);     #endif         if(!equal(steamid[ACTIVE], steamid[PARSED])) //Only the first line in the file is checked.                    {      #if defined DEBUG_MODE      client_print(id, print_chat, "[AMXX] SteamID's wasn't Equal ! SteamID : [%s] | Parsed : [%s]", steamid[ACTIVE], steamid[PARSED]);      log_amx("[AMXX] SteamID's wasn't Equal ! SteamID : [%s] | Parsed : [%s]", steamid[ACTIVE], steamid[PARSED]);      #endif            continue;                  }     else     {      #if defined DEBUG_MODE      client_print(id, print_chat, "[AMXX] SteamID's was Equal ! SteamID : [%s] | Parsed : [%s]", steamid[ACTIVE], steamid[PARSED]);      log_amx("[AMXX] SteamID's was Equal ! SteamID : [%s] | Parsed : [%s]", steamid[ACTIVE], steamid[PARSED]);      #endif            return 1;                  }    }   }     else if(!file_exists(filename))   {    #if defined DEBUG_MODE    log_amx("File [%s] is not Created !", filename);    #endif        server_print("File [%s] is not Created !", filename);    client_print(id, print_chat, "File [%s] is not Created !", filename);   }  }  return 0; }
__________________
Still...lovin' . Connor noob! Hello

Last edited by Alka; 06-11-2008 at 14:33.
Alka is offline
atomen
Veteran Member
Join Date: Oct 2006
Location: Stockholm, Sweden
Old 06-11-2008 , 14:37   Re: SteamID check with File Problem
Reply With Quote #6

So when it doesn't find any match it returns 0 ?
__________________
atomen is offline
Send a message via MSN to atomen
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 06-11-2008 , 14:38   Re: SteamID check with File Problem
Reply With Quote #7

Yes.
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
atomen
Veteran Member
Join Date: Oct 2006
Location: Stockholm, Sweden
Old 06-11-2008 , 15:28   Re: SteamID check with File Problem
Reply With Quote #8

Thanks Alka, worked like a charm
__________________
atomen is offline
Send a message via MSN to atomen
Reply


Thread Tools
Display Modes

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 10:14.


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