Thread: Msg (Very simple plugin to display a message every x seconds)

Results 1 to 19 of 19
  1. #1
    incognico nico's Avatar
    Join Date
    Aug 2015
    Posts
    440

    Msg (Very simple plugin to display a message every x seconds)

    Because someone was asking for it. A very simple plugin to display a custom message every x seconds:

    Add to: svencoop/default_plugins.txt
    Code:
    "plugin"
            {
                    "name" "Msg"
                    "script" "admin/Msg"
                    "concommandns" "msg"
            }
    Download & Save as: svencoop_addon/scripts/plugins/admin/Msg.as

    Add to: svencoop/server.cfg
    Code:
    as_command msg.msg "lol some cool text to display every msg.interval seconds"
    as_command msg.interval 120
    Note that there is no error checking in the script, so don't set interval to 0 or weird stuff like text.
    Last edited by nico; 02-06-2016 at 03:30 AM.

  2. #2
    Registered User AntonivkA's Avatar
    Join Date
    Jan 2016
    Location
    Odessa, Ukraine
    Posts
    14

    Re: Msg (Very simple plugin to display a message every x seconds)

    not work.

  3. #3
    incognico nico's Avatar
    Join Date
    Aug 2015
    Posts
    440

    Re: Msg (Very simple plugin to display a message every x seconds)

    Quote Originally Posted by AntonivkA View Post
    not work.
    Sorry, a typo slipped in. Should work now.

  4. #4
    Registered User AntonivkA's Avatar
    Join Date
    Jan 2016
    Location
    Odessa, Ukraine
    Posts
    14

    Re: Msg (Very simple plugin to display a message every x seconds)

    work fine, thanks =)

  5. #5
    triggered Cadaver's Avatar
    Join Date
    Mar 2016
    Location
    Argentina
    Posts
    76

    Re: Msg (Very simple plugin to display a message every x seconds)

    Isn't working i need to exec the server.cfg before?



  6. #6
    incognico nico's Avatar
    Join Date
    Aug 2015
    Posts
    440

    Re: Msg (Very simple plugin to display a message every x seconds)

    Quote Originally Posted by Cadaver View Post
    Isn't working i need to exec the server.cfg before?
    If you just (re)loaded the script it should display the default message until you exec server.cfg or had for a mapchange. This is why dedicated server users should always start the server with the map _server_start, to allow plugins to initialize.

  7. #7
    triggered Cadaver's Avatar
    Join Date
    Mar 2016
    Location
    Argentina
    Posts
    76

    Re: Msg (Very simple plugin to display a message every x seconds)

    Thanks, works perfect



  8. #8
    Registered User Joce's Avatar
    Join Date
    Feb 2016
    Location
    Paris
    Posts
    96

    Re: Msg (Very simple plugin to display a message every x seconds)

    How if I want to add more than 1 message ? Do I have to write the "as_commands" like this ?

    as_command msg.msg "Message 1"
    as_command msg.interval "xx"
    as_command msg.msg "Message 2"
    as_command msg.interval "xx"

    Thanks

  9. #9
    200 MB Angelscript log file KernCore's Avatar
    Join Date
    Apr 2016
    Location
    Brazil
    Posts
    265

    Re: Msg (Very simple plugin to display a message every x seconds)

    Quote Originally Posted by Joce View Post
    How if I want to add more than 1 message ? Do I have to write the "as_commands" like this ?

    as_command msg.msg "Message 1"
    as_command msg.interval "xx"
    as_command msg.msg "Message 2"
    as_command msg.interval "xx"

    Thanks
    I think you mean a way for the plugin to switch messages from time to time right? I think I can do that.

  10. #10
    Registered User Joce's Avatar
    Join Date
    Feb 2016
    Location
    Paris
    Posts
    96

    Re: Msg (Very simple plugin to display a message every x seconds)

    Quote Originally Posted by KernCore View Post
    I think you mean a way for the plugin to switch messages from time to time right? I think I can do that.
    This is exactly what I want

  11. #11
    200 MB Angelscript log file KernCore's Avatar
    Join Date
    Apr 2016
    Location
    Brazil
    Posts
    265

    Re: Msg (Very simple plugin to display a message every x seconds)

    Quote Originally Posted by Joce View Post
    This is exactly what I want
    Here you go, I was developing something similiar for HLDM-BR.net.

    Code:
    CCVar@ g_Msg;
    CCVar@ g_Msg2;
    CCVar@ g_Interval;
    
    CScheduledFunction@ g_pThinkFunc = null;
    
    void PluginInit()
    {
    	g_Module.ScriptInfo.SetAuthor( "animaliZed" );
    	g_Module.ScriptInfo.SetContactInfo( "irc://irc.rizon.net/#/dev/null" );
    	g_Module.ScriptInfo.SetMinimumAdminLevel( ADMIN_YES );
    
    	@g_Msg = CCVar( "msg", "Please configure msg.msg", "The text to display", ConCommandFlag::AdminOnly );
    	@g_Msg2 = CCVar( "msg2", "Please configure msg.msg2", "The text to display", ConCommandFlag:: AdminOnly );
    	@g_Interval = CCVar( "interval", 421.0f, "Repeat every x seconds", ConCommandFlag::AdminOnly );
    }
    
    void MapInit()
    {
    	if( g_pThinkFunc !is null ) 
    		g_Scheduler.RemoveTimer( g_pThinkFunc );
    
    	@g_pThinkFunc = g_Scheduler.SetInterval( "msgthink", g_Interval.GetFloat() );
    }
    
    void msgthink()
    {
    	switch( Math.RandomLong( 0, 1 ) )
    	{
    		case 0:
    		{
    			g_PlayerFuncs.ClientPrintAll( HUD_PRINTTALK, g_Msg.GetString() + "\n" );
    			g_PlayerFuncs.ClientPrintAll( HUD_PRINTCONSOLE, g_Msg.GetString() + "\n" );
    			break;
    		}
    		case 1:
    		{
    			g_PlayerFuncs.ClientPrintAll( HUD_PRINTTALK, g_Msg2.GetString() + "\n" );
    			g_PlayerFuncs.ClientPrintAll( HUD_PRINTCONSOLE, g_Msg2.GetString() + "\n" );
    			break;
    		}
    	}
    }
    It will add one line of command tho, you'll need to set as_command msg.msg and as_command msg.msg2. And it will automatically display one of them in the chat and in the console as well.

    A screenshot of it in action:

  12. #12
    Registered User Joce's Avatar
    Join Date
    Feb 2016
    Location
    Paris
    Posts
    96

    Re: Msg (Very simple plugin to display a message every x seconds)

    Quote Originally Posted by KernCore View Post
    Here you go, I was developing something similiar for HLDM-BR.net.

    Code:
    CCVar@ g_Msg;
    CCVar@ g_Msg2;
    CCVar@ g_Interval;
    
    CScheduledFunction@ g_pThinkFunc = null;
    
    void PluginInit()
    {
    	g_Module.ScriptInfo.SetAuthor( "animaliZed" );
    	g_Module.ScriptInfo.SetContactInfo( "irc://irc.rizon.net/#/dev/null" );
    	g_Module.ScriptInfo.SetMinimumAdminLevel( ADMIN_YES );
    
    	@g_Msg = CCVar( "msg", "Please configure msg.msg", "The text to display", ConCommandFlag::AdminOnly );
    	@g_Msg2 = CCVar( "msg2", "Please configure msg.msg2", "The text to display", ConCommandFlag:: AdminOnly );
    	@g_Interval = CCVar( "interval", 421.0f, "Repeat every x seconds", ConCommandFlag::AdminOnly );
    }
    
    void MapInit()
    {
    	if( g_pThinkFunc !is null ) 
    		g_Scheduler.RemoveTimer( g_pThinkFunc );
    
    	@g_pThinkFunc = g_Scheduler.SetInterval( "msgthink", g_Interval.GetFloat() );
    }
    
    void msgthink()
    {
    	switch( Math.RandomLong( 0, 1 ) )
    	{
    		case 0:
    		{
    			g_PlayerFuncs.ClientPrintAll( HUD_PRINTTALK, g_Msg.GetString() + "\n" );
    			g_PlayerFuncs.ClientPrintAll( HUD_PRINTCONSOLE, g_Msg.GetString() + "\n" );
    			break;
    		}
    		case 1:
    		{
    			g_PlayerFuncs.ClientPrintAll( HUD_PRINTTALK, g_Msg2.GetString() + "\n" );
    			g_PlayerFuncs.ClientPrintAll( HUD_PRINTCONSOLE, g_Msg2.GetString() + "\n" );
    			break;
    		}
    	}
    }
    It will add one line of command tho, you'll need to set as_command msg.msg and as_command msg.msg2. And it will automatically display one of them in the chat and in the console as well.

    A screenshot of it in action:
    Thank you very much. Do I have to write the messages in the code itself or in server.cfg ?
    Last edited by Joce; 07-06-2016 at 04:29 AM. Reason: mistake

  13. #13
    200 MB Angelscript log file KernCore's Avatar
    Join Date
    Apr 2016
    Location
    Brazil
    Posts
    265

    Re: Msg (Very simple plugin to display a message every x seconds)

    Quote Originally Posted by Joce View Post
    Thank you very much. Do I have to writer the messages in the code itself or in server.cfg ?
    I think it's recommended to write in the cfg.

    Code:
    as_command msg.msg "The First Msg goes here"
    as_command msg.msg2 "The Second Msg goes here"
    as_command msg.interval The timer in seconds

  14. #14
    Registered User Joce's Avatar
    Join Date
    Feb 2016
    Location
    Paris
    Posts
    96

    Re: Msg (Very simple plugin to display a message every x seconds)

    Quote Originally Posted by KernCore View Post
    I think it's recommended to write in the cfg.

    Code:
    as_command msg.msg "The First Msg goes here"
    as_command msg.msg2 "The Second Msg goes here"
    as_command msg.interval The timer in seconds
    In my server.cfg:


    as_command msg.msg "Want to add some funs ? Type Glow *color* /// Trail *color*"
    as_command msg.msg2 "This server is running with Angelscript's plugins"
    as_command msg.interval "60"

    But i have a problem with msg2:



    the second line does not appear

  15. #15
    200 MB Angelscript log file KernCore's Avatar
    Join Date
    Apr 2016
    Location
    Brazil
    Posts
    265

    Re: Msg (Very simple plugin to display a message every x seconds)

    Quote Originally Posted by Joce View Post
    In my server.cfg:


    as_command msg.msg "Want to add some funs ? Type Glow *color* /// Trail *color*"
    as_command msg.msg2 "This server is running with Angelscript's plugins"
    as_command msg.interval "60"

    But i have a problem with msg2:



    the second line does not appear
    What you can do to fix this is modifying the script it self. Like this:

    Code:
    @g_Msg = CCVar( "msg", "Want to add some funs ? Type Glow *color* /// Trail *color*", "The text to display", ConCommandFlag::AdminOnly );
    @g_Msg2 = CCVar( "msg2", "This server is running with Angelscript's plugins", "The text to display", ConCommandFlag:: AdminOnly );
    By doing this setting the msg.msg/msg.msg2 in the server.cfg is not necessary anymore.

  16. #16
    Registered User Joce's Avatar
    Join Date
    Feb 2016
    Location
    Paris
    Posts
    96

    Re: Msg (Very simple plugin to display a message every x seconds)

    Thanks, i wasn't sure.

  17. #17
    Registered User Joce's Avatar
    Join Date
    Feb 2016
    Location
    Paris
    Posts
    96

    Re: Msg (Very simple plugin to display a message every x seconds)

    Hi,

    I used this plugin for months now, thanks.

    Now i need a third message, it is possible ? I tried to edit the script the way you did for Msg2 but it didn't work :>

  18. #18
    Server Owner Enrory's Avatar
    Join Date
    Dec 2016
    Location
    Austria
    Posts
    109

    Re: Msg (Very simple plugin to display a message every x seconds)

    Can someone update this plugin pls?
    maybe for more msgs.

    have a nice day

  19. #19
    Registered User
    Join Date
    Aug 2018
    Posts
    1

    Re: Msg (Very simple plugin to display a message every x seconds)

    Quote Originally Posted by Enrory View Post
    Can someone update this plugin pls?
    maybe for more msgs.

    have a nice day
    +1 it would be nice

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •