Try this. if it works, keep your 5 bucks for your server costs. I just modified a different plugin I had made for someone.
Code:
#include <amxmodx>
#include <amxmisc>
#include <dbi>
new Sql:dbc
new Result:result
public plugin_init(){
register_plugin("SteamId Manager","1.0","Migs Davis ")
set_task(0.1,"sql_init")
}
public sql_init() {
new host[64], username[32], password[32], dbname[32], error[32]
get_cvar_string("amx_sql_host",host,64)
get_cvar_string("amx_sql_user",username,32)
get_cvar_string("amx_sql_pass",password,32)
get_cvar_string("amx_sql_db",dbname,32)
dbc = dbi_connect(host,username,password,dbname,error,32)
if (dbc == SQL_FAILED)
{
new err[255]
new errNum = dbi_error(dbc, err, 254)
server_print("error1: %s|%d", err, errNum)
}
else
{
dbi_query(dbc,"CREATE TABLE IF NOT EXISTS `steamidmanager` (`steamid` VARCHAR(32) NOT NULL,`player` VARCHAR(32) NOT NULL, PRIMARY KEY(`steamid`))")
}
}
public client_authorized(id){
if ( is_user_bot(id) ) { //Do not add to database
return PLUGIN_CONTINUE
}
if (is_user_hltv(id) ) { //Do not add to database
return PLUGIN_CONTINUE
}
new name[32]
get_user_name(id,name,31)
new authid[32]
get_user_authid(id,authid,31)
result = dbi_query(dbc,"SELECT * FROM steamidmanager WHERE steamid = '%s'",authid)
if (result == RESULT_FAILED){ //Problem with mysql
log_amx("[steamidmanager] MySQL Query failed")
return PLUGIN_CONTINUE
}
else if (result == RESULT_NONE)
{ //not in db, add them
server_print("Not in our database yet, %s", authid)
result = dbi_query(dbc,"INSERT INTO steamidmanager (steamid, player) values ('%s','%s')", authid, name)
return PLUGIN_CONTINUE
}
else
{
server_print("%s is in our database under %s", authid, name)
result = dbi_query(dbc,"UPDATE steamidmanager SET player=%s WHERE steamid='%s'", name, authid)
}
dbi_free_result(result)
return PLUGIN_CONTINUE
}