Message-Plugin Version 0.2


  • Thanks to @Metachronism, I was able to create a mod/Plugin that sends a message to the server every nth minute. I did not use the EcoModKit to create this. I based it off AdminChatCommands.cs. Also as this place is for discussion of modding, if this is not the correct place to post plugins/mods, please move it to the right forum section.

    What is it?
    This is a small plugin that will auto send a message to your server every nth minute. You are able to change the time and message (as of Version 0.1) in MOTD.cs file on line 15 (for time) and line 14 for the message. Version 0.2 will include changing of the file time and message via commands. This plugin can be used to inform people what your team speak or discord channel is. It can also be used for a motd to be sent out every so often to remind people about things. The possibilities are endless.

    Please note that time is in milliseconds. 300000 ms = 5 minutes. So every 5 minutes the message is sent to everyone connected to your server.

    Features of Version 0.1:

    • Enable and Disable the automatic play of the message.
    • Uses commands to start and stop
    • Message is hard coded. You must edit the MOTD.cs file to change message.

    How to install and Use:
    Download attached file. Place MOTD.cs into the server folder/Mods/Misc. Once placed in the Misc folder restart server. This will enable the mod and compile it.

    Make sure you are flagged as an admin via the server. If you are not an admin the command will not work. Once flagged as an admin type /motd-on to enable the message. to disable it type /motd-off. The method of how to start and stop is not set in stone and could eventually change.

    Download
    MOTD.cs - Version 0.2
    @R4mbo Version - R4mbo Version (Check out his post about his version)

    Known Issues:
    None:

    Features to come:

    • Change the interval time via command
    • Change the MOTD via command
    • Save new MOTD to file
    • Load MOTD from file

    Thanks again to the following who helped me out throughout the process of making this small plugin.
    Metachronism
    @NoBlackThunder - for helping with the known error.

    Living to Ride, Riding to Live


  • 8
    Posts
    2748
    Views
    Log in to reply


  • did a quick look at your code.

    case "motdenable":
    var enable = args;

                if(enable == "1")
                {
                    // Lets call enable the MOTD
                    enableMOTD();
                }
                else
                {
                    // Lets disable it.
                    disableMOTD();
                }
                
                return true;
    

    i suspect the issue you get with object refference might be that args = null. and therfor you dont have an instance of that object ? .. you could try do do the following :

        switch (command)
        {
            case "motdenable":
                var enable = "0";
    
                if (!string.IsNullOrEmpty(args))
                    enable = args;
    
                if(enable == "1")
                {
                    // Lets call enable the MOTD
                    enableMOTD();
                }
                else
                {
                    // Lets disable it.
                    disableMOTD();
                }
                
                return true;
        }
    
        return false;
    

    maybe that helps?



  • @NoBlackThunder that is most likely the issue. I'll get that updated and tested and push out an update if correct.

    EDIT: V.0.2 is out for the fix with the error. As of now there are no more errors.

    Living to Ride, Riding to Live



  • I just wanted to post a small update since its been about a week since I last uploaded anything.

    Version 0.3 is coming a long nice. I've added in support for loading messages via txt file along with them getting rotated ever 5 minutes or so. (I forgot what the default time span I've set.). With Version 0.3 the commands have changed again. I'm also working on creating config xml file instead of a txt document so it can also hold the amount of time to pass before the next message is sent in the queue. This is no longer a MOTD mod. This is more of a random message mod now.

    The Doctor

    Living to Ride, Riding to Live



  • Greetings, Doc!

    I just updated your MOTD script.

    Usage:
    /motd-on = Activates MOTD and loads the messages from specified path
    /motd-off = Deactivates MOTD

    /motd-list = Show all Messages (Includes INDEX)
    Example for motd-list Output:
    0 Welcome!
    1 Test123
    2 Have Fun!

    /motd-remove X = Remove Message with INDEX X
    For example: /motd-remove 1 = Remove message Test123
    List will be saved after that.

    /motd-add MESSAGE
    Will add a Message to the List and save it.

    You can edit the Savepath if you open the Modfile with Notepad++
    Mod will crash the client if you do typing mistakes, for example: /motd-remove cwafasfa
    Handle with Care!

    MOTD.cs

    Do you like my mods? I would be thankful for a small donation^^.
    ETH: 0x24d8FCA487EF62d58f0e926c4c7E21B3ca10f782
    Doge: DQrTnvtf8qPe6dzCLZUpbkEAC1DfAsmzHN
    Eco-Coin: EqQQEGe89dgG3F9893rODI (just joking)



  • Ah yea, it can handle multiple messages now.

    Do you like my mods? I would be thankful for a small donation^^.
    ETH: 0x24d8FCA487EF62d58f0e926c4c7E21B3ca10f782
    Doge: DQrTnvtf8qPe6dzCLZUpbkEAC1DfAsmzHN
    Eco-Coin: EqQQEGe89dgG3F9893rODI (just joking)



  • @R4mbo

    Nice additions. I'll have to get back into playing ECO. I took a break for college and work. I'll add your version to the main post.

    Living to Ride, Riding to Live



  • Hi,

    I am hosting a Server with Pingperfect and tried it as you said. Unfortunately it has not worked.

    Could it be a problem with Version Alpha 5.5.4 or with the fact that I am hosting with a Server provider?

    Thanks for your help.

    Greetings,

    Mosin


8
Posts
2748
Views
Log in to reply

Internal error.

Oops! Looks like something went wrong!