View Single Post
Author Message
RM_Hamster
SourceMod Donor
Join Date: Jul 2008
Location: MA
Old 08-19-2008 , 17:50   Dynamic Hostname [V2.1.1 - 8/27/2008]
Reply With Quote #1

Dynamic Hostname

Description:

This plugin is a remake of Hell Phoenix's "Timeleft Hostname" plugin which I wanted to expand on. What Dynamic Hostname does is that it automatically replaces variables in the hostname. Right now, it supports %t (for timeleft) and %n (for nextmap).

CVars:
  • dh_default <string> - Default hostname for when no clients are active on the server.
    • Default is "" (empty string).
When no one is playing in the server (either it is empty or everyone is spectating), the plugin will automatically set the hostname to dh_default. This is an optional feature; if you do not wish to use dh_default, simply keep it to the default empty string and it will not be used.

If you decide not to use dh_default, when no one is playing in the server, timeleft will be subject to dh_empty.
  • dh_empty <bool> - Specifies whether the hostname will include timeleft when the server is empty.
    • Default is 1 (true).
If set to 1, the server will always display the timeleft. Otherwise, the timeleft will simply be removed from the hostname when no players are in the server. The server must begin processing frames before timeleft can work (at least one player must have joined the server since it last restarted).
  • dh_frequency <float> - How often, in seconds, to update the hostname.
    • Default is one second (1.0)
    • Note: timeleft (%t) does not work if the server is empty.
  • dh_update <opt:string> - Manually update the hostname with an option to specify a new hostname.
Since there is no way of telling if a player sets the hostname or if the plugin sets the hostname, I made dh_update. This CVar can be used to change the hostname, such as dh_update "This is a test hostname!". Also, if used without any arguments, it will manually update the hostname (useful just in case it ever messes up).

Notes:

As of V2.1, I'm working on adding some new features, such as a config that allows for custom flags in the hostname. Once this is done, I'll be removing dh_default (it's not really needed). Also, I'm rearranging certain parts of the code to circumvent OnConfigsExecuted() since it seems to be causing problems. This should alleviate the problem Caught off Guard reported (thanks for all the help!).

After the next major release, I'll be working on full support for SourceForts (thanks Chanz!).

Versions:

2.1.1 - 12/31/2008
  • Fixed small bug with dh_update when using RCON/console (really fixed now!)
2.1 - 8/27/2008
  • Added CVar dh_empty to control behavior of the plugin when server is empty
  • Fixed small bug with dh_update when using RCON/console
  • Semi-support for bug with Insurgency and OnConfigsExecuted (will have full support next major version)
2.0 - 8/19/2008
  • Renamed to "Dynamic Hostname"
  • Rewrote most of the existing code
  • Renamed original cvar to dh_frequency
  • Added cvars dh_default and dh_update
  • Added support for %t and %n
  • Added changing of frequency "on the fly"
  • Optimized to only update when needed
Thanks To:

Hell Phoenix - original SourceMod plugin
Chanz - for the concept and the SourceForts code
Caught off Guard - for helping with the Insurgency/OnConfigsExecuted() bug
MaKTaiL - for the ideas to make this plugin better and for testing

Cheap Suit - original AMXX plugin
Ferret - for pointing out some things to fix =D
Attached Files
File Type: sp Get Plugin or Get Source (dynamic_hostname.sp - 3325 views - 6.7 KB)

Last edited by RM_Hamster; 12-31-2008 at 18:19. Reason: Updated to V2.1.1
RM_Hamster is offline