Last 5 user using the command - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Last 5 user using the command (
/showthread.php?tid=628925)
Last 5 user using the command -
DGRP - 17.02.2017
How do I make a command that shows last 5 admin using a command. In this case, last 5 admin using /givemoney [playerid] [amount] [reason] command, (Example: /givemoney 3 1250 TESTING), then when a user types /lastgivemoney, they will be shown messages in the chat something like:
Код:
————— LAST 5 ADMIN USING /givemoney —————
1. Mike_Nico(ID: 3), Reason: TESTING
2. Nico_Andrea, Reason: TESTING2
3. Martin_1111, Reason: TESTING3
Re: Last 5 user using the command -
SyS - 17.02.2017
add this log to sql data base with some primary key or a date filed and do a query to fetch results in descending order.
Re: Last 5 user using the command -
AbyssMorgan - 17.02.2017
Last player commands:
PHP код:
new CMD1[MAX_PLAYERS][200],
CMD2[MAX_PLAYERS][200],
CMD3[MAX_PLAYERS][200],
CMD4[MAX_PLAYERS][200],
CMD5[MAX_PLAYERS][200];
public OnPlayerConnect(playerid){
CMD1[playerid] = "---"; //newest
CMD2[playerid] = "---";
CMD3[playerid] = "---";
CMD4[playerid] = "---";
CMD5[playerid] = "---"; //last
return 1;
}
public OnPlayerCommandReceived(playerid,cmdtext[]){
CMD5[playerid] = CMD4[playerid];
CMD4[playerid] = CMD3[playerid];
CMD3[playerid] = CMD2[playerid];
CMD2[playerid] = CMD1[playerid];
format(CMD1[playerid],200,"%s",cmdtext);
return 1;
}
Re: Last 5 user using the command -
renatog - 17.02.2017
I don't know how to explain, so I did an example. Don't just copy and paste, try to understand what I did.
PHP код:
new lastGiveMoneyCommandUses[5][144];
// 5 because you want the latest 5, 144 because it's the chat limit (in case of big reasons)
//In your give money command:
{
lastGiveMoneyCommandUses[4] = lastGiveMoneyCommandUses[3];
lastGiveMoneyCommandUses[3] = lastGiveMoneyCommandUses[2];
lastGiveMoneyCommandUses[2] = lastGiveMoneyCommandUses[1];
lastGiveMoneyCommandUses[1] = lastGiveMoneyCommandUses[0];
format(lastGiveMoneyCommandUses[0], 144, "%s gave %d to %s, reason: %s", adminName, amount, playerName, reason);
}
SendLastGiveMoneyCommandUses(playerid)
{
SendClientMessage(playerid, -1, " ————— LAST 5 ADMIN USING /givemoney —————");
SendClientMessage(playerid, -1, lastGiveMoneyCommandUses[0]);
SendClientMessage(playerid, -1, lastGiveMoneyCommandUses[1]);
SendClientMessage(playerid, -1, lastGiveMoneyCommandUses[2]);
SendClientMessage(playerid, -1, lastGiveMoneyCommandUses[3]);
SendClientMessage(playerid, -1, lastGiveMoneyCommandUses[4]);
return 1;
}
Respuesta: Last 5 user using the command -
Eloy - 17.02.2017
Try
PHP код:
public OnPlayerCommandReceived(playerid, cmdtext[])
{
new Info[128], name[MAX_PLAER_NAME];
format(info, sizeof(info), "Command executed By: %s Command: %s", GetPlayerName(playerid, name, sizeof(name)), cmdtext);
printf("[LOG CMD] %s", info);
return 1;
}