Mysql Help -
XStreeter - 06.12.2015
1.How can i get all admins online and show they name in textdraw
2. How can i get top 10 Players from mysql R39-3
Please give mee information Thanks
Re: Mysql Help -
XStreeter - 06.12.2015
Sorry for this bump but i rlly need help
THANKS
Re: Mysql Help -
Vince - 06.12.2015
Look up ORDER BY.
Re: Mysql Help -
XStreeter - 06.12.2015
What ?
Please tell mee bro
I rlly need help
Re: Mysql Help -
Antonio144 - 06.12.2015
What's your database schema? You need to formulate an sql query.
1. SELECT `userName` from usersTable WHERE `userLevel` = 'admin'; and then check the usernames with usernames that are online. And then just make the textDraws (use wiki if you need help). BUT you should not do this through an sql. You should already have in your script some variable that holds online player's status (admin, vip, regular etc..) And just lopp through that.
EDIT: oh you didn't mean to get the data from database. But it still applies. Just loop through all the online players and check their level.
2. If you have the score it in the same table as users: SELECT `userName`, `score` from usersTable ORDER BY `score` DESC LIMIT 10; If not, you would need to use join statment or inline query.
But without knowing your database schema I can't form the correct query's.
Re: Mysql Help -
XStreeter - 06.12.2015
1 I dont want to get online admins from database Idk just how to make it with loop i have try but not working.
PHP код:
stock AdminsOnlineTextdraw()
{
new adminstring[128];
for (new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(pInfo[i][pAdminLevel] > 0)
{
format(adminstring, sizeof(adminstring),"%s\n",PlayerName(i));
}
}
}
return 1;
}
2. yeah i know this but i dont know how to show it in textdraw
Please answer mee
THANKS
Re: Mysql Help -
Antonio144 - 06.12.2015
1.
Код:
stock AdminsOnlineTextdraw()
{
new adminstring[128];
for (new i = 0; i < MAX_PLAYERS; i++)
{
if(!IsPlayerConnected(i)) continue;
if(pInfo[i][pAdminLevel] == 0) continue;
new tmp[MAX_PLAYER_NAME+1];
format(tmp, sizeof(tmp),"%s\n",PlayerName(i));
strcat(adminstring, tmp);
}
return adminstring;
}
2. You just want to show a list of online admins?
Re: Mysql Help -
XStreeter - 06.12.2015
Thanks for 1-st
now the second is my problem
I want to get top 10 players from Database and show them to a textdraw
THANKS
Re: Mysql Help -
XStreeter - 06.12.2015
SELECT `userName`, `score` from usersTable ORDER BY `score` DESC LIMIT 10
I mean how to get 10 players from this and show them to textdraw
Re: Mysql Help -
Antonio144 - 06.12.2015
Since I don't know exactly how you want the textdraw to look, I can only point you in the right direction.
Start from
this link and from TexDrawCreate. Experiment with all the functions.
Now for the SQL start from
here
It might look something like this:
Код:
enum tPlayers{
new userName[MAX_PLAYER_NAME],
new score
};
new topPlayers[10][tPlayersyers]
forward OnDataLoad();
mysql_format(MySQL, query, sizeof(query), "SELECT `userName`, `score` from usersTable ORDER BY `score` DESC LIMIT 10", pname);
mysql_pquery(MySQL, query, "OnDataLoad");
public OnDataLoad()
{
for (int i = 0; i < cache_get_row_count(); i++)
{
cache_get_field_content(i, "userName", topPlayers[i][userName]);
topPlayers[i][score] = cache_get_field_content_int(i, "score");
}
return 1;
}
NOTE. code not tested