You have quite a few problems but you are on the right track. I will not correct it all for you as you just need to understand the correct layout and then you can easily go through it yourself
This is how you find and use a command.
Format:Command.all.Find("commandName").Use(Player, "commandParameters");
So, the "commandParameters" will hold a string which will be passed through to the
Command.Use method (which is overrided by the specified command); the Player object is the Player in which the command will be executed from. So if you wanted Player A to use a command on Player B, you would do this:
Command.all.Find("commandName").Use(playerAObject, "playerBName");
You'll find in 90% of simple cases that 'playerAobject' will be 'p' and 'playerBName' will be 'message'.
Some simple examples:- Code: Select all
public override void Use(Player p, string message)
{
// Attempt to use the kick command, the 'message' would need to be a player's name
Command.all.Find("kick").Use(p, message);
// Attempt to ban the player, the 'message' would need to be the player's name
Command.all.Find("ban").Use(p, message);
// Kill the specified player with your own custom message - 'message' would need to be the player's name
Command.all.Find("kill").Use(p, message + " was eaten alive by zombies!");
// Make the other player use a command
// 1. Find the other player
Player who = Player.Find(message);
// 2. Check they exist
if (who == null) { Player.SendMessage(p, "Player could not be found."); return; }
// 3. Execute the command
Command.all.Find("me").Use(who, " was just forced to use a command!");
// The above would cause the player specified to use the 'me' command, as if they were typing themself:
// /me was just forced to use a command!
}
So take note of the correct format and you may find your solution quicker. Also take note that it is
always 'Command.all' - this is a list of all commands (stored as Command objects) inside the Command class. You are searching this list for your command. There are no such lists in the Command class called "one", "two", "three".
Good luck!