Last 5 user using the command
#1

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
Reply
#2

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.
Reply
#3

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;

Reply
#4

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"adminNameamountplayerNamereason);
}
SendLastGiveMoneyCommandUses(playerid)
{
    
SendClientMessage(playerid, -1" ————— LAST 5 ADMIN USING /givemoney —————");
    
SendClientMessage(playerid, -1lastGiveMoneyCommandUses[0]);
    
SendClientMessage(playerid, -1lastGiveMoneyCommandUses[1]);
    
SendClientMessage(playerid, -1lastGiveMoneyCommandUses[2]);
    
SendClientMessage(playerid, -1lastGiveMoneyCommandUses[3]);
    
SendClientMessage(playerid, -1lastGiveMoneyCommandUses[4]);
    return 
1;

Reply
#5

Try

PHP код:
public OnPlayerCommandReceived(playeridcmdtext[])
{
     new 
Info[128], name[MAX_PLAER_NAME];
     
format(infosizeof(info), "Command executed By: %s Command: %s"GetPlayerName(playeridnamesizeof(name)), cmdtext);
     
printf("[LOG CMD] %s"info);
     return 
1;

Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)