MYSQL取得排名的方法
get_user_info(id,"name",username,31)
get_user_info(id,passfield,userpwd,31)
replace_all(username,31,"[","[")
replace_all(username,31,"]","]")
replace_all(username,31,"<","<")
replace_all(username,31,">",">")
new g_sqlpwd
new g_Signature
new g_realname
new g_kills
new g_deaths
new g_score
g_dbc = dbi_connect(g_host,g_user,g_pass,g_dbname,g_error,MAX_NAME_LENGTH)
if (g_dbc == SQL_FAILED)
log_amx(" SQL Connection Failed")
else
{
result = dbi_query(g_dbc,"set names utf8;")
result = dbi_query(g_dbc,"select * from `%s` where Username = '%s'", g_sqlstats_table, username)
if (result == RESULT_FAILED)
{
log_amx(" Sorry,No DataBase or Table")
}
else if(result == RESULT_NONE)
{
dbi_free_result(result)
dbi_close(g_dbc)
new szMessage;
format( szMessage, 191, "^x04【未注册用户】^x03%s^x04【来自】^x03%s-%s",username,szCountry,szArea)
display_chat( szMessage);
format( szMessage, 191, "^x04【个性签名】^x03请到http://klwbcs.vicp.net注册才能显示");
display_chat( szMessage);
}
else
{
dbi_result(result, "Password", g_sqlpwd, 31)
dbi_result(result, "Real_name",g_realname,31)
dbi_result(result, "Signature",g_Signature,63)
dbi_result(result, "kills",g_kills,11)
dbi_result(result, "deaths",g_deaths,11)
dbi_result(result, "score",g_score,11)
dbi_free_result(result)
dbi_close(g_dbc)
g_dbc = dbi_connect(g_host,g_user,g_pass,g_dbname,g_error,MAX_NAME_LENGTH)
result = dbi_query(g_dbc,"select * from `%s` where score >= '%s'", g_sqlstats_table, g_score)
iRankPos = dbi_num_rows(result)
dbi_free_result(result)
dbi_close(g_dbc)
new szMessage;
format( szMessage, 191, "^x01* 欢迎【^x04%s^x01】^x03%s^x01 -->>【排名】第^x04%d^x01名【来自】^x04%s^x01 - ^x04%s",iRank(), username, iRankPos,szCountry, szArea);
display_chat( szMessage);
format( szMessage, 191, "^x03【个性签名】^x04%s", g_Signature);
display_chat( szMessage);
}
页:
[1]