Conor wrote:....
You can make a player use a command, or you can use a command directed at a player. There is a difference and I'm not sure which you're talking about. So I'll show you both.
To make a player use a command, you would do the following.
- Code: Select all
public override void Use(Player p, string message)
{
if (String.IsNullOrEmpty(message) || message.IndexOf(' ') != -1) { Help(p); return; }
Player who = Player.Find(message);
if (who == null || who.hidden)
{
Player.SendMessage(p, "Player could not be found.");
return;
}
string commandName = "me";
string commandMessage = "is a smelly monkey.";
Command.all.Find(commandName).Use(who, commandMessage);
}
To use a command, directed at another player (e.g. /kill [other player]) you would do the following.
- Code: Select all
public override void Use(Player p, string message)
{
if (String.IsNullOrEmpty(message) || message.IndexOf(' ') != -1) { Help(p); return; }
Player who = Player.Find(message);
if (who == null || who.hidden)
{
Player.SendMessage(p, "Player could not be found.");
return;
}
string commandName = "kill";
string commandMessage = " was eaten alive by monkeys";
Command.all.Find(commandName).Use(p, who.PublicName + commandMessage);
}
To get the parameters from the command when the player uses the command, instead of having them as stored string variables, you'd have to split the message up using String.Split(' '), or just use the 'message' variable.
namespace MCDzienny
{
public class Cmdkicktban : Command
{
public override string name { get { return "kicktempban"; } }
public override string shortcut { get { return "kt"; } }
public override string type { get { return "mod"; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.Operator; } }
public override void Use(Player p, string message)
{
if (String.IsNullOrEmpty(message) || message.IndexOf(' ') != -1) { Help(p); return; }
Player who = Player.Find(message);
if (who == null || who.hidden)
{
Player.SendMessage(p, "Player could not be found.");
return;
}
string kick = "kick";
string kickMessage = who + " was kicked and is being temp-banned";
string tban = "tempban";
string tbanMessage = who + " is now temp-banned";
Command.all.Find(kick).Use(p, who.PublicName + kickMessage);
Command.all.Find(tban).Use(p, who.PublicName + tbanMessage);
}
string kickMessage = who + " was kicked and is being temp-banned";
Command.all.Find(kick).Use(p, who.PublicName + kickMessage);
string kickMessage = "was kicked and is being temp-banned";
Command.all.Find(kick).Use(p, who.PublicName + kickMessage);
/kick conanza121was kicked and is being temp-banned.
string kickMessage = "was kicked and is being temp-banned";
Command.all.Find(kick).Use(p, who.PublicName + " " + kickMessage);
Leeizazombie wrote:Ohh wow I can't believe it was such an easy mistake xD thanks again :3
Users browsing this forum: No registered users and 1 guest