Raised This Month: $ Target: $400
 0% 

need a sql plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
vikasvishwakarma
Member
Join Date: Mar 2013
Old 11-25-2017 , 15:31   need a sql plugin
Reply With Quote #1

Need a plugin that can store players data in sql such as their ip address, steam id, Name, time and date.

i want to write a php script afterwards which will allow my community manager to track down the hackers in the server and ban them manually.

if anyone can create it for me please.
vikasvishwakarma is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 11-25-2017 , 16:01   Re: need a sql plugin
Reply With Quote #2

Why not just use log_to_file and log every player into a .txt/.log file?
__________________
edon1337 is offline
vikasvishwakarma
Member
Join Date: Mar 2013
Old 11-25-2017 , 16:49   Re: need a sql plugin
Reply With Quote #3

i cannot give the access of the vps to others thats why i am looking into plugin so that way once the data is saved in sql i can pull the data with php and display on the page which will be secured by user and pass
vikasvishwakarma is offline
Alber9091
Veteran Member
Join Date: Jun 2014
Location: Karachi, Pakistan
Old 11-25-2017 , 17:01   Re: need a sql plugin
Reply With Quote #4

Quote:
Originally Posted by vikasvishwakarma View Post
i cannot give the access of the vps to others thats why i am looking into plugin so that way once the data is saved in sql i can pull the data with php and display on the page which will be secured by user and pass
I guess Edon meant to print the .txt file on webpage.

It is possible. By making a simple webpage (in public_html or desired path) and adding server ftp info in it. It will print that .txt file from server to that web page.
Alber9091 is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 11-25-2017 , 17:04   Re: need a sql plugin
Reply With Quote #5

You have to find a PHP scripter.

@Alber9091 Not really what I meant, I'm not sure whether that is possible.
__________________
edon1337 is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 11-25-2017 , 17:12   Re: need a sql plugin
Reply With Quote #6

Quote:
Originally Posted by edon1337 View Post
You have to find a PHP scripter.

@Alber9091 Not really what I meant, I'm not sure whether that is possible.
It is, I've developed some stuff using FTP to connect to the server and retrieve files. Although it will never be better than MySQL, you don't need a database which is nice. However your game server has to also run a FTP server (this is common with Counter-Strike server providers as far as I know) and your host has to allow outgoing FTP requests from PHP, which not every host does.

It's totally alright for small files of fixed size, but with for example logs which OP wants the file will continuously grow which is bad and every other request will take more and more time to complete.

Last edited by klippy; 11-25-2017 at 17:13.
klippy is offline
vikasvishwakarma
Member
Join Date: Mar 2013
Old 11-25-2017 , 17:21   Re: need a sql plugin
Reply With Quote #7

if it can be done by ftp what is the process i have to do to get it working ?
vikasvishwakarma is offline
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 11-25-2017 , 19:23   Re: need a sql plugin
Reply With Quote #8

Try (make sure you added sql info)

PHP Code:
#include < amxmodx >
#include < sqlx >

#define TABLE_NAME "player_info"

/* Database */
new Host[] = "yourInfo"
new User[]  =  "yourInfo"
new Pass[] =  "yourInfo"
new Db[] =  "yourInfo"

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) NOT NULL, steam_id VARCHAR(20), ip_adress VARCHAR(15), date DATE, time TIME )" )

    
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 )

Time and date marks latest player's connection to server.

P.S. You should set collation for username to avoid random symbols unless you are using amx version lower than 1.8.3
__________________

Last edited by Airkish; 11-25-2017 at 19:25.
Airkish is offline
vikasvishwakarma
Member
Join Date: Mar 2013
Old 11-26-2017 , 05:15   Re: need a sql plugin
Reply With Quote #9

Quote:
Originally Posted by Airkish View Post
Try (make sure you added sql info)

PHP Code:
#include < amxmodx >
#include < sqlx >

#define TABLE_NAME "player_info"

/* Database */
new Host[] = "yourInfo"
new User[]  =  "yourInfo"
new Pass[] =  "yourInfo"
new Db[] =  "yourInfo"

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) NOT NULL, steam_id VARCHAR(20), ip_adress VARCHAR(15), date DATE, time TIME )" )

    
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 )

Time and date marks latest player's connection to server.

P.S. You should set collation for username to avoid random symbols unless you are using amx version lower than 1.8.3
thanks for the reply. i tried your code but it did not work for some reason.
i checked the phpmyadmin there was no table created in the DB.
i added the correct information in the sma file for the sql.
vikasvishwakarma is offline
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 11-26-2017 , 07:59   Re: need a sql plugin
Reply With Quote #10

Try now:

PHP Code:
#include < amxmodx >
#include < sqlx >

#define TABLE_NAME "player_info"

/* Database */
new Host[] = "yourInfo"
new User[]  =  "yourInfo"
new Pass[] =  "yourInfo"
new Db[] =  "yourInfo"

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 )

__________________
Airkish 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 22:33.


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