Raised This Month: $ Target: $400
 0% 

Logging player problem?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 07-28-2010 , 23:33   Re: Logging player problem?
Reply With Quote #1

Still not working after trying with trie's :/

Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <celltrie>

#define PLUGIN "logging"
#define VERSION "1.0"
#define AUTHOR "Server Owner"

new Trie:gSteamIDTrie
new gszFile[64]
public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_dictionary("steamids.txt")
    register_logevent("round_start", 2, "1=Round_Start")
}

public round_start()
{
    new info[36]
    new players[32], player, num
    new authid[32], name[32]
    gSteamIDTrie=TrieCreate()
    get_localinfo( "amxx_configsdir", gszFile, 63 )
    copy( gszFile, charsmax(gszFile), "/logs.txt" )
    new file=fopen( gszFile, "rt" )
    while( !feof(file) )
    {
        fgets( file, info, charsmax(info) )
        trim(info)
        TrieSetCell(gSteamIDTrie, info, 1)
    }
    fclose(file)
    get_players(players, num)
    for( new i; i<num; i++ )
    {
        player=players[i]
        get_user_authid( player, authid, charsmax(authid) )
        get_user_name( player, name, 31 )
        if( !TrieKeyExists( gSteamIDTrie, authid ) )
        {
            write_file( gszFile, name )
            write_file( gszFile, authid )
            client_print(0, print_chat, %L, "LOGGED_NAME", name)
        }
        
    }
}
Any ideas?
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-29-2010 , 02:17   Re: Logging player problem?
Reply With Quote #2

If all you are doing is trying to log the player then I would recommend doing it on client_putinserver().

I would start with Bugsy's example and just modify it to add your SteamID to the list and write to the file (as shown in the AddID() function). Don't do anything with names yet. Get it working then you can add or modify from there.

As far as your most recent code, you need to put quotes around the %L to get it to compile. Again, you need to start simple. Don't do any multilingual stuff until you have the rest of the code working as it should.
__________________
fysiks is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 07-29-2010 , 22:57   Re: Logging player problem?
Reply With Quote #3

Got it working without the lang file . Thanks for the help fysiks.
Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <celltrie>

#define PLUGIN "logging"
#define VERSION "1.0"
#define AUTHOR "Server Owner"

new Trie:gSteamIDTrie
new gszFile[64]
public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_logevent("round_start", 2, "1=Round_Start")
}

public round_start()
{
    new info[36]
    new players[32], player, num
    new authid[32], name[32]
    gSteamIDTrie=TrieCreate()
    get_localinfo( "amxx_configsdir", gszFile, 63 )
    new const text[64]="Server Player Log File"
    new const logs[64]="addons/amxmodx/configs/logs.txt"
    if(!file_exists(logs))
    write_file(logs, text)
    
    new file=fopen( logs, "rt" )
    while( !feof(file) )
    {
        fgets( file, info, charsmax(info) )
        trim(info)
        TrieSetCell(gSteamIDTrie, info, 1)
    }
    fclose(file)
    get_players(players, num)
    for( new i; i<num; i++ )
    {
        player=players[i]
        get_user_authid( player, authid, charsmax(authid) )
        get_user_name( player, name, 31 )
        if( !TrieKeyExists( gSteamIDTrie, authid ) )
        {
            write_file( logs, name )
            write_file( logs, authid )
            client_print(0, print_chat, "%s has never played in this server before, please welcome him!", name)
        }
        
    }
}

Last edited by nikhilgupta345; 07-29-2010 at 23:04.
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-29-2010 , 23:18   Re: Logging player problem?
Reply With Quote #4

FYI, if you listen to me and use Bugsy's code as a template it would be much much much more optimized. Reading a file several times and looping through players on NewRound is something you do not need to do at all.
__________________
fysiks is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 07-29-2010 , 23:32   Re: Logging player problem?
Reply With Quote #5

Yea, I realize that, gonna fix that now :/
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
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:13.


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