|
Member
|

10-27-2014
, 12:29
[help] Fix the errors in Admin Attandance plugin
|
#1
|
This plugin is not working n the author is not responding , not sure why its not in the allied mod forum.. Please do check if u know scripting ... Its a must for every server ...
The sql is failing to load and the plugin is forced to stop.... every server getting the same error ..
Cross checked with php files and sql , its all fine... just needs to fix something in plugin...
Code:
/* AttendanceAdmins v2.0 Beta v1.0 */
#include <amxmodx>
#include <sqlx>
new Error[512], adminID[33][32], gamedate[12], Handle: SqlTuple;
public plugin_init() {
register_plugin("AttendanceAdmins", "2.0", "ZETA [M|E|N]");
register_cvar("aa_sql_host", "localhost");
register_cvar("aa_sql_user", "root");
register_cvar("aa_sql_pass", "");
register_cvar("aa_sql_db", "AttendanceAdmins");
}
public plugin_cfg() {
new host[64], user[64], password[64], database[64];
get_cvar_string("aa_sql_host", host, charsmax(host));
get_cvar_string("aa_sql_user", user, charsmax(user));
get_cvar_string("aa_sql_pass", password, charsmax(password));
get_cvar_string("aa_sql_db", database, charsmax(database));
SqlTuple = SQL_MakeDbTuple(host, user, password, database);
get_time("%Y-%m-%d", gamedate, charsmax(gamedate));
}
public client_putinserver(id) {
new name[32], ip[32], authid[32];
get_user_name(id, name, charsmax(name));
get_user_ip(id, ip, charsmax(ip), 1);
get_user_authid(id, authid, charsmax(authid));
new Handle: SqlConnection, Handle: Query, ErrorCode;
SqlConnection = SQL_Connect(SqlTuple, ErrorCode, Error, charsmax(Error))
if(SqlConnection == Empty_Handle)
set_fail_state(Error);
Query = SQL_PrepareQuery(SqlConnection, "SELECT * FROM `admins`");
SQL_Execute(Query);
new ID[46], type;
while(SQL_MoreResults(Query)) {
type = SQL_ReadResult(Query, 1);
SQL_ReadResult(Query, 2, ID, charsmax(ID));
switch(type) {
case 0:{
if(containi(ID, name) != -1) {
SQL_ReadResult(Query, 0, adminID[id], charsmax(adminID));
break;
}
}
case 1:{
if(containi(ID, ip) != -1) {
SQL_ReadResult(Query, 0, adminID[id], charsmax(adminID));
break;
}
}
case 2:{
if(containi(ID, authid) != -1) {
SQL_ReadResult(Query, 0, adminID[id], charsmax(adminID));
break;
}
}
}
SQL_NextRow(Query);
}
SQL_FreeHandle(Query);
SQL_FreeHandle(SqlConnection);
return PLUGIN_HANDLED;
}
public client_disconnect(id) {
if(equal(adminID[id], ""))
return PLUGIN_HANDLED;
new Float: gametime, Float: regtime;
gametime = float(get_user_time(id, 1)) / 3600;
if(gametime < 0.02)
return PLUGIN_HANDLED;
new Handle: SqlConnection, Handle: Query, ErrorCode;
SqlConnection = SQL_Connect(SqlTuple, ErrorCode, Error, charsmax(Error));
if(SqlConnection == Empty_Handle)
set_fail_state(Error);
Query = SQL_PrepareQuery(SqlConnection, "SELECT * FROM `attendance` WHERE `Date` = '%s' AND `Name` = '%s'", gamedate, adminID[id]);
SQL_Execute(Query);
if(SQL_MoreResults(Query)) {
SQL_ReadResult(Query, 2, regtime);
regtime += gametime;
Query = SQL_PrepareQuery(SqlConnection, "UPDATE `attendance` SET `Time` = '%f' WHERE `Date` = '%s' AND `Name` = '%s'", regtime, gamedate, adminID[id]);
}
else
Query = SQL_PrepareQuery(SqlConnection, "INSERT INTO `attendance` VALUES ('%s','%s','%f')", gamedate, adminID[id], gametime);
SQL_Execute(Query);
Query = SQL_PrepareQuery(SqlConnection, "SELECT * FROM `statistics` WHERE `Name` = '%s'", adminID[id]);
SQL_Execute(Query);
if(SQL_MoreResults(Query)) {
SQL_ReadResult(Query, 1, regtime);
regtime += gametime;
Query = SQL_PrepareQuery(SqlConnection, "UPDATE `statistics` SET `Time` = '%f', `LastDate` = '%s' WHERE `Name` = '%s'", regtime, gamedate, adminID[id]);
}
else
Query = SQL_PrepareQuery(SqlConnection, "INSERT INTO `statistics` VALUES ('%s','%f', '%s')", adminID[id], gametime, gamedate);
SQL_Execute(Query);
SQL_FreeHandle(Query);
SQL_FreeHandle(SqlConnection);
adminID[id] = "";
return PLUGIN_HANDLED;
}
Or guide me if u have similar plugin....
Last edited by deepaklost; 10-27-2014 at 12:29.
|
|