Description:
This plugin allows Administrators to randomly select a human player who is currently in the game and not spectating.
Commands:
!randomplayer - This will find a random player. A player is selected and a short song is played along with a countdown to prepare the player for whatever is next.
!randomplayer <target> - This will appear to find a random player, but it will pick the target player.
Example: !randomplayer
Effect: A random human player will be chosen.
Example: !randomplayer johnny
Effect: The player named Johnny will be chosen, but it will look random.
I typically use this after a vote asking if a random player should become a BOSS. You might use it for other purposes such as determining who wins a prize.
Installation:
Place randomplayer.smx in tf/addons/sourcemod/plugins directory
Place randomplayer.sp in tf/addons/sourcemod/scripting directory
Place Get_Ready.mp3 in tf/sound/custom directory
For your countdown timer, you can avoid all if/else-if statements by using a switch statement like this:
PHP Code:
public Action RPTimer_CountDown(Handle timer)
{
switch (iAmount)
{
case 5: EmitSoundToAll("/vo/announcer_ends_5sec.mp3");
case 4: EmitSoundToAll("/vo/announcer_ends_4sec.mp3");
case 3: EmitSoundToAll("/vo/announcer_ends_3sec.mp3");
case 2: EmitSoundToAll("/vo/announcer_ends_2sec.mp3");
case 1: EmitSoundToAll("/vo/announcer_ends_1sec.mp3");
case 0:
{
PrintCenterTextAll("Done!");
EmitSoundToAll("/player/taunt_bell.wav");
PrintToServer("Countdown Complete");
return Plugin_Stop;
}
}
if (iAmount > 0)
{
PrintCenterTextAll("Countdown: %i", iAmount);
iAmount--;
}
I went ahead and modified it a bit to my liking. You should use this version for following updates as it fixes a weird bug such as text overlapping (attached a screenshot of said bug to this reply).
I would also suggest fixing the "[SM] More than one client matched the given pattern." printing in chat when you run the command but don't specify a player. A player is going to be randomly selected anyways so there's no reason it should show up.
And restrict the ability to use @red, @blue, @all, etc... best to just limit it to @me and@aim when you want to not-so-randomly select a player as an alternative to typing their username.
Version 1.2 updated in original post with changes made by FluffPuro. I revised the text from words like 'chose' and 'has chosen' to 'selected'. That's because saying 'Bob has chosen Mary' sounds weird to me, and 'Bob chose Mary' sounds weird to you. 'Bob selected Mary' is my compromise.
Version 1.2 now requires morecolors.inc include file if you want to compile it yourself.
This version uses SourceMod 1.11 syntax. No new features since it already works as intended.
You don't need to install the morecolors.inc file unless you want to compile the plugin yourself. If so, you'll need to put the morecolors.inc file into your \sourcemod\scripting\include\ folder.