I wanna made a top 5 users with menu_create and if i press on player show custom stats. Example:
I write /top5 i get menu from mysql by points:
TOP USERS MENIU
1) USER1 [300 points]
2) USER2 [100 points]
3) USER3 [25 points]
And if i press number 1 i get:
USER1 STATISTICS
4102 kills
265 deaths
654hs
and etc... I have made like this:
PHP Code:
public sqlLoadTop()
{
new Handle:hQuery;
hQuery = SQL_PrepareQuery(g_sql, "SELECT player_name, points FROM users ORDER BY points DESC LIMIT 5;");
if(!SQL_Execute(hQuery))
checkError(hQuery, 1);
else if(SQL_NumResults(hQuery))
{
g_top_menu = menu_create("TOP 5 PLAYERS", "menu_Top5Nothing");
g_block_top_menu = 0;
new sData[128];
new player_name[32];
new sPosition[2];
new points[128];
new iPosition;
while(SQL_MoreResults(hQuery))
{
++iPosition;
SQL_ReadResult(hQuery, 0, player_name, charsmax(player_name));
SQL_ReadResult(hQuery, 1, points, charsmax(points));
num_to_str(iPosition, sPosition, charsmax(sPosition));
formatex(sData, charsmax(sData), "%s \y[\r%s\y]", player_name, points);
menu_additem(g_top_menu, sData, sPosition);
SQL_NextRow(hQuery);
}
menu_setprop(g_top_menu, MPROP_NEXTNAME, "Next");
menu_setprop(g_top_menu, MPROP_BACKNAME, "Back");
menu_setprop(g_top_menu, MPROP_EXITNAME, "Exit");
SQL_FreeHandle(hQuery);
}
else
{
g_block_top_menu = 1;
SQL_FreeHandle(hQuery);
}
return PLUGIN_HANDLED;
}
public checkError(const Handle:hQuery, const query_num)
{
SQL_QueryError(hQuery, g_sql_error, charsmax(g_sql_error));
log_to_file("error_sql.log", "- error: %d - code: %s", query_num, g_sql_error);
SQL_FreeHandle(hQuery);
}
public clcmd_Top15(id)
{
if(!is_user_connected(id))
return PLUGIN_HANDLED;
if(g_block_top_menu)
{
return PLUGIN_HANDLED;
}
menu_display(id, g_top_menu);
return PLUGIN_HANDLED;
}
public menu_Top5Nothing(id, menuid, item)
{
if(!is_user_connected(id) || item == MENU_EXIT)
return PLUGIN_HANDLED;
clcmd_Top15(id);
return PLUGIN_HANDLED;
}
But i dont know how to get submenu by player like in my example. Any help? Thanks guys!