View Single Post
Author Message
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 10-07-2019 , 21:07   [L4D1 & L4D2] Hostname - Display Map Name [v1.0.2 | 16-March-2021]
Reply With Quote #1

About

I made this plugin because I usually access my favorite [L4D]/[L4D2] servers through the "openserverbrowser" console command and,
despite knowing the dev name of the vanilla campaigns (c*m*), some customs maps don't follow this name pattern for its chapters,
Also, the chapter name doesn't appear through the Steam Group servers list, or through the Friend List, only the map name is displayed,
Making it difficult to identify which chapter the map is currently running.

Description

This plugin will add the map name to the hostname, based on a KeyValue file located at data folder.
It was made mainly for [L4D]/[L4D2] game because the campaign (map-chapter) style, but should also work with other games.

Example

My hostname is "Mart Server" and I'm currently playing in the "c1m1" map.
The name "Dead Center [1-5]" was added for the "c1m1" map at the KeyValue file.
And the hostname format is set to {hostname} | {mapname}.
When the plugin runs, it will turn my hostname into "Mart Server | Dead Center [1-5]"

Cvars

A configuration file named "hostname_mapdisplay.cfg" will automatically be created for you upon the first run in the "\cfg\sourcemod\" folder.

PHP Code:
// Enables/Disables the plugin. 0 = Plugin OFF, 1 = Plugin ON.
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
hostname_mapdisplay_enabled "1"

// Display format.
// Available tags: {hostname},{mapname},{gamemode},{GAMEMODE}
// Note: If the "format" attribute is set in the KeyValue file located at data folder, this cvar will be ignored.
// -
// Default: "{hostname} | {GAMEMODE} | {mapname}"
hostname_mapdisplay_format "{hostname} | {GAMEMODE} | {mapname}"

// Hostname used by the {hostname} tag.
// Note: If the "hostname" attribute is set in the KeyValue file located at data folder, this cvar will be ignored.
// -
// Default: "<your hostname>."
hostname_mapdisplay_hostname "<your hostname>"

// Enables/Disables the plugin when the map is not found in the KeyValue file located at data folder. 0 = OFF, 1 = ON (shows the map dev name).
// -
// Default: "0"
// Minimum: "0.000000"
// Maximum: "1.000000"
hostname_mapdisplay_mapnotfound "0" 
Admin Commands

PHP Code:
sm_hostname_mapdisplay_reload  // Reloads the hostname based on a KeyValue file located at data folder. (needs "z" flag).
sm_print_cvars_hostname_mapdisplay // Prints the plugin related cvars and their respective values to the console. (needs "z" flag). 
Change Log

Spoiler


Notes
  • This plugin isn't compatible with other plugins that also changes the hostname.
  • On the first run, the hostname_mapdisplay_hostname cvar will be filled with your current hostname.
  • If your hostname is large, the map name may truncate.
  • Seems that unicode characters don't load properly from ".cfg" files so if you want to have unicode characters in the hostname (e.g.: Simplified Chinese), use the configs in the KeyValue file located at data folder as a workaround instead of the ".cfg" file generated with the cvars of the plugin.
  • If any config from the "Host" section in the KeyValue file is set, the related cvar value will be ignored.

To Do
  • Add a translation file.
  • Add more tags (player count/timeleft?).
  • Add support to customize gamemode tags. (e.g. Versus => Vs)

Thank you!

Related Plugins

Post Reply
  • Any feedbacks, bug reports, fixes, improvements, translations or suggestions for the plugin are welcome.

Installation
  • Put the "hostname_mapdisplay.txt" file in your "\addons\sourcemod\data\" folder. [Note: this file is currently based on some L4D2 maps]
  • Put the "hostname_mapdisplay.smx" file (click Get Plugin) in your "\addons\sourcemod\plugins\" folder.
Attached Files
File Type: txt hostname_mapdisplay.txt (17.3 KB, 277 views)
File Type: sp Get Plugin or Get Source (hostname_mapdisplay.sp - 351 views - 15.2 KB)
__________________

Last edited by Marttt; 01-15-2023 at 20:32.
Marttt is offline