stats command -
ivndosos - 07.02.2018
Hi,
I don't have any issues with my stats code, I just want to know how do I see other's stats as well? I can only see mine's at the moment.
Код:
CMD:stats(playerid, params[])
{
if(connected[playerid] == true) return GameTextForPlayer(playerid, "~r~Spawn First", 5000, 5);
new id;
if(sscanf(params, "u", id)) return SendClientMessage(, -1, "{c3c3c3}(INFO) /stats [id]");
SendClientMessage(playerid, -1, "{CECEF6}* You are viewing /stats.");
new string[900], stats[900],str[129], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
format(str, sizeof(str), "{4286f4}Player name {FFFFFF}%s {4286f4}database id {FFFFFF}%i\n\n", name, pInfo[playerid][ID]);
strcat(stats, str);
format(string, sizeof(string), "{4286f4}Admin Level: ( {FFFFFF}%i {4286f4})\n", pInfo[playerid][Admin]);
strcat(stats, string);
format(string, sizeof(string), "{4286f4}Score: ( {FFFFFF}%i {4286f4})\n", pInfo[playerid][Score]);
strcat(stats, string);
format(string, sizeof(string), "{4286f4}Points: ( {FFFFFF}%i {4286f4})\n", pInfo[playerid][Points]);
strcat(stats, string);
format(string, sizeof(string), "{4286f4}Respect: ( {FFFFFF}%i {4286f4})\n", pInfo[playerid][Respect]);
strcat(stats, string);
format(string, sizeof(string), "{4286f4}Kills: ( {FFFFFF}%i {4286f4})\n", pInfo[playerid][Kills]);
strcat(stats, string);
format(string, sizeof(string), "{4286f4}Deaths: ( {FFFFFF}%i {4286f4})\n", pInfo[playerid][Deaths]);
strcat(stats, string);
format(string, sizeof(string), "{4286f4}Ratio K/D: ( {FFFFFF}%.2f {4286f4})\n", floatdiv(pInfo[playerid][Kills], pInfo[playerid][Deaths]));
strcat(stats, string);
ShowPlayerDialog(playerid, 55, DIALOG_STYLE_MSGBOX, "STATS", stats, "Ok", "");
return 1;
}
Re: stats command -
zMason - 07.02.2018
It's because you've assigned your own ID (playerid), instead it should've been the specified (id) like this:
Код:
CMD:stats(playerid, params[])
{
if(connected[playerid] == true) return GameTextForPlayer(playerid, "~r~Spawn First", 5000, 5);
new id;
if(sscanf(params, "u", id)) return SendClientMessage(, -1, "{c3c3c3}(INFO) /stats [id]");
SendClientMessage(playerid, -1, "{CECEF6}* You are viewing /stats.");
new string[900], stats[900],str[129], name[MAX_PLAYER_NAME];
GetPlayerName(id, name, sizeof(name));
format(str, sizeof(str), "{4286f4}Player name {FFFFFF}%s {4286f4}database id {FFFFFF}%i\n\n", name, pInfo[id][ID]);
strcat(stats, str);
format(string, sizeof(string), "{4286f4}Admin Level: ( {FFFFFF}%i {4286f4})\n", pInfo[id][Admin]);
strcat(stats, string);
format(string, sizeof(string), "{4286f4}Score: ( {FFFFFF}%i {4286f4})\n", pInfo[id][Score]);
strcat(stats, string);
format(string, sizeof(string), "{4286f4}Points: ( {FFFFFF}%i {4286f4})\n", pInfo[id][Points]);
strcat(stats, string);
format(string, sizeof(string), "{4286f4}Respect: ( {FFFFFF}%i {4286f4})\n", pInfo[id][Respect]);
strcat(stats, string);
format(string, sizeof(string), "{4286f4}Kills: ( {FFFFFF}%i {4286f4})\n", pInfo[id][Kills]);
strcat(stats, string);
format(string, sizeof(string), "{4286f4}Deaths: ( {FFFFFF}%i {4286f4})\n", pInfo[id][Deaths]);
strcat(stats, string);
format(string, sizeof(string), "{4286f4}Ratio K/D: ( {FFFFFF}%.2f {4286f4})\n", floatdiv(pInfo[id][Kills], pInfo[id][Deaths]));
strcat(stats, string);
ShowPlayerDialog(playerid, 55, DIALOG_STYLE_MSGBOX, "STATS", stats, "Ok", "");
return 1;
}
I'd also suggest to check if IsPlayerConnected(id) and return an error message if it's false.