Raised This Month: $12 Target: $400
 3% 

[TF2] Workshop Map Collection Support (2018.12.19-1, 2018-12-19)


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Breadpudding
New Member
Join Date: Nov 2018
Plugin ID:
6325
Plugin Version:
2019.12.19-1
Plugin Category:
Server Management
Plugin Game:
Team Fortress 2
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Adds the tf_workshop_map_collection command Valve should have added
    Old 11-02-2018 , 00:39   [TF2] Workshop Map Collection Support (2018.12.19-1, 2018-12-19)
    Reply With Quote #1

    I'm the owner of a TF2 server and I find it annoying to type all those workshop/id lines just to get the maps to load from the workshop. So I offer a solution: tf_workshop_mapcycle_collection. Now all you have to do is create a collection, add the command to your server.cfg, and you can now add/remove maps to/from your server from the workshop! Hope this helps you like it helped me! ~Breadpudding

    How to use

    Code:
    tf_workshop_mapcycle_collection <id of collection>
    Example:
    Code:
    tf_workshop_mapcycle_collection 1554125608
    Changelog

    Quote:
    2018-12-19 (v2018.12.19-1)

    - Removed sm-json as a dependency
    * Changed the response format from JSON to VDF
    + Added tf_workshop_mapcycle_collection

    2018-11-02 (v2018.11.2-2)

    * An emergency fix of everything I couldn't comprehend at one in the morning.

    2018-11-02 (v2018.11.2)

    * Initial release.
    Installation
    1. Download the SteamWorks extension and install it to your server if you haven't already.
    2. Then copy the plugin into the sourcemod/plugins folder
    3. Congratulations, you can now use the tf_workshop_mapcycle_collection command!

    Dependencies

    Plans

    Nothing right now.

    Media



    GitHub: https://github.com/cbpudding/tf_workshop_map_collection
    Submit issues here: https://github.com/cbpudding/tf_work...lection/issues
    Attached Files
    File Type: sp Get Plugin or Get Source (mapcollection.sp - 331 views - 5.5 KB)
    File Type: smx mapcollection.smx (6.3 KB, 342 views)

    Last edited by Breadpudding; 12-19-2018 at 13:05. Reason: Changed the intro paragraph to reflect the changes made in the latest version
    Breadpudding is offline
    nosoop
    Veteran Member
    Join Date: Aug 2014
    Old 11-08-2018 , 04:00   Re: [TF2] Workshop Map Collection Support (2018.11.2-2, 2018-11-02)
    Reply With Quote #2

    Hi there! Congrats on your first plugin release.

    Just looked at the plugin; you're definitely leaking obj. What you'll want to do is not assign any JSON_Object handles back to obj, as you need to call Cleanup() on the initial handle after you're done with the loop. Instead, you should assign them to separate JSON_Object handles (which I think you don't need to clean up as they're nested objects). Haven't looked at the JSON library, but I think you can also chain the getters together like so:

    Code:
    JSON_Object collectionEntry = obj.GetObject("response").GetObject("collectiondetails").GetObjectIndexed(0);
    collectionEntry.GetString("publishedfileid", id, sizeof(id));
    JSON_Object collectionItems = collectionEntry.GetObject("children");
    You're also leaking item since you instantiate an initial JSON_Object and then assign a new handle in the loop (the original gets lost entirely). Declare JSON_Object item in the loop, the cleanup routines should be fine.

    I think it's an odd choice to have tf_workshop_map_collection as a command instead of a ConVar, but I suppose the command would work just fine.

    All that said, I'm curious; what use case does this plugin serve? In my experience, Workshop maps are already synced from the file referenced in mapcyclefile, and you can sm_map workshop/any_valid_workshop_map_id or changelevel and the server will change to it without performing any prior syncing (though of course it may need to download the map in that case).

    (Disclaimer: I wrote py-mapcyclefile and its successor workshopmaps.py to automate syncing Workshop collections into my map cycles.)
    __________________
    I do TF2, TF2 servers, and TF2 plugins.
    I don't do DMs over Discord -- PM me on the forums regarding inquiries.
    AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)
    nosoop is offline
    Breadpudding
    New Member
    Join Date: Nov 2018
    Old 11-14-2018 , 18:10   Re: [TF2] Workshop Map Collection Support (2018.11.2-2, 2018-11-02)
    Reply With Quote #3

    Quote:
    Originally Posted by nosoop View Post
    Just looked at the plugin; you're definitely leaking obj.
    Thanks for the tip, I'll fix it when I have the time.

    Quote:
    Originally Posted by nosoop View Post
    In my experience, Workshop maps are already synced from the file referenced in mapcyclefile, and you can sm_map workshop/any_valid_workshop_map_id or changelevel and the server will change to it without performing any prior syncing (though of course it may need to download the map in that case).
    I realized that after I created and published the plugin. So I put it in my plans to add a command to fetch a mapcycle from the workshop. My semester should be ending soon so I'll have more time to work on these things.

    Overall, thank you for your reply, I appreciate your feedback. ~Breadpudding
    Breadpudding is offline
    nosoop
    Veteran Member
    Join Date: Aug 2014
    Old 11-15-2018 , 06:28   Re: [TF2] Workshop Map Collection Support (2018.11.2-2, 2018-11-02)
    Reply With Quote #4

    Quote:
    Originally Posted by Breadpudding View Post
    I realized that after I created and published the plugin. So I put it in my plans to add a command to fetch a mapcycle from the workshop.
    Sounds good to me; I've seen a few people that have wondered why TF2 doesn't have this kind of functionality built-in.

    Forgot to bring this up before: If you're feeling adventurous, you can cut the dependency on sm-json, pass in &format=vdf to the API instead of JSON, and use SourceMod's KeyValue parser to extract the data.

    Not my decision to make though, of course, but it's nice of Valve to offer that option in their API.
    __________________
    I do TF2, TF2 servers, and TF2 plugins.
    I don't do DMs over Discord -- PM me on the forums regarding inquiries.
    AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)
    nosoop is offline
    Breadpudding
    New Member
    Join Date: Nov 2018
    Old 12-19-2018 , 12:43   Re: [TF2] Workshop Map Collection Support (2018.11.2-2, 2018-11-02)
    Reply With Quote #5

    Quote:
    Originally Posted by nosoop View Post
    Sounds good to me; I've seen a few people that have wondered why TF2 doesn't have this kind of functionality built-in.

    Forgot to bring this up before: If you're feeling adventurous, you can cut the dependency on sm-json, pass in &format=vdf to the API instead of JSON, and use SourceMod's KeyValue parser to extract the data.

    Not my decision to make though, of course, but it's nice of Valve to offer that option in their API.
    Just released the latest version(about time eh?) and I took your suggestion to change from JSON to VDF to remove the dependency. Also, I added tf_workshop_mapcycle_collection to save the collection as mapcycle_workshop.txt in your tf/cfg! Hopefully that will add some use to this plugin. ~Breadpudding
    Breadpudding is offline
    ThatKidWhoGames
    Veteran Member
    Join Date: Jun 2013
    Location: IsValidClient()
    Old 12-19-2018 , 13:14   Re: [TF2] Workshop Map Collection Support (2018.12.19-1, 2018-12-19)
    Reply With Quote #6

    Thanks for this!
    ThatKidWhoGames is offline
    Reply


    Thread Tools
    Display Modes

    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 11:22.


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