Raised This Month: $32 Target: $400
 8% 

[SM] Notices v1.0.2 (Updated: 3/15/12)


Post New Thread Reply   
 
Thread Tools Display Modes
Author
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Plugin ID:
2838
Plugin Version:
1.0.2
Plugin Category:
General Purpose
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Provides a simple interface for relaying news/announcements to a server.
    Old 03-15-2012 , 21:34   [SM] Notices v1.0.2 (Updated: 3/15/12)
    Reply With Quote #1

    Information:
    • This plugin provides an interface allowing server owners to keep players up to date with recent changes in the server/community. You can think of it as an Announcement feature common on most forums.
    • Notice: Requires a SQLite / MySQL database!
      • The default configuration is to access a database "sm_notices", so please make the necessary entry into your databases.cfg.
    Features:
    • Displays up to 256 unique Notices via plugin menu, which can be accessed through one of several defined chat commands such as !news and !notices. An example menu has been provided, as descriptions fall short:
      • Server Announcements:
      • 1) Announcement #1
      • 2) Announcement #2
      • 3) Recent Rule Changes
      • 4) Announcement #4
      • Upon selection, the following information is printed to the client's chat:
        • Admin (who posted the Notice), Date Posted
        • Title
        • Message
    • Provides several admin commands for managing Notices both in-game and via console, restricted to the ROOT flag by default.
    • Translation support so you don't have to worry about recompiling the source to edit phrases.
    • Supports both temporary and permanent Notices. Expired Notices are removed from the database on map change, however, they will not display in-game if they've expired prior to being removed.
    • Supports both global Notices and individual server Notices.
      • Global Notices require an index of 0
      • Individual Notices require an index equal to that of the server's index cvar.
    • Support for displaying an in-game advert X seconds after a player joins a team for the first time (on that connection) to notify user of the command.
    ConVars:
    • sm_notices_enabled: Enables/disables all features of the plugin.
    • sm_notices_index: The server index, allowing for server-specific notices.
    • sm_notices_commands: The chat triggers available to clients to access notices.
    • sm_notices_database: The database to use for the plugin.
    • sm_notices_format_time: Determines the formatting for time and date display. Using "" will default to sm_datetime_format (/cfg/sourcemod.cfg)
    • sm_notices_advert: The number of seconds after a player joins an initial team for an advert to be sent about the plugin. (0.0 = Disabled)
    Admin Commands:
    • sm_listnotices <server : optional>:Prints all Notices to the admin's console; can be constrained to a specific sm_notices_index server.
    • sm_delnotice <index>: Deletes a specific Notice from the database.
    • sm_getnotice <index>: Prints a specific Notice to the admin's console.
    • sm_addnotice <server> <duration : minutes> <"Notice Title"> <"Notice Message">: Adds a new Notice to the database.
      • <server>: Can be 0 for all servers using the same database, or a specific sm_notices_index.
      • <duration>: Can be 0 for a permanent Notice, otherwise the number of minutes the Notice lasts.
      • <"Notice Title"> and <"Notice Message"> MUST be enclosed with quotation marks!
    • sm_loadnotices: Re-loads Notices from the database to the specific server; this is done automatically on Map Change, but if changes are made in-game prior to map change, this command must be used to see changes.
    Getting Started:
    • After the plugin is installed, and a functional database connection has been created (i.e. an entry in databases.cfg and a map change / server restart), the plugin is ready for usage. However, without overrides, only ROOT administrators can access the administrative features of the plugin.
    • To create a Notice, run sm_addnotice <parameters:see above>. You can confirm the entry of the Notice by running sm_getnotice <index>, where the <index> parameter is printed to you after adding a notice. If you lose the <index>, you can run sm_listnotices and all the necessary information will be printed to your console. If you make a mistake, you'll need to run sm_delnotice <index> and re-create it.Once satisfied, run sm_loadnotices to sync the server with the database.
    • The "Admin" responsible for adding a notice is defined by the Admin's Username (you can see this in-game by using sm_who). The default options for Console, and Admins without Usernames, can be configured in the Translations.
    Attached Files
    File Type: txt sm_notices.phrases.txt (2.9 KB, 558 views)
    File Type: cfg sm_notices.cfg (1.1 KB, 515 views)
    File Type: smx sm_notices.smx (17.7 KB, 480 views)
    File Type: sp Get Plugin or Get Source (sm_notices.sp - 434 views - 22.7 KB)
    __________________

    Last edited by thetwistedpanda; 07-12-2012 at 15:00.
    thetwistedpanda is offline
    Mitchell
    ~lick~
    Join Date: Mar 2010
    Old 03-15-2012 , 21:47   Re: [SM] Notices
    Reply With Quote #2

    Pretty Useful.
    Mitchell is offline
    Fearts
    ferts of daeth
    Join Date: Oct 2008
    Old 03-15-2012 , 23:38   Re: [SM] Notices v1.0.1 (Updated: 3/15)
    Reply With Quote #3

    Very nice. Here is some bacon for your troubles

    I am not sure what the timer does though. I did:

    sm_addnotice 0 .2 "Test Notice" "Let see what this does"

    Then I used: sm_loadnotices

    Then I typed !news and it shows the notice.

    I waited 30 seconds and changed the map. I typed !news and the notice is still there. Shouldn't it have been deleted?

    EDIT:

    Oh I see it wont let me use .2 only whole numbers.

    EDIT2:

    ] sm_addnotice 0 1 "Test Notice" "Let see what this does"
    News: Notice successfully entered into database under index 6!
    ] sm_getnotice 6
    News: The requested notice has been printed to your console.
    News: Server: 0, Issued: 03/15/12, Admin: Admin, Duration: 60 minutes.

    Shouldn't this be 1 minute not 60 minutes?

    EDIT3:

    sm_delnotice removes the notice from the menu but not the database as stated.
    __________________

    Last edited by Fearts; 03-15-2012 at 23:50.
    Fearts is offline
    thetwistedpanda
    Good Little Panda
    Join Date: Sep 2008
    Old 03-15-2012 , 23:43   Re: [SM] Notices v1.0.1 (Updated: 3/15)
    Reply With Quote #4

    Indeed, only integers allowed for the duration. I wrote it to notify my players of recent rule / server changes, so I expected durations of at least 10080 (a week). Notices that expire within a minute are a bit useless since very very few would ever see them.

    *Edit for your edit*
    Hmm, a minor bug that doesn't affect the plugin, I'll resolve it in 1.0.2. I forgot to divide the display by 60 in sm_getnotice.
    __________________

    Last edited by thetwistedpanda; 03-16-2012 at 00:05.
    thetwistedpanda is offline
    Fearts
    ferts of daeth
    Join Date: Oct 2008
    Old 03-15-2012 , 23:52   Re: [SM] Notices v1.0.1 (Updated: 3/15)
    Reply With Quote #5

    So the notice duration wont print less than 60 mins? I mean it says 60 minutes but it is only 1 minute and only lasts 1 minute in the menu as well.

    Also please read EDIT3 that same issue is also present when the notice duration is over. Notices never get removed from the database only the menu.

    EDIT:

    Also I don't understand this:

    "Displays up to 256 unique Notices"

    Why only 256 where does that number come from?
    __________________

    Last edited by Fearts; 03-15-2012 at 23:54.
    Fearts is offline
    thetwistedpanda
    Good Little Panda
    Join Date: Sep 2008
    Old 03-15-2012 , 23:54   Re: [SM] Notices v1.0.1 (Updated: 3/15)
    Reply With Quote #6

    As for Edit #3, notices are not removed automatically from the database when they expire. This is intentional. They are only removed on map change once detected to be expired. I wanted to avoid potential mid-game queries. 1.0.2 (already fixed it, will upload tomorrow after more feedback arrives) correctly divides sm_getnotice / sm_listnotices duration by 60, so that the duration parameter displays a minute value, rather than seconds.

    *Edit for your edit*
    The plugin needed a hardcoded limit as I wasn't about to mess with a slew of dynamic arrays for a plugin such as this. It's completely unnecessary. So I just limited the variables to 256, but the plugin can easily be recompiled to support any amount. If a community more than 30 Notices though, they're failing at something.
    __________________

    Last edited by thetwistedpanda; 03-16-2012 at 00:04.
    thetwistedpanda is offline
    Fearts
    ferts of daeth
    Join Date: Oct 2008
    Old 03-16-2012 , 00:11   Re: [SM] Notices v1.0.1 (Updated: 3/15)
    Reply With Quote #7

    OK, I did a little more testing.

    sm_delnotice # deletes the notice from the database. However, it does not reset the notice count. Right now I am up to notice #9 even though all the other notices are deleted. The notice number keeps going up even though the old notices have been removed. I don't know if this was intended but I can see this becoming quite confusing.

    Map changing does not remove from the database:

    Code:
    ] sm_addnotice 0 1 "Test Notice" "Let see what this does"
    News: Notice successfully entered into database under index 10!
    ] sm_loadnotices 
    ] sm_getnotice 10
    News: The requested notice has been printed to your console.
    News: Server: 0, Issued: 03/16/12, Admin: Admin, Duration: 60 minutes.
    News: Title: Test Notice
    News: Message: Let see what this does
    
    WAITED 1 MINUTE
    
    ] sm_map ba_jail_electric_razor_v6
    [SM] Changing map to ba_jail_electric_razor_v6...
    
    Counter-Strike: Source
    Map: ba_jail_electric_razor_v6
    Players: 1 / 12
    Build: 4833
    Server Number: 4
    
    No pure server whitelist. sv_pure = 0
    Fire ̷̨●̷̨° connected.
    
    ] sm_listnotices 
    News: There are no notices in the database.
    ] sm_getnotice 10
    News: The requested notice has been printed to your console.
    News: Server: 0, Issued: 03/16/12, Admin: Admin, Duration: 60 minutes.
    News: Title: Test Notice
    News: Message: Let see what this does
    __________________

    Last edited by Fearts; 03-16-2012 at 00:12.
    Fearts is offline
    thetwistedpanda
    Good Little Panda
    Join Date: Sep 2008
    Old 03-16-2012 , 00:13   Re: [SM] Notices v1.0.1 (Updated: 3/15)
    Reply With Quote #8

    The index corresponding to the Notice isn't supposed to reset. I'm being cheap and using the AUTOINCREMENT/AUTO_INCREMENT parameter provided by SQLite/MySQL, so that the notices always have a unique index.

    I wanted to wait until tomorrow to fix that bug in 1.0.1 but it seems that the inability to automatically delete expired Notices is a bit more important. Botched code from 1.0.0 to 1.0.1 so that it wasn't pruning properly.

    Revision 1.0.2

    ----------------
    • Added cvar sm_notices_order, which allows choice between ascending/descending ordering for the Notice menu.
    • Fixed a minor display bug with sm_getnotice, / sm_listnotices where Duration showed a value in seconds rather than minutes.
    • Fixed an issue with Notices not expiring automatically on map change where applicable.
    __________________

    Last edited by thetwistedpanda; 03-16-2012 at 00:18.
    thetwistedpanda is offline
    Fearts
    ferts of daeth
    Join Date: Oct 2008
    Old 03-16-2012 , 00:30   Re: [SM] Notices v1.0.2 (Updated: 3/15)
    Reply With Quote #9

    Everything seems to be in working order now. The sm_notices_order was a good idea. I don't like that the number doesn't reset but it isn't that big of a deal since you have the sm_listnotices command.

    The only other error (if it is indeed a error) is that it doesn't display the name of the notice poster.

    News: Posted by Admin on 03/16/12
    News: "Test Notice4"
    News: Let see what this does

    ^Says posted by Admin not posted by Fire.

    ] sm_getnotice 4
    News: The requested notice has been printed to your console.
    News: Server: 0, Issued: 03/16/12, Admin: Admin, Duration: 1 minutes.

    ^Says Admin: Admin, I assume it is supposed to say Admin: Fire.

    Very nice work I will be using this on my servers and thanks for the quick updates.
    __________________
    Fearts is offline
    thetwistedpanda
    Good Little Panda
    Join Date: Sep 2008
    Old 03-16-2012 , 00:34   Re: [SM] Notices v1.0.2 (Updated: 3/15)
    Reply With Quote #10

    *Edit for clarity*

    The plugin uses GetAdminUsername to determine the name when adding a Notice. If no username is set, if the user doesn't have admin, or if the user is console, then it defaults to the pre-defined values located in the translation file. I do not use the player's in-game name since that always changes.

    As for the number not resetting, it would require far more work to maintain the number myself than letting SQLite/MySQL do it for me. The List command was written to provide a means to identify the indexes.
    __________________

    Last edited by thetwistedpanda; 03-16-2012 at 00:42.
    thetwistedpanda is offline
    Reply



    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 23:36.


    Powered by vBulletin®
    Copyright ©2000 - 2024, vBulletin Solutions, Inc.
    Theme made by Freecode