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

[TF2] Auto DeSpectate (1.1.1)


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Oshroth
Senior Member
Join Date: Dec 2009
Plugin ID:
2465
Plugin Version:
1.1.1
Plugin Category:
Gameplay
Plugin Game:
Team Fortress 2
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Moves Spectators to a playing team automatically
    Old 07-28-2011 , 17:16   [TF2] Auto DeSpectate (1.1.1)
    Reply With Quote #1

    Auto DeSpectate
    by Oshroth
    About:
    DeSpectate moves all spectators to the playing teams automatically. It designed to prevent Achievement Idle servers ending up with 26/30 players on spectator because the map changed.

    Cvars:
    sm_despec_version - Plugin Version
    sm_despec_time - (default 120) How often the plugin moves all spectators. 0 - disables plugin.
    sm_despec_team - (default 0) What team spectators are moved to. 0 - Moves to smaller team or RED if equal sizes. 1 - Moves to RED. 2 - Moves to BLU.
    sm_despec_class - (default 0) What class they should be (This only applies to players who haven't selected a class yet). 0 - Random class. 1-9 - Specific Class
    sm_despec_admins_immune - (default 1) Are admins immune to the plugin

    Changelog:
    • 1.0 - 11 views
      • Initial version
    • 1.0.1 - 25 views
      • Fixed some coding style issues (Reported Here)
    • 1.1 - 24 views
      • Added Admin Immunity (Reported Here)
      • Fixed cvar error (Reported Here)
      • Added retry on team or class join failure
    • 1.1.1
      • More Coding Fixes (Reported Here)
      • Renamed Cvars in preparation for cross-mod support
    Attached Files
    File Type: sp Get Plugin or Get Source (DeSpectate.sp - 3014 views - 5.1 KB)
    __________________

    Last edited by Oshroth; 08-18-2011 at 09:21. Reason: Updated Plugin
    Oshroth is offline
    Powerlord
    AlliedModders Donor
    Join Date: Jun 2008
    Location: Seduce Me!
    Old 07-28-2011 , 17:29   Re: [TF2] Auto DeSpectate
    Reply With Quote #2

    er... why do you need players to join a team on an idle server? They gain items regardless of whether they're on a team or not.

    Having said that, a few notes about the code:

    1. Retrieving the values of convars in OnPluginStart won't work, as plugins load before server.cfg is executed. They should be retrieved when you need them... or in OnConfigsExecuted if you really only want to check them once.


    2.
    Code:
    #define TEAM_BLU 3
    #define TEAM_RED 2
    #define TEAM_SPEC 1
    #define TEAM_NONE 0
    Congratulations on reinventing the TFTeam enum from the tf2 include.

    And before you say "but I can't use this to compare against values returned from GetClientTeam," yes you can... you just have to prefix it with _:, such as this:

    PHP Code:
    if (GetClientTeam(i) == _:TFTeam_Unassigned || GetClientTeam(i) == _:TFTeam_Spectator) { 
    3. CheckTimer will always be INVALID_HANDLE in OnPluginStart, no need to check if it is.
    __________________
    Not currently working on SourceMod plugin development.

    Last edited by Powerlord; 07-28-2011 at 17:40.
    Powerlord is offline
    Oshroth
    Senior Member
    Join Date: Dec 2009
    Old 07-29-2011 , 03:15   Re: [TF2] Auto DeSpectate
    Reply With Quote #3

    Quote:
    Originally Posted by Powerlord View Post
    er... why do you need players to join a team on an idle server? They gain items regardless of whether they're on a team or not.
    This is basically so people who are playing can kill them and also for the servers with mp_idledealmethod set to 1 or 2
    Quote:
    Originally Posted by Powerlord View Post
    1. Retrieving the values of convars in OnPluginStart won't work, as plugins load before server.cfg is executed. They should be retrieved when you need them... or in OnConfigsExecuted if you really only want to check them once.
    Retrieving the convars in OnPluginStart returns their default values and ConVar_Changed gets called when they get changed in the config anyway.
    Quote:
    Originally Posted by Powerlord View Post
    2.
    Congratulations on reinventing the TFTeam enum from the tf2 include...
    That is actually a valid point. I haven't used Sourcemod in over a year and this is my first tf2 plugin so I was unaware of that enum.
    __________________
    Oshroth is offline
    desynced
    Member
    Join Date: Feb 2010
    Old 07-29-2011 , 21:17   Re: [TF2] Auto DeSpectate
    Reply With Quote #4

    Thank you for this!!!! Been wanting something like this for my achievement server.
    desynced is offline
    desynced
    Member
    Join Date: Feb 2010
    Old 08-03-2011 , 13:45   Re: [TF2] Auto DeSpectate
    Reply With Quote #5

    Ive noticed when I run tf_despec_time if gives the error:

    ConVarRef tf_despec_time doesn't point to an existing ConVar


    But if I run the same command again a second time, it kicks in. Dunno when it started doing this but just noticed it today.
    desynced is offline
    desynced
    Member
    Join Date: Feb 2010
    Old 08-05-2011 , 07:21   Re: [TF2] Auto DeSpectate
    Reply With Quote #6

    Any way of making admins immune to getting auto despectated? Sometimes an admin needs to spec someone.
    desynced is offline
    Oshroth
    Senior Member
    Join Date: Dec 2009
    Old 08-06-2011 , 14:43   Re: [TF2] Auto DeSpectate
    Reply With Quote #7

    Quote:
    Originally Posted by desynced View Post
    Ive noticed when I run tf_despec_time if gives the error:

    ConVarRef tf_despec_time doesn't point to an existing ConVar


    But if I run the same command again a second time, it kicks in. Dunno when it started doing this but just noticed it today.
    I was getting that error as well, but its been fixed now.
    __________________
    Oshroth is offline
    KyleS
    SourceMod Plugin Approver
    Join Date: Jul 2009
    Location: Segmentation Fault.
    Old 08-10-2011 , 18:25   Re: [TF2] Auto DeSpectate (1.1)
    Reply With Quote #8

    If tf_despec_time is set to 0 this will error on every round start due to CheckTimer never being reset to INVALID_HANDLE. The Handle is invalidated when you use CloseTimer, but it still has the existing handle value.

    Using break in a switch in pawn has a different meaning then it does in C. You're breaking out of the for and not the switch. With the extra checks below, is this intended?

    Nitpicking:

    Cache GetClientTeam. While it's not a big deal here, it can hurt you in more expensive loops.

    Use MaxClients instead of your own MaxPlayers.

    While I realize this is intended for TF2, why not add support for other games? There's nothing using the TF2 Extension, so you can undef REQUIRE_EXTENSIONS and make this cross platform.



    When the first field is addressed, PM me.
    KyleS is offline
    Oshroth
    Senior Member
    Join Date: Dec 2009
    Old 08-18-2011 , 09:23   Re: [TF2] Auto DeSpectate (1.1.1)
    Reply With Quote #9

    More coding fixes and cvar changes
    __________________
    Oshroth is offline
    nineteeneleven
    Veteran Member
    Join Date: Nov 2010
    Old 09-06-2011 , 08:56   Re: [TF2] Auto DeSpectate (1.1.1)
    Reply With Quote #10

    this should work well with saxton hale mod also.

    oh, does it move the replay bot off of spec?
    __________________
    nineteeneleven 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 22:38.


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