//-----------------//稱號
new fun_name[33][32];
new steam_id[33][35];
//-----------------//稱號
//稱號系統
register_cvar("amx_funname","0"); //是否打開稱號系統
register_cvar("amx_funname_save","0"); //是否打開存檔系統
//稱號系統
setting_funname = get_cvar_num("amx_funname"); //是否打開稱號系統
setting_funname_save = get_cvar_num("amx_funname_save"); //是否打開存檔系統
register_clcmd("say","allchat")
public client_putinserver(id)
{
if(setting_sqlserver_open && setting_funname && setting_funname_save)
{
sql_load_data(id)
}
return PLUGIN_CONTINUE
}
public sql_load_data(id)
{
new NetAddr[32]
get_user_ip(id, NetAddr, 31, 1)
new Handle:hkcs_sql_connect = SQL_MakeDbTuple(hkcs_host,hkcs_user,hkcs_pass,hkcs_db)
new Handle:hkcs_sql = SQL_Connect(hkcs_sql_connect, errno, hkcs_error, 511)
get_user_authid(id, steam_id[id], 34)
if(equal(steam_id[id],"VALVE_ID_LAN"))
{
new Handle:hkcs_query_acc = SQL_PrepareQuery(hkcs_sql, "SELECT * FROM `%s` WHERE name_ip= '%s';",hkcs_tab,NetAddr);
SQL_Execute(hkcs_query_acc)
if(SQL_NumResults(hkcs_query_acc))
{
SQL_ReadResult(hkcs_query_acc, 2, fun_name[id],30) //設定稱號
}
else
if(!SQL_NumResults(hkcs_query_acc))
{
new Handle:query = SQL_PrepareQuery(hkcs_sql, "INSERT INTO `%s` (`name_ip`,`name`) VALUES ('%s','%s');",hkcs_tab,NetAddr,default_name);
SQL_Execute(query) //建立稱號
format(fun_name[id], 12, "%s",default_name)
}
}
else
{
new Handle:hkcs_query_acc = SQL_PrepareQuery(hkcs_sql, "SELECT * FROM `%s` WHERE steam_id= '%s';",hkcs_tab,steam_id[id]);
SQL_Execute(hkcs_query_acc)
if(SQL_NumResults(hkcs_query_acc))
{
SQL_ReadResult(hkcs_query_acc, 2, fun_name[id],30)
}
else
if(!SQL_NumResults(hkcs_query_acc))
{
new Handle:query = SQL_PrepareQuery(hkcs_sql, "INSERT INTO `%s` (`steam_id`,`name_ip`) VALUES ('%s','%s');",hkcs_tab,steam_id[id],NetAddr);
SQL_Execute(query)
format(fun_name[id], 12, "%s",default_name)
}
}
SQL_FreeHandle(hkcs_sql)
}
public allchat(id)
{
if(!is_user_connected(id))
{
return PLUGIN_HANDLED
}
new system_msg[150]
new all_msg[200]
new name[32]
get_user_name(id, name, 31)
read_args(all_msg, 200)
remove_quotes(all_msg)
replace_all(all_msg, 200, "%", "%")
format(all_msg, 200, " %s", all_msg) // 獲取SAY信息
new check_name[32]
new send_msg[192],get_msg[256]
format(get_msg, 200, "%s", all_msg) // 復制信息
strtok(get_msg[1],check_name,30,send_msg,170,' ') // 分離信息
if(containi(check_name,"/fun_name") != -1 && setting_funname)
{
if(!send_msg[0])
{
format(system_msg, 149, "%s^x04 稱號長度必須大於1字節", setting_plugin_name)
client_color(id, id, system_msg)
return PLUGIN_HANDLED
}
new fun_len = strlen(send_msg);
if(fun_len > 15)
{
format(system_msg, 149, "%s^x04 稱號長度必需小於5個中文字或15個英文字", setting_plugin_name)
client_color(id, id, system_msg)
return PLUGIN_HANDLED
}
format(fun_name[id], 30, "%s",send_msg)
format(system_msg, 149, "%s^x04 稱號變更為^x03 %s", setting_plugin_name,fun_name[id])
client_color(id, id, system_msg)
if(setting_sqlserver_open && setting_funname_save)
{
if(equal(steam_id[id],"VALVE_ID_LAN"))
{
new NetAddr[32]
get_user_ip(id, NetAddr, 31, 1)
new Handle:hkcs_sql_connect = SQL_MakeDbTuple(hkcs_host,hkcs_user,hkcs_pass,hkcs_db)
new Handle:hkcs_sql = SQL_Connect(hkcs_sql_connect, errno, hkcs_error, 511)
new Handle:query = SQL_PrepareQuery(hkcs_sql, "UPDATE `%s` SET `name` = '%s' WHERE ( `name_ip` = '%s');",hkcs_tab,fun_name[id],NetAddr)
SQL_Execute(query)
SQL_FreeHandle(hkcs_sql)
}
else
{
new NetAddr[32]
get_user_ip(id, NetAddr, 31, 1)
new Handle:hkcs_sql_connect = SQL_MakeDbTuple(hkcs_host,hkcs_user,hkcs_pass,hkcs_db)
new Handle:hkcs_sql = SQL_Connect(hkcs_sql_connect, errno, hkcs_error, 511)
new Handle:query = SQL_PrepareQuery(hkcs_sql, "UPDATE `%s` SET `name` = '%s',`name_ip` = '%s' WHERE ( `steam_id` = '%s');",hkcs_tab,fun_name[id],NetAddr,steam_id[id])
SQL_Execute(query)
SQL_FreeHandle(hkcs_sql)
}
}
return PLUGIN_HANDLED
}
return PLUGIN_HANDLED
}