On_Command

Sep 18, 2015
On_Command
  • Method:
    On_Command

    Argument(s):
    1: Fougerite.Player Player
    2: Commands command
    3: Args[] args

    Examples:
    Python:

    Code (Python):
    def On_Command(self, Player, cmd, args):
        if cmd == "announce":
            if len(args) == 0:
                Player.Message("Specify a message!")
            elif len(args) > 0:
                Server.Broadcast(str.join(" ", args))
     
    Javascript:
    Code (Javascript):
    function On_Command(Player, cmd, args) {
        if (cmd == "announce") {
            if (args.Length == 0) {
                Player.Message("Specify a message!");
            }
            else if (args.Length > 0) {
                Server.Broadcast(args.join());
            }
        }
    }

    C#:
    Code (C#):
    public override void Initialize()
    {
         Hooks.OnCommand += CommandHandler;
    }

    public override void DeInitialize()
    {
         Hooks.OnCommand -= CommandHandler;
    }
    Code (C#):
    public void CommandHandler(Fougerite.Player Player, string cmd, string[] args)
    {
         if (cmd == "announce")
         {
              if (args.Length > 0){
              {
                   Server.GetServer().Broadcast(string.Join(" ", args));
              }
              else
              {
                   Player.Message("Specify a message!");
              }
         }
    }