16.02.2016, 22:27
I'm working on a command which shows the last text someone typed in that chat.
Everything works fine, the text is getting stored in the database. But the only problem is
that whenever I use that command, only the first record is shown. For example.
I type "Hey" in chat. It gets saved into the database with the ID 0 (auto-increment).
Now if I type "Bye" in chat, it gets saved into the database with the ID 1.
Whenever I use the command /last chat "playerid" it only displays "Bye" instead of "Bye" and "Hey".
This is my command.
What did I do wrong?
Everything works fine, the text is getting stored in the database. But the only problem is
that whenever I use that command, only the first record is shown. For example.
I type "Hey" in chat. It gets saved into the database with the ID 0 (auto-increment).
Now if I type "Bye" in chat, it gets saved into the database with the ID 1.
Whenever I use the command /last chat "playerid" it only displays "Bye" instead of "Bye" and "Hey".
This is my command.
Код:
CMD:last(playerid, params[]) { if(pInfo[playerid][pAdminLevel] > 0) { new item[256], otherid, othername[MAX_PLAYER_NAME]; GetPlayerName(otherid, othername, sizeof(othername)); if(sscanf(params, "s[256]r", item, otherid)) { SendClientMessage(playerid, COLOR_GREY, "Usage: {FFFFFF}/last [action] [playerid]"); SendClientMessage(playerid, COLOR_GREY, "Last: Chat"); } else if(strcmp(item, "chat", true) == 0) { new query[512]; mysql_format(mysql, query, sizeof(query), "SELECT * FROM `chatlog` WHERE `chatName` = '%s' LIMIT 10", othername); new Cache: salkf = mysql_query(mysql, query); new test2[512], test3[512], csf[512]; for(new i, j = cache_get_row_count(); i != j; ++i) { cache_get_field_content(i, "chatString", test2); cache_get_field_content(i, "chatTime", test3); format(csf, sizeof(csf), "[%s] %s.\n", test3, test2); ShowPlayerDialog(playerid, DIALOG_LCHAT, DIALOG_STYLE_MSGBOX, "SERVER: Last Chat", csf, "Close", ""); } cache_delete(salkf); } } else return SendClientMessage(playerid, -1, NotAdmin); return 1; }