PHP Code:
#pragma semicolon 1
#define PLUGIN_AUTHOR "z4cH3r"
#define PLUGIN_VERSION "1.00"
#include <sourcemod>
#include <emitsoundany>
#pragma newdecls required
#define SoundOnJoin "JOINSOUND/FILENAME.mp3"
ConVar g_cvJoinSoundVolume = null;
public Plugin myinfo =
{
name = "Joinsound",
author = PLUGIN_AUTHOR,
description = "Play sound to players when they connect",
version = PLUGIN_VERSION,
url = ""
}
public void OnPluginStart()
{
g_cvJoinSoundVolume = CreateConVar("sm_joinsound_volume", "1.0", "Volume of joinsound (1 = default)");
}
public void OnMapStart()
{
char szFormat[MAX_NAME_LENGTH];
FormatEx(szFormat, sizeof(szFormat), "sound/%s", SoundOnJoin);
AddFileToDownloadsTable(szFormat);
PrecacheSoundAny(SoundOnJoin);
}
public void OnClientPostAdminCheck(int client)
{
CreateTimer(8.0, Play_JoinSound, GetClientUserId(client));
}
public Action Play_JoinSound(Handle timer, any userid)
{
int client = GetClientOfUserId(client);
if(IsClientValid(client))
EmitSoundToClientAny(client, SoundOnJoin, _, _, _, _, g_cvJoinSoundVolume.FloatValue);
}
stock bool IsClientValid(int client)
{
if(client > 0 && client <= MaxClients && IsClientInGame(client))
return true;
return false;
}
notes
*you will need EmitSoundAny for compile
https://forums.alliedmods.net/showthread.php?t=237045
*the volume thing is taken from some other join sound plugin