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

Halftime teamswitch (1.0.11)


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Gemeni
Senior Member
Join Date: Sep 2007
Location: Sweden
Plugin ID:
226
Plugin Version:
1.0.11
Plugin Category:
General Purpose
Plugin Game:
Counter-Strike: Source
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Moves all players to the opposite team at halftime (ie. Half of the map time has passed and round has ended)
    Old 12-06-2007 , 17:32   Halftime teamswitch (1.0.11)
    Reply With Quote #1

    Description:
    Simple plugin the switch all players to the opposite team when half of the map time has passed and the round ended.

    Background:
    Some maps people find to be unbalanced. This plugin tries to make it equal for everyone. All get to play both sides of the map.

    Change log:
    1.0 - First Version
    1.0.1 - Using bool values (Thanks pRED)
    1.0.2 - Added reset of halftime flag to false in OnMapStart just for safety
    1.0.3 - Cleaned up code. Added logging to logfile due to some reported problems. Works fine in the last tests.
    1.0.4 - Adding sounds
    1.0.5 - Switching the score when teams switch
    1.0.6 - Now switch of scores stays
    1.0.7 - Added variable to reset money and weapons at switch
    Added possibility to disable the halftime sound
    Added global forward "gemHalftime" if other scripts want to do something in halftime
    1.0.8 - Added possibility to switch teams based on rounds as well. Either maxrounds or winlimit.
    1.0.9 - Removed unnecessary logmessages, less spam in logs.
    1.0.10 - Fixed bug where nopt all grenades and def kit were removed
    1.1.11 - Fix so it works with new CSS update

    Note:
    1.0.5 switch did not work due to what I think is a bug in sourcemod. Reported the bug, https://bugs.alliedmods.net/show_bug.cgi?id=3722. We'll see what happens.
    In the mean time, version 1.0.6 takes care of displaying the correct scores. Thanks to [MKBI]Relle for pointing out the simple work around

    Install instructions:
    Put the plugin in the standard plugin dir
    Unzip gem_sounds under cstrike/sound
    Alter your pure_server_whitelist.txt (if you are running pure server) and add
    Code:
    sound\gem_sounds\*.*      allow_from_disk
    Variables:
    sm_halftime_sound - The sound that should be played in halftime, gem_sounds/teamswitch.mp3 is default. If set to "" in the config, halftime sound is disabled and no download occurs.

    sm_halftime_money_reset - Can be 0 or 1. 0 means no reset of money or weapons. You keep what you have. 1 means, all wepons and armour are removed, starting with standard pistol and mp_startmoney to by for.

    sm_halftime_teamswitch_type - It can have the following values ...
    timelimit - switch will be done at the end of the round when more than half of mp_timelimit has passed.
    maxrounds - switch will be done at then end of the round when playedRounds >= mp_maxrounds
    winlimit- switch will be done at then end of the round when playedRounds >= mp_winlimit
    Attached Files
    File Type: zip gem_sounds.zip (490.9 KB, 7122 views)
    File Type: sp Get Plugin or Get Source (gem_halftime_teamswap.sp - 9970 views - 8.7 KB)
    __________________
    --- Growing older is mandatory --
    ----- Growing up is optional -----

    Last edited by Gemeni; 06-28-2010 at 17:52.
    Gemeni is offline
    LocutusH
    Senior Member
    Join Date: Dec 2007
    Location: Hungary
    Old 12-07-2007 , 03:00   Re: Halftime teamswitch
    Reply With Quote #2

    And what if the map time is extended after the swich, so that the "half time" is moved away a few rounds?
    There will be another switch?
    LocutusH is offline
    Gemeni
    Senior Member
    Join Date: Sep 2007
    Location: Sweden
    Old 12-07-2007 , 03:54   Re: Halftime teamswitch
    Reply With Quote #3

    Good question, and I havn't tried it myself ...

    The way the script works now is:
    If timeleft increases above maptime/2 the halftime flag will reset so a switch will occur next time timeleft falls below maptime/2

    But I don't know if both maptime and timeleft is changed on extension or if it's only timeleft ...

    Guess I will have to try this a well ...


    And things will depend on when the map is extended ... So I guess the switch cant really be 100% fair depending on when you decide to extend the map.
    __________________
    --- Growing older is mandatory --
    ----- Growing up is optional -----
    Gemeni is offline
    Gemeni
    Senior Member
    Join Date: Sep 2007
    Location: Sweden
    Old 12-07-2007 , 17:22   Re: Halftime teamswitch
    Reply With Quote #4

    Ok ... Just checked the extend map thingie ...
    The extention time is added to both mapTime and timeleft

    Scenario 1:
    maptime is the standard 900 secons and timeleft is 600 (300 secs passed)
    - No teamswitch has occured
    extending the map by 15 minutes
    maptime is now 1800 and timeleft is 1500, finishing the map with no more extension
    - Teamswitch will occur when time left is 900
    Result: one team will play CT 300+600 and the other one 900 secs = Fair

    Scenario 2:
    maptime is the standard 900 secons and timeleft is 200 (700 secs passed)
    - Teamswitch was done after 450 seconds
    extending the map by 15 minutes
    maptime is now 1800 and timeleft is 1100, finishing the map with no more extension
    - Teamswitch will occur again when time left is 900
    Result: one team will play CT 450+900 = 1350 and the other one 250+300 secs = 550 secs ... Might not seem fair ... but what is a good solution?!

    And what if the map is replaced by another map after 400 secons ... then no teamswitch will occur at all!

    I dont think this can be 100% fair ... but it will give some fairness if maps are played the standard time which they are 95% of the times on our server ... guess most servers have the same ...

    Leaving the plugin as it is ... unless someone comes up with a better suggestion ... But to start to calculate something else than timeleft<=maptime/2 for trigger for mapchange will just be akward in my opinion ... the fairness can always be set aside with another map vote ...

    Thanks for raising the question though ...

    Conclusion
    Plugin will not crash when extending the map ... some extra switching might be done if extension is done after halftime.
    Works as designed ;)

    We sure will be using it on our servers even if it might not get approved for not handling this in more detail ;)
    __________________
    --- Growing older is mandatory --
    ----- Growing up is optional -----
    Gemeni is offline
    pRED*
    Join Date: Dec 2006
    Old 12-07-2007 , 18:05   Re: Halftime teamswitch
    Reply With Quote #5

    For readability you could try changing 'new halftime' to 'new bool:halftime' and then using 'true' and 'false' instead of 1 and 0. This has no effect on how the code gets executed, just makes it clearer to read imo. Definitely not required for approval.

    You said in one of your comments that you tried the event 'game_newmap', you can just use the public forward 'public OnMapStart()' (in the same way as OnPluginStart) if you want to initialize halftime to 0 then.

    Other than that looks pretty solid.
    pRED* is offline
    Gemeni
    Senior Member
    Join Date: Sep 2007
    Location: Sweden
    Old 12-07-2007 , 18:24   Re: Halftime teamswitch
    Reply With Quote #6

    Sticking with the way I'm handling initializing of halftime ... since it aids in the map extension case explained above ...

    Thanks for the input regarding bool values ... updated the script ;)
    __________________
    --- Growing older is mandatory --
    ----- Growing up is optional -----
    Gemeni is offline
    TechKnow
    Senior Member
    Join Date: Nov 2007
    Old 12-07-2007 , 23:15   Re: Halftime teamswitch
    Reply With Quote #7

    I would like to understand how the players team models know how to switch as well, is this a new internal command?

    TechKnow
    __________________
    "Stupd is what Stupid dose"
    MY MODELS SITE
    http://techknowmodels.19.forumer.com/index.php
    TechKnow is offline
    Gemeni
    Senior Member
    Join Date: Sep 2007
    Location: Sweden
    Old 12-09-2007 , 04:35   Re: Halftime teamswitch
    Reply With Quote #8

    Seems to me that it's integrated ... at least T looks like T and CT looks like CT ...

    Documentation doesn'm mention if someone who picked model 2 as CT gets model 2 as T ... Or if they always default to model 1
    ;)
    __________________
    --- Growing older is mandatory --
    ----- Growing up is optional -----
    Gemeni is offline
    Gemeni
    Senior Member
    Join Date: Sep 2007
    Location: Sweden
    Old 12-09-2007 , 16:42   Re: Halftime teamswitch
    Reply With Quote #9

    1.0.2 - Added reset of halftime flag to false in OnMapStart just for safety
    __________________
    --- Growing older is mandatory --
    ----- Growing up is optional -----
    Gemeni is offline
    Gemeni
    Senior Member
    Join Date: Sep 2007
    Location: Sweden
    Old 12-12-2007 , 08:59   Re: Halftime teamswitch
    Reply With Quote #10

    Regarding approval. Any special request need to be done to get approval?
    __________________
    --- Growing older is mandatory --
    ----- Growing up is optional -----
    Gemeni 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 01:10.


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