Raised This Month: $ Target: $400
 0% 

How to get selected player from mysql?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
jonatat
Senior Member
Join Date: Dec 2017
Old 07-02-2018 , 12:42   How to get selected player from mysql?
Reply With Quote #1

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(hQuery1);
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(hQuery0player_namecharsmax(player_name));
SQL_ReadResult(hQuery1pointscharsmax(points));

num_to_str(iPositionsPositioncharsmax(sPosition));

formatex(sDatacharsmax(sData), "%s \y[\r%s\y]"player_namepoints);

menu_additem(g_top_menusDatasPosition);

SQL_NextRow(hQuery);
}

menu_setprop(g_top_menuMPROP_NEXTNAME"Next");
menu_setprop(g_top_menuMPROP_BACKNAME"Back");
menu_setprop(g_top_menuMPROP_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(hQueryg_sql_errorcharsmax(g_sql_error));

log_to_file("error_sql.log""- error: %d - code: %s"query_numg_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(idg_top_menu);

return 
PLUGIN_HANDLED;
}

public 
menu_Top5Nothing(idmenuiditem)
{
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!
jonatat is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:38.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode