Hi.
I've done a plugin that logs nick, authid,ip to a database ...
But when the player join again, the ip etc is inserted again, then i have duplicate results...
Can you help with a function that checks before doing the query if the nickname is in the database?
Here is partial code:
Code:
public client_putinserver(id){
new Error[512], Handle: SqlTuple;
new host[64], user[64], password[64], database[64], prefix[64];
new configsDir[64]
get_configsdir(configsDir, 63)
server_cmd("exec %s/amxx.cfg", configsDir) // Execute main configuration file
server_cmd("exec %s/sql.cfg", configsDir)
get_cvar_string("mpstats_sql_host", host, charsmax(host));
get_cvar_string("mpstats_sql_user", user, charsmax(user));
get_cvar_string("mpstats_sql_pass", password, charsmax(password));
get_cvar_string("mpstats_sql_db", database, charsmax(database));
get_cvar_string("mpstats_sql_prefix", prefix, charsmax(prefix));
SqlTuple = SQL_MakeDbTuple(host, user, password, database);
new Handle: SqlConnection, Handle: Query, ErrorCode;
SqlConnection = SQL_Connect(SqlTuple, ErrorCode, Error, charsmax(Error));
new name[32],protocol[32],userip[32];
get_user_name(id,name,31);
get_user_ip(id, userip, 31, 1);
get_user_authid(id, protocol,31);
if(SqlConnection != Empty_Handle)
Query = SQL_PrepareQuery(SqlConnection, "INSERT INTO `mostplay_players`(`nick`,`protocol`,`ip`,`active`) VALUES ('%s','%s','%s','1')", name,protocol, userip);
SQL_Execute(Query);
SQL_FreeHandle(Query);
SQL_FreeHandle(SqlConnection);
server_cmd("echo Player %s with ip %s connected!",name, userip)
return PLUGIN_CONTINUE;
}
Cheers.(and sorry for my bad english)