View Single Post
DruGzOG
Veteran Member
Join Date: Nov 2007
Location: Unknown
Old 08-15-2019 , 17:17   Re: Visitor Counter v1.3
Reply With Quote #19

Quote:
Originally Posted by Alber9091 View Post
Well I think that's .php script & you are displaying the data on your web by providing ftp information in your .php script. If still its SQL, then, .php script would be much better for such simple outputs, since they are easy to setup & understand than SQL.
PHP Code:
#include < amxmodx >
#include < sqlx >

#define TABLE_NAME "player_info"

/* Database */
new Host[] = "hostname"
new User[]  =  "user"
new Pass[] =  "pass"
new Db[] =  "databasename"

new MySQL_Query512 ]
new 
Handle:MySQL_Tuple
new Handle:MySQL_Connection

public plugin_init( ) {
    
register_plugin"PlayerInfo""v1""???" )
}

public 
client_putinserverid )
{
    
MySQL_Load(id);
}

public 
plugin_precache( )
{
    
MySQL_Tuple SQL_MakeDbTupleHostUserPassDb )
    
#if AMXX_VERSION_NUM >= 183
        
SQL_SetCharset(MySQL_Tuple,"utf8");
    
#endif
    
    
new ErrorCode
    MySQL_Connection 
SQL_ConnectMySQL_TupleErrorCodeMySQL_QuerycharsmaxMySQL_Query ) )
    
    if( 
MySQL_Connection == Empty_Handle )
        
set_fail_stateMySQL_Query )
    
formatexMySQL_QuerycharsmaxMySQL_Query ), "CREATE TABLE IF NOT EXISTS %s (id int NOT NULL AUTO_INCREMENT, username VARCHAR(128), steam_id VARCHAR(20), ip_adress VARCHAR(15), date DATE, time TIME, primary key (id) )"TABLE_NAME )

    
SQL_ThreadQueryMySQL_Tuple"SQL_TrashHandler"MySQL_Query )  
}

public 
MySQL_Loadid 
{
    new 
szAuth[32]; 
    
get_user_authid(idszAuth31);
    
    new 
Temp]
    
Temp] = id
    
    formatex
MySQL_QuerycharsmaxMySQL_Query ), "SELECT `steam_id` FROM %s WHERE `steam_id` = '%s'"TABLE_NAMEszAuth )
    
SQL_ThreadQueryMySQL_Tuple"Load_PlayerInfo"MySQL_QueryTempsizeofTemp ) )
}
                                                                                
public 
Load_PlayerInfoFailStateHandle:QueryError[ ], ErrcodeData[ ], DataSize 
{
    if( 
FailState == TQUERY_CONNECT_FAILED ) { return PLUGIN_HANDLED; }            
    else if( 
FailState == TQUERY_QUERY_FAILED ) { return PLUGIN_HANDLED; }

    new 
id Data]
    
    if( !
is_user_connectedid ) )
        return 
PLUGIN_HANDLED;
        
    new 
szAuth[32], szName[32], szIP[23], currentTime[9], currentDate[11]; 
    
get_user_authid(idszAuth31);
    
get_user_name(idszName31);
    
get_user_ip(idszIP221);
    
get_time("%H:%M:%S"currentTime8
    
get_time("%Y/%m/%d"currentDate10)

    if( 
SQL_NumResultsQuery ) < 
    {
        
formatexMySQL_QuerycharsmaxMySQL_Query ), "INSERT INTO %s (`username`, `steam_id`, `ip_adress`, `date`, `time`) VALUES ('%s', '%s', '%s', '%s', '%s')"TABLE_NAMEszNameszAuthszIPcurrentDatecurrentTime )
        
SQL_ThreadQueryMySQL_Tuple"SQL_TrashHandler"MySQL_Query )
    }
    else {
        
formatexMySQL_QuerycharsmaxMySQL_Query ), "UPDATE %s SET `date` = '%s', `time` = '%s' WHERE `steam_id` = '%s'"TABLE_NAMEcurrentDatecurrentTimeszAuth  )
        
SQL_ThreadQueryMySQL_Tuple"SQL_TrashHandler"MySQL_Query )
    }
    return 
PLUGIN_CONTINUE;
}

public 
SQL_TrashHandlerFailState,Handle:QueryError[ ], Errcode,Data[ ], DataSize )  

    if( 
FailState == TQUERY_CONNECT_FAILED )
        return 
PLUGIN_HANDLED;
        
    else if( 
FailState == TQUERY_QUERY_FAILED )
        return 
PLUGIN_HANDLED;
    
    
SQL_FreeHandleQuery )
    return 
PLUGIN_CONTINUE;
}

public 
plugin_end( ) 
{   
    
SQL_FreeHandleMySQL_Connection )

SQLx, and using that info, pulling data using a php script. I believe either Bugsy or someone else scripted this, don't recall.
__________________
DruGzOG is offline
Send a message via AIM to DruGzOG