Raised This Month: $106 Target: $400
 26% 

[TF2] Workshop Map Collection Support (2018.11.2-2, 2018-11-02)


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Breadpudding
New Member
Join Date: Nov 2018
Plugin ID:
6325
Plugin Version:
2019.11.2-2
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 , 01:39   [TF2] Workshop Map Collection Support (2018.11.2-2, 2018-11-02)
    Reply With Quote #1

    I'm the owner of a TF2 server and I find it annoying to type all those tf_workshop_map_sync commands just to get the maps to load from the workshop. So I offer a solution: tf_workshop_map_collection. All you have to do is make a collection on the workshop and add all your maps to it! Now all the map_sync spam is replaced by a single map_collection command! Not only does it declutter your server.cfg, but it also makes it easier to add new maps in the future! Hope this helps you like it helped me! ~Breadpudding

    How to use

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

    Quote:
    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_map_collection command!

    Dependencies

    Plans
    • Make a command to add the synced maps to a mapcycle file

    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 - 15 views - 3.7 KB)
    File Type: smx mapcollection.smx (15.2 KB, 14 views)

    Last edited by Breadpudding; 11-04-2018 at 14:12. Reason: Updated the image
    Breadpudding is offline
    nosoop
    Senior Member
    Join Date: Aug 2014
    Old 11-08-2018 , 05: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.
    AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH)
    nosoop is offline
    Breadpudding
    New Member
    Join Date: Nov 2018
    Old 11-14-2018 , 19: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
    Senior Member
    Join Date: Aug 2014
    Old 11-15-2018 , 07: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.
    AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH)
    nosoop 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 07:40.


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