CMD:test(playerid, params[])
{
printf("[DETECTED CMD:] %s has just used /test", GetPlayerName(playerid));
/*Code here */
}
enum cInfo { UsedCmdX1[MAX_PLAYER_NAME], UsedCmdX2[MAX_PLAYER_NAME], UsedCmdX3[MAX_PLAYER_NAME], UsedCmdX4[MAX_PLAYER_NAME], UsedCmdX5[MAX_PLAYER_NAME], TimesCmdXUsed, }; new CommandInfo[cInfo]; CMD:x(playerid, parmas[]) { switch(CommandInfo[TimesCmdXUsed]) { case 0: { CommandInfo[TimesCmdXUsed]++; format(CommandInfo[UsedCmdX1], sizeof(CommandInfo[UsedCmdX1]), "%s", GetName(playerid)); return 1; } case 1: { CommandInfo[TimesCmdXUsed]++; format(CommandInfo[UsedCmdX2], sizeof(CommandInfo[UsedCmdX2]), "%s", GetName(playerid)); return 1; } case 2: { CommandInfo[TimesCmdXUsed]++; format(CommandInfo[UsedCmdX3], sizeof(CommandInfo[UsedCmdX3]), "%s", GetName(playerid)); return 1; } case 3: { CommandInfo[TimesCmdXUsed]++; format(CommandInfo[UsedCmdX4], sizeof(CommandInfo[UsedCmdX4]), "%s", GetName(playerid)); return 1; } case 4: { CommandInfo[TimesCmdXUsed]++; format(CommandInfo[UsedCmdX5], sizeof(CommandInfo[UsedCmdX5]), "%s", GetName(playerid)); return 1; } } return 1; } CMD:names(playerid, parmas[]) { new string[128]; switch(CommandInfo[TimesCmdXUsed]) { case 0: { SendClientMessage(playerid, -1, " No one used command X !"); return 1; } case 1: { format(string, sizeof(string), "1- %s", CommandInfo[UsedCmdX1]); ShowPlayerDialog(playerid, 10, DIALOG_STYLE_MSGBOX, "Players used command X", string, "Close", ""); return 1; } case 2: { format(string, sizeof(string), "1- %s\n2- %s", CommandInfo[UsedCmdX1], CommandInfo[UsedCmdX2]); ShowPlayerDialog(playerid, 10, DIALOG_STYLE_MSGBOX, "Players used command X", string, "Close", ""); return 1; } case 3: { format(string, sizeof(string), "1- %s\n2- %s\n3- %s", CommandInfo[UsedCmdX1], CommandInfo[UsedCmdX2], CommandInfo[UsedCmdX3]); ShowPlayerDialog(playerid, 10, DIALOG_STYLE_MSGBOX, "Players used command X", string, "Close", ""); return 1; } case 4: { format(string, sizeof(string), "1- %s\n2- %s\n3- %s\n4- %s", CommandInfo[UsedCmdX1], CommandInfo[UsedCmdX2], CommandInfo[UsedCmdX3], CommandInfo[UsedCmdX4]); ShowPlayerDialog(playerid, 10, DIALOG_STYLE_MSGBOX, "Players used command X", string, "Close", ""); return 1; } case 5: { format(string, sizeof(string), "1- %s\n2- %s\n3- %s\n4- %s\n5- %s", CommandInfo[UsedCmdX1], CommandInfo[UsedCmdX2], CommandInfo[UsedCmdX3], CommandInfo[UsedCmdX4], CommandInfo[UsedCmdX5]); ShowPlayerDialog(playerid, 10, DIALOG_STYLE_MSGBOX, "Players used command X", string, "Close", ""); return 1; } } return 1; } stock GetName(playerid); { new szName[MAX_PLAYER_NAME]; GetPlayerName(playerid, szName, sizeof(szName)); return szName; }
Code:
enum cInfo { UsedCmdX1[MAX_PLAYER_NAME], UsedCmdX2[MAX_PLAYER_NAME], UsedCmdX3[MAX_PLAYER_NAME], UsedCmdX4[MAX_PLAYER_NAME], UsedCmdX5[MAX_PLAYER_NAME], TimesCmdXUsed, }; new CommandInfo[cInfo]; CMD:x(playerid, parmas[]) { switch(CommandInfo[TimesCmdXUsed]) { case 0: { CommandInfo[TimesCmdXUsed]++; format(CommandInfo[UsedCmdX1], sizeof(CommandInfo[UsedCmdX1]), "%s", GetName(playerid)); return 1; } case 1: { CommandInfo[TimesCmdXUsed]++; format(CommandInfo[UsedCmdX2], sizeof(CommandInfo[UsedCmdX2]), "%s", GetName(playerid)); return 1; } case 2: { CommandInfo[TimesCmdXUsed]++; format(CommandInfo[UsedCmdX3], sizeof(CommandInfo[UsedCmdX3]), "%s", GetName(playerid)); return 1; } case 3: { CommandInfo[TimesCmdXUsed]++; format(CommandInfo[UsedCmdX4], sizeof(CommandInfo[UsedCmdX4]), "%s", GetName(playerid)); return 1; } case 4: { CommandInfo[TimesCmdXUsed]++; format(CommandInfo[UsedCmdX5], sizeof(CommandInfo[UsedCmdX5]), "%s", GetName(playerid)); return 1; } } return 1; } CMD:names(playerid, parmas[]) { new string[128]; switch(CommandInfo[TimesCmdXUsed]) { case 0: { SendClientMessage(playerid, -1, " No one used command X !"); return 1; } case 1: { format(string, sizeof(string), "1- %s", CommandInfo[UsedCmdX1]); ShowPlayerDialog(playerid, 10, DIALOG_STYLE_MSGBOX, "Players used command X", string, "Close", ""); return 1; } case 2: { format(string, sizeof(string), "1- %s\n2- %s", CommandInfo[UsedCmdX1], CommandInfo[UsedCmdX2]); ShowPlayerDialog(playerid, 10, DIALOG_STYLE_MSGBOX, "Players used command X", string, "Close", ""); return 1; } case 3: { format(string, sizeof(string), "1- %s\n2- %s\n3- %s", CommandInfo[UsedCmdX1], CommandInfo[UsedCmdX2], CommandInfo[UsedCmdX3]); ShowPlayerDialog(playerid, 10, DIALOG_STYLE_MSGBOX, "Players used command X", string, "Close", ""); return 1; } case 4: { format(string, sizeof(string), "1- %s\n2- %s\n3- %s\n4- %s", CommandInfo[UsedCmdX1], CommandInfo[UsedCmdX2], CommandInfo[UsedCmdX3], CommandInfo[UsedCmdX4]); ShowPlayerDialog(playerid, 10, DIALOG_STYLE_MSGBOX, "Players used command X", string, "Close", ""); return 1; } case 5: { format(string, sizeof(string), "1- %s\n2- %s\n3- %s\n4- %s\n5- %s", CommandInfo[UsedCmdX1], CommandInfo[UsedCmdX2], CommandInfo[UsedCmdX3], CommandInfo[UsedCmdX4], CommandInfo[UsedCmdX5]); ShowPlayerDialog(playerid, 10, DIALOG_STYLE_MSGBOX, "Players used command X", string, "Close", ""); return 1; } } return 1; } stock GetName(playerid); { new szName[MAX_PLAYER_NAME]; GetPlayerName(playerid, szName, sizeof(szName)); return szName; } |
And to reset that counting after let's say 5, so that the 6th player will be the 1st again?
|
new CommandCount; CMD:thecommand(playerid,params[]) { new string[60]; CommandCount++; format(string,sizeof(string),"You are number %i in the queue.",CommandCount); SendClientMessage(playerid,-1,string); switch(CommandCount) { case 0: { // do X } case 1: { // do Y } case 2: { // do Z } } return 1; }
Code:
new CommandCount; CMD:thecommand(playerid,params[]) { new string[60]; CommandCount++; format(string,sizeof(string),"You are number %i in the queue.",CommandCount); SendClientMessage(playerid,-1,string); switch(CommandCount) { case 0: { // do X } case 1: { // do Y } case 2: { // do Z } } return 1; } |