View Single Post
Author Message
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 02-01-2011 , 21:51   [L4D2] Jukebox Spawner (1.12) [11-Dec-2022]
Reply With Quote #1

About:
  • Auto-spawns jukeboxes on round_start.
  • Admin command to spawn jukeboxes aligned to the wall and floor.
  • Positions and angles based on a config (Attached below is a config with jukeboxes on every Valve map).
  • Triggers a horde when track #4 is played.
  • The jukebox plays a max of 7 tracks, the last 2 rarely play.
  • Please note: Each jukebox creates 18 entities within the game. Maximum of 10 jukeboxes allowed (recompile for more).
  • Please note: Sounds which loop will do so forever until you change track or use !jukestop.


Thanks:
  • 8bit - for the idea.
  • Mr.RuyC and NanX - For helping test the plugin on their server.
  • Zuko & McFlurry for source code (full credits inside the source).


Custom Tracks and Spawn Config:
  • The config is saved to l4d2_jukebox_spawns.cfg in your servers \addons\sourcemod\data\ folder.
  • The position and angles for each jukebox are saved in a key value structure.
  • Each map has it's own section (as seen below for Dead Center)
  • Simply put "track#" (where # is 1-7 for the track to change or 1-64) followed by the soundscape name in quotes.
  • Soundscape names can be found in the .snd files in your games \reslists\ folders.

Map Specific overrides:
When a jukebox is created, it will first check for 7 map specific tracks. In the example below "track1" is a map specific override within the "c1m1_hotel" section so that track will be loaded on that map.
"main" keyvalue tracks:
You can specify 7 tracks in the "main" section which force the specified track and track number on all maps. In the example "track4" will be the same on all maps while the rest could be random.
"random" keyvalue tracks:
Specifying "track1" to "track7" will override the relative original Valve track. This is how you would remove certain Valve default tracks from playing. Leaving 1 to 7 blank will allow them to play. To give the jukebox a wider selection of tracks, add them from "track8" onwards.


Example:
Code:
"jukeboxes"
{
	"main"
	{
		"track4"		"Jukebox.re_your_brains"
	}
	"random"
	{
		"track8"		"Vomit.Use"
	}
	"c1m1_hotel"
	{
		"num"        "2"
		"angle1"        "-0.000000 90.000000 0.000000"
		"origin1"       "412.860748 5683.539062 2880.000000"
		"angle2"        "-0.000000 90.000000 0.000000"
		"origin2"       "1854.047729 4510.630859 1216.031250"
		"track1"        "Jukebox.still_alive"
		"track4"        "Vomit.Use"
	}
}
Valve orignial tracks
Code:
    "track1"        "Jukebox.BadMan1",
    "track2"        "Jukebox.Ridin1",
    "track3"        "Jukebox.saints_will_never_come",
    "track4"        "Jukebox.re_your_brains",
    "track5"        "Jukebox.SaveMeSomeSugar",
    "track6"        "Jukebox.still_alive",
    "track7"        "Jukebox.AllIWantForXmas"


Commands:

PHP Code:
// All players
sm_jukenext    // Changes track on the closest jukebox, must be near by.
sm_jukestop    // Stops the music playing from all jukeboxes.

// Admins only (requires "z" flag)
sm_juke        // Spawns a jukebox where your crosshair is pointing (attempts to align with walls and floor).
sm_jukebox     // Same as above, but saves the origin and angle to the jukebox spawns config.
sm_jukedel     // Deletes the jukebox you are pointing at (point near the top above the menu).
sm_jukewipe    // Removes all the jukeboxes in game and deletes the current map from the config.
sm_jukelist    // Lists all the Jukeboxes on the current map and their locations.
sm_juketracks  // Lists all the tracks read from the config and shows which will be playing. 


CVars:

Saved to l4d2_jukebox.cfg in your servers \cfg\sourcemod\ folder.

PHP Code:
// 0=Plugin off, 1=Plugin on.
l4d2_jukebox_allow ""

// Create a panic event on these gamemodes when track #4 plays. Separate by commas (no spaces). "" = all.
l4d2_jukebox_horde_modes ""

// Display a chat message when the horde is triggered by track #4.
l4d2_jukebox_horde_notify "1"

// How many seconds after track #4 plays before triggering a horde.
l4d2_jukebox_horde_time "42"

// -1=Infinite, 0=Off. Specify how many times a panic event may occur when track #4 plays.
l4d2_jukebox_horde_trigger "-1"

// Turn on the plugin in these game modes, separate by commas (no spaces). (Empty = all).
l4d2_crawling_modes ""

// Turn off the plugin in these game modes, separate by commas (no spaces). (Empty = none).
l4d2_jukebox_modes_disallow ""

// Turn on the plugin in these game modes. 0=All, 1=Coop, 2=Survival, 4=Versus, 8=Scavenge. Add numbers together.
l4d2_crawling_modes_tog "0"

// Jukebox Spawner plugin version.
l4d2_jukebox_version 


Changes:
Code:
1.12 (11-Dec-2022)
    - Changes to fix compile warnings on SourceMod 1.11.

1.11 (11-Jul-2021)
    - Moved the button forward slightly. This allows using the button which the last update prevented.

1.10 (06-Jul-2021)
    - Fixed getting stuck on the Jukebox. Thanks to "Shadowysn" for reporting. Maybe caused by the "2.2.1.3" game update.

1.9 (10-May-2020)
    - Extra checks to prevent "IsAllowedGameMode" throwing errors.
    - Various changes to tidy up code.

1.8 (01-Apr-2020)
    - Fixed "IsAllowedGameMode" from throwing errors when the "_tog" cvar was changed before MapStart.

1.7 (05-May-2018)
    - Converted plugin source to the latest syntax utilizing methodmaps. Requires SourceMod 1.8 or newer.

1.6 (21-Jul-2013)
    - Removed Sort_Random work-around. This was fixed in SourceMod 1.4.7, all should update or spawning issues will occur.

1.5 (10-May-2012)
    - Added cvar "l4d2_jukebox_allow" to turn the plugin on and off.
    - Added cvar "l4d2_jukebox_modes" to control which game modes the plugin works in.
    - Added cvar "l4d2_jukebox_modes_tog" same as above.
    - Removed max entity check and related error logging.
    - Small changes and fixes.

1.4 (01-Dec-2011)
    - Added Jukeboxes to these maps: Crash Course, Dead Air, Death Toll, Blood Harvest, Cold Stream.
    - Added command "sm_juketracks" to list tracks read from the config and which will play.
    - Changed command "sm_jukelist" to list all Jukebox positions on the current map.
    - Creates Jukeboxes when the plugin is loaded and removes when unloaded.
    - Fixed "l4d2_jukebox_modes_disallow" cvar not working all the time.

1.3 (19-May-2011)
    - Fixed sm_jukestop not working.

1.2 (19-May-2011)
    - Fixed no tracks loading if a "random" section was not specified. Valve default tracks will be loaded into the "main" section.
    - Fixed PrintToChatAll() error.

1.1 (19-May-2011)
    - Added a "main" section to the keyvalue config which sets a specific track to a specific number for all maps.
    - Added a "random" section to the keyvalue config. Tracks will be randomly be selected from here.
    - Added cvar "l4d2_jukebox_horde_notify" to display a hint when the jukebox triggers a horde.
    - Added command "sm_jukelist" to display a list of randomly selected tracks as well as the override, random and main tracks loaded.
    - Added a check to avoid spawning footlockers when there are too many entities.
    - Added Jukeboxes to saferooms in the the Cold Stream campaign.
    - Changed sm_juke and sm_jukebox to spawn jukeboxes with specified tracks from the "main" and "random" sections and uses overrides for that map if available.
    - Limited sm_jukenext and sm_jukestop to survivor team and admins with 'z' flag only.

1.0 (01-Dec-2011)
    - Initial release.


Installation:
  1. Click "Get Plugin" and put the .smx file into your servers \addons\sourcemod\plugins\ folder.
  2. Optionally download "l4d2_jukebox_spawns.cfg" and save to your servers \addons\sourcemod\data\ folder. This has jukeboxes saved on every Valve map.

Updating from 1.4 or older:
  • New cvars have been added: use the Cvar Configs Updater, or delete the old cvars config or manually add them.
Attached Files
File Type: cfg l4d2_jukebox_spawns.cfg (10.9 KB, 4091 views)
File Type: sp Get Plugin or Get Source (l4d2_jukebox_spawner.sp - 662 views - 42.9 KB)
__________________

Last edited by Silvers; 12-11-2022 at 04:26.
Silvers is offline