14.01.2014, 10:00
Can someone tell me what's wrong? This /top is supposed to show top 5 players with highest score, money, deaths and exp, but when i do /top ingame, it shows no name and 0, at every value.
pawn Код:
CMD:top(playerid, params[])
{
if(GetPVarInt(playerid,"CmdTime")>GetTickCount())return SCM(playerid,0xFF0000FF,"Please wait before using this command again.");
mysql_query("SELECT user, Scores FROM `playerdata` ORDER BY `Scores` DESC LIMIT 5");
mysql_query("SELECT user, Deaths FROM `playerdata` ORDER BY `Deaths` DESC LIMIT 5");
mysql_query("SELECT user, Cash FROM `playerdata` ORDER BY `Cash` DESC LIMIT 5");
mysql_query("SELECT user, Exp FROM `playerdata` ORDER BY `Exp` DESC LIMIT 5");
mysql_store_result();
new num, top[6][24], score[6][10], deaths[6][10], cash[6][20], exp[6][25];
while(mysql_retrieve_row())
{
mysql_fetch_field_row(top[num], "user");
mysql_fetch_field_row(score[num], "Scores");
mysql_fetch_field_row(deaths[num], "Deaths");
mysql_fetch_field_row(cash[num], "Cash");
mysql_fetch_field_row(exp[num], "Exp");
num++;
}
mysql_free_result();
new temp[1500];
new info[1500];
//Score
strcat(info,"{53C506}Top 5 players with most score:\n\n");
format(temp, sizeof(temp), "{FFFFFF}N° 1: %s with {A1C2FF}%d Score \n", top[0], score[0]);
strcat(info, temp);
format(temp, sizeof(temp), "{FFFFFF}N° 2: %s with {A1C2FF}%d Score \n", top[1], strval(score[1]));
strcat(info, temp);
format(temp, sizeof(temp), "{FFFFFF}N° 3: %s with {A1C2FF}%d Score \n", top[2], strval(score[2]));
strcat(info, temp);
format(temp, sizeof(temp), "{FFFFFF}N° 4: %s with {A1C2FF}%d Score \n", top[3], strval(score[3]));
strcat(info, temp);
format(temp, sizeof(temp), "{FFFFFF}N° 5: %s with {A1C2FF}%d Score \n\n", top[4], strval(score[4]));
strcat(info, temp);
//Deaths
strcat(info,"{53C506}Top 5 players with most deaths:\n\n");
format(temp, sizeof(temp), "{FFFFFF}N° 1: %s with {A1C2FF}%d Deaths \n", top[0], deaths[0]);
strcat(info, temp);
format(temp, sizeof(temp), "{FFFFFF}N° 2: %s with {A1C2FF}%d Deaths \n", top[1], strval(deaths[1]));
strcat(info, temp);
format(temp, sizeof(temp), "{FFFFFF}N° 3: %s with {A1C2FF}%d Deaths \n", top[2], strval(deaths[2]));
strcat(info, temp);
format(temp, sizeof(temp), "{FFFFFF}N° 4: %s with {A1C2FF}%d Deaths \n", top[3], strval(deaths[3]));
strcat(info, temp);
format(temp, sizeof(temp), "{FFFFFF}N° 5: %s with {A1C2FF}%d Deaths \n\n", top[4], strval(deaths[4]));
strcat(info, temp);
//Cash
strcat(info,"{53C506}Top 5 players with most deaths:\n\n");
format(temp, sizeof(temp), "{FFFFFF}N° 1: %s with {A1C2FF}%i CSCash \n", top[0], cash[0]);
strcat(info, temp);
format(temp, sizeof(temp), "{FFFFFF}N° 2: %s with {A1C2FF}%i CSCash \n", top[1], strval(cash[1]));
strcat(info, temp);
format(temp, sizeof(temp), "{FFFFFF}N° 3: %s with {A1C2FF}%i CSCash \n", top[2], strval(cash[2]));
strcat(info, temp);
format(temp, sizeof(temp), "{FFFFFF}N° 4: %s with {A1C2FF}%i CSCash \n", top[3], strval(cash[3]));
strcat(info, temp);
format(temp, sizeof(temp), "{FFFFFF}N° 5: %s with {A1C2FF}%i CSCash \n\n", top[4], strval(cash[4]));
strcat(info, temp);
//Exp
strcat(info,"{53C506}Top 5 players with most deaths:\n\n");
format(temp, sizeof(temp), "{FFFFFF}N° 1: %s with {A1C2FF}%d Exp \n", top[0], exp[0]);
strcat(info, temp);
format(temp, sizeof(temp), "{FFFFFF}N° 2: %s with {A1C2FF}%d Exp \n", top[1], strval(exp[1]));
strcat(info, temp);
format(temp, sizeof(temp), "{FFFFFF}N° 3: %s with {A1C2FF}%d Exp \n", top[2], strval(exp[2]));
strcat(info, temp);
format(temp, sizeof(temp), "{FFFFFF}N° 4: %s with {A1C2FF}%d Exp \n", top[3], strval(exp[3]));
strcat(info, temp);
format(temp, sizeof(temp), "{FFFFFF}N° 5: %s with {A1C2FF}%d Exp \n", top[4], strval(exp[4]));
strcat(info, temp);
ShowPlayerDialog(playerid, DIALOG_TOP, DIALOG_STYLE_MSGBOX,"Top 5 BWH Players",info,"Close","");
SetPVarInt(playerid,"CmdTime",GetTickCount()+5000);
return true;
}