CMD:xplog(playerid, params[])
{
if(!IsAdminLevel(playerid, 4)) return NoPermsMSG(playerid);
new query[200], dialogfinal[1000], string[128], amount, reason[30], givenid, givenbyid;
mysql_format(mysql, query, sizeof(query), "SELECT * FROM `xplog` ORDER BY `ID` DESC LIMIT 10");
new Cache: result = mysql_query(mysql, query);
strcat(dialogfinal, "Player\tGiven By\tAmount\tReason\n");
cache_get_row_count();
new count = cache_get_row_count();
if(count == 0) return ErrorMSG(playerid, "The XP log is empty.");
for(new i = 0; i < count; i++)
{
cache_get_row(i, 3, reason);
givenid = cache_get_field_content_int(i, "GivenID");
givenbyid = cache_get_field_content_int(i, "GivenByID");
amount = cache_get_field_content_int(i, "Amount");
format(string, sizeof(string), "%s\t%s\t%d\t%s\n", GetNameFromMySQLID(givenid), GetNameFromMySQLID(givenbyid), amount, reason);
strcat(dialogfinal, string);
}
cache_delete(result);
ShowPlayerDialog(playerid, DIALOG_XPLOG, DIALOG_STYLE_TABLIST_HEADERS, ""COL_WHITE"XP Log", dialogfinal, "Close", "");
return 1;
}
Code:
GetNameFromMySQLID(givenid), GetNameFromMySQLID(givenbyid) |
SELECT
recipient.name,
sender.name,
xplog.amount,
xplog.reason
FROM
xplog
INNER JOIN
Player recipient ON xplog.givenID = recipient.ID
INNER JOIN
Player sender ON xplog.givenByID = sender.ID
ORDER BY xplog.ID DESC LIMIT 10