Junior Member
Join Date: Oct 2017
Location: Morocco
|
03-22-2018
, 21:17
Re: [Help] admin Connect log
|
#2
|
Quote:
Originally Posted by hardboy
hello i have this error but i don't understand to fix it.
server go shutdown when change map and slow if players is more than 20
Code:
L 03/07/2018 - 20:56:43: [MySQL] Invalid database handle: 0
L 03/07/2018 - 20:56:43: [AMXX] Run time error 10 (plugin "admin_connect.amxx") (native "SQL_PrepareQuery") - debug not enabled!
L 03/07/2018 - 20:56:43: [AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quotes).
sma
Code:
#include <amxmodx>
#include <amxmisc>
#include <sqlx>
#define VERSION "1.0"
#define admin ADMIN_RESERVATION
new g_sqlTable[16] = "cretagam_admins"
new Handle: SqlxTuple, Handle:SqlxConnection;
new Error[ 512 ];
public plugin_init()
{
register_plugin("Admin Logs",VERSION,"Unknow")
set_task(0.1,"SetSQL")
}
public SetSQL()
{
SqlxTuple = SQL_MakeDbTuple( "******","******","***********","********" );
new ErrorCode;
SqlxConnection = SQL_Connect( SqlxTuple, ErrorCode, Error, charsmax( Error ) );
new Handle:Queries = SQL_PrepareQuery( SqlxConnection, "CREATE TABLE IF NOT EXISTS `%s` ( `nick` VARCHAR( 36 ), `steamid` VARCHAR( 32 ) NOT NULL, `ip` VARCHAR( 32 ) NOT NULL,`flags` VARCHAR( 32 ) NOT NULL,`team` VARCHAR( 32 ) NOT NULL, `server` VARCHAR( 105 ) DEFAULT 'none' NOT NULL, `Ddate` VARCHAR( 32 ) NOT NULL, `time` VARCHAR( 32 ) NOT NULL,`map` VARCHAR( 36 ) NOT NULL ) COMMENT = 'Admins Logs'",g_sqlTable );
if( !SQL_Execute( Queries ) )
{
SQL_QueryError( Queries, Error, charsmax( Error ) );
set_fail_state( Error );
}
if( SqlxConnection )
{
server_print( "[Admin Logs] Conected to database");
}
else
{
server_print( "[Admin Logs] : Database connection failed (error %d): %s", ErrorCode, Error )
SQL_FreeHandle( SqlxTuple );
}
}
public client_connect( id )
{
set_task( 5.0, "check", id );
}
public check(id)
{
if (get_user_flags(id) & admin) {
//static SqlQuery[ 1001 ];
new szAdminName[36], szAdminAuth[32], szAdminIP[32],szDate[26],szMap[36],szTime[16], szServerName[101],szFlags[32],szTeam[32];
get_user_name(id,szAdminName,35)
remove_quotes(szAdminName)
while(replace(szAdminName,35,"'","")) { }
get_user_authid(id,szAdminAuth,31)
get_user_ip(id, szAdminIP, charsmax(szAdminIP), 1)
get_time("%m-%d-%Y",szDate,25)
get_time("%H:%M:%S",szTime,15)
get_mapname(szMap,35)
get_cvar_string("hostname", szServerName, 100)
new flags = get_user_flags(id)
get_flags(flags, szFlags, 31)
if (get_user_team(id) == 0)
szTeam = "Spectator";
else if (get_user_team(id) == 1)
szTeam = "Terrorist";
else if (get_user_team(id) == 2)
szTeam = "Counter-Terrorist";
else
szTeam = "Unassigned Team";
//formatex(SqlQuery, charsmax(SqlQuery),"INSERT INTO %s (nick,steamid,ip,flags,team,server,Ddate,time,map)VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s')", g_sqlTable, szAdminName, szAdminAuth, szAdminIP,szFlags, szTeam, szServerName, szDate, szTime, szMap );
new Handle:Queries = SQL_PrepareQuery( SqlxConnection, "INSERT INTO %s (nick,steamid,ip,flags,team,server,Ddate,time,map)VALUES ('%s','%s','%s','%s','%s','%s','%s','%s','%s')", g_sqlTable, szAdminName, szAdminAuth, szAdminIP,szFlags, szTeam, szServerName, szDate, szTime, szMap );
if( !SQL_Execute( Queries ) )
{
SQL_QueryError( Queries, Error, charsmax( Error ) );
set_fail_state( Error );
}
}
}
public SqlxHandle( FailState, Handle:Query, Error[], Errcode, Data[], DataSize )
{
if( FailState == TQUERY_CONNECT_FAILED )
{
return server_print( "[Admin Logs] could not connect to SQL database!" );
}
else if( FailState == TQUERY_QUERY_FAILED )
{
return server_print( "[Admin Logs] : Query failed" );
}
if( Errcode )
{
return server_print( "[Admin Logs]: Error on query: %s", Error );
}
static DataNum;
while( SQL_MoreResults( Query ) )
{
DataNum = SQL_ReadResult( Query, 0 );
server_print( "Some data: %s", DataNum );
SQL_NextRow( Query );
}
return PLUGIN_CONTINUE;
}
public plugin_end()
{
if( SqlxTuple != Empty_Handle )
{
SQL_FreeHandle( SqlxTuple );
}
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/
|
Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <geoip>
public plugin_init() {
register_plugin("Connects Log", "1.0", "Crey")
// Add your code here...
}
public client_connect(id) {
new logfile[37];
new datadir[20];
new text[124];
new name[32]
new authid[32]
new ip[32]
new szCountry[32]
get_datadir(datadir, charsmax(datadir));
formatex(logfile, charsmax(logfile), "%s/connected_log.txt", datadir);
get_user_name(id, name, charsmax(name));
get_user_authid(id, authid, 31)
get_user_ip(id, ip, 31)
geoip_country( ip, szCountry )
formatex(text, charsmax(text), "%s | ^"%s^" Connected. [SteamID: %s - IP: %s - Country: %s]", is_user_admin(id) ? "Admin":"Players", name, authid, ip, szCountry);
write_file(logfile, text);
}
|
|