How can I detect the players that used X command?
#5

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;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)