Jump to content
  • Sign Up

Archived

This topic is now archived and is closed to further replies.

  • 1
kilgorezer

Global Chat Messages

Question

5 answers to this question

Recommended Posts

I am confused, It keeps giving me a error in my code.

Can someone help me?

(It is supposed to send a message between two IRCs)

//    Auto-generated command skeleton class
//    Use this as a basis for custom MCGalaxy commands
//    Naming should be kept consistent (e.g. /update command should have a class name of 'CmdUpdate' and a filename of 'CmdUpdate.cs')
// As a note, MCGalaxy is designed for .NET 4.0

// To reference other assemblies, put a "//reference [assembly filename]" at the top of the file
//   e.g. to reference the System.Data assembly, put "//reference System.Data.dll"

// Add any other using statements you need after this
using System;
using MCGalaxy;

public class CmdSendtomegs : Command
{
    // The command's name (what you put after a slash to use this command)
    public override string name { get { return "Sendtomegs"; } }

    // Command's shortcut, can be left blank (e.g. "/Copy" has a shortcut of "c")
    public override string shortcut { get { return ""; } }

    // Which submenu this command displays in under /Help
    public override string type { get { return "other"; } }

    // Whether or not this command can be used in a museum. Block/map altering commands should return false to avoid errors.
    public override bool museumUsable { get { return true; } }

    // The default rank required to use this command. Valid values are:
    //   LevelPermission.Guest, LevelPermission.Builder, LevelPermission.AdvBuilder,
    //   LevelPermission.Operator, LevelPermission.Admin, LevelPermission.Owner
    public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }

    // This is for when a player executes this command by doing /Sendtomegs
    //   p is the player object for the player executing the command. 
    //   message is the arguments given to the command. (e.g. for '/Sendtomegs this', message is "this")
    public override void Use(Player p, string message)
    {
        Chat.GlobalMessage(".x " + message);
    }

    // This is for when a player does /Help Sendtomegs
    public override void Help(Player p)
    {
        p.Message("/Sendtomegs - Sends a command to megs server");
    }
}

Share this post


Link to post
4 minutes ago, kilgorezer said:

I am confused, It keeps giving me a error in my code.

Can someone help me?

(It is supposed to send a message between two IRCs)

//    Auto-generated command skeleton class
//    Use this as a basis for custom MCGalaxy commands
//    Naming should be kept consistent (e.g. /update command should have a class name of 'CmdUpdate' and a filename of 'CmdUpdate.cs')
// As a note, MCGalaxy is designed for .NET 4.0

// To reference other assemblies, put a "//reference [assembly filename]" at the top of the file
//   e.g. to reference the System.Data assembly, put "//reference System.Data.dll"

// Add any other using statements you need after this
using System;
using MCGalaxy;

public class CmdSendtomegs : Command
{
    // The command's name (what you put after a slash to use this command)
    public override string name { get { return "Sendtomegs"; } }

    // Command's shortcut, can be left blank (e.g. "/Copy" has a shortcut of "c")
    public override string shortcut { get { return ""; } }

    // Which submenu this command displays in under /Help
    public override string type { get { return "other"; } }

    // Whether or not this command can be used in a museum. Block/map altering commands should return false to avoid errors.
    public override bool museumUsable { get { return true; } }

    // The default rank required to use this command. Valid values are:
    //   LevelPermission.Guest, LevelPermission.Builder, LevelPermission.AdvBuilder,
    //   LevelPermission.Operator, LevelPermission.Admin, LevelPermission.Owner
    public override LevelPermission defaultRank { get { return LevelPermission.Admin; } }

    // This is for when a player executes this command by doing /Sendtomegs
    //   p is the player object for the player executing the command. 
    //   message is the arguments given to the command. (e.g. for '/Sendtomegs this', message is "this")
    public override void Use(Player p, string message)
    {
        Chat.GlobalMessage(".x " + message);
    }

    // This is for when a player does /Help Sendtomegs
    public override void Help(Player p)
    {
        p.Message("/Sendtomegs - Sends a command to megs server");
    }
}

"Args" is a string not string array

Share this post


Link to post
14 minutes ago, Rulja1234 said:

Chat.GlobalMessage(message);

 

2 minutes ago, Rulja1234 said:

"Args" is a string not string array

The error is

(20:34:13) Error #CS0117 on line 37 - `MCGalaxy.Chat' does not contain a definition for `GlobalMessage'
(20:34:13) Compiling failed. See logs/errors/compiler.log for more detail

Share this post


Link to post

Use Chat.MessageChat(p, ".x " + message, null, true);
The last arg true means it sends to discord/irc, false means it stays in-game only.
 

Share this post


Link to post

×
×
  • Create New...