Description
This plugin uses HookEvent("player_team") and grabs their new (and old) team. If their team is 0, they aren't fully-loaded. If their team is 1, they are loaded but haven't been assigned a team yet because other players are still loading (or are about to be assigned a team). Once players have been assigned to team 2 (survivors) or team 3 (infected), they are fully past the loading screen and can see chat. This plugin then displays a message to them. This plugin should be compatible with competitive L4D2 servers as well.
By default, this prints 2 messages to each player individual, translated to their language provided in the phrases file. You also have an option to make it print every map, or just on the very first time they connect to the server. Once they disconnect, they'll see the welcome message again.
An autoexec is created in
cfg/sourcemod for this plugin.
Cvars- pcs_everymap "1" // Whether to print every map.
- pcs_lines "2" // How many lines to print.
- pcs_finalmsg "1" // Should we print a final message?
- pcs_lines_final "2" // How many lines to print for final message?
Other plugins use things like player_connect, player_spawn, or OnClientPutInServer(), etc. Some of these fire multiple times in L4D2 especially during map changes, and don't cover the initial time everyone is loading in from a lobby where load times and connections vary. As well, things like OnClientPutInServer() will fire before a client finishes loading.
Compiling
In order to compile, you will need colors.inc ->
https://forums.alliedmods.net/showthread.php?t=96831
Installation
You don't need to mess with any of the code to change the messages in the translation files.
pcsWelcome.smx -> addons/sourcemod/plugins
pcswelcome.phrases.txt -> addons/sourcemod/translations
Changelog:
Code:
1.21 (July 17th - 2024)
- Added some validity checks in PlayerQuit, Event_VehicleLeave, and Event_VersusFinished to prevent client 0 errors.
1.2 (July 16th - 2024)
- Added cvars and code related to sending a "final message" to the players. Using "versus_match_finished" and "finale_vehicle_leaving".
1.1 (July 16th - 2024)
- Used ArrayList and user's SteamAuth to check if they were connected. Prior design caused mismatches for "pcs_everymap" "0".
1.0 (July 16th - 2024)
- Initial release.
Additional
This is a very simple plugin. While I plan to add to it, the whole point of it is for others to build on it and tailor it to their own liking. You can increase the amount of lines by changing a few things in a few places easily. The plugin also should work for Left4Dead1, but I do not have a server setup to test these so if you want you can remove the
public APLRes AskPluginLoad2 at the top to let it load.