Not Tested.
You need to change the sound path on JOIN_SOUND define.
PHP Code:
#include <sourcemod>
#include <sdktools>
#pragma semicolon 1
#pragma newdecls required
#define JOIN_SOUND "example/sound1.wav"
ConVar g_cPlayTime;
Handle JoinTimer[MAXPLAYERS+1];
public Plugin myinfo =
{
name = "[ANY] Join Music",
description = "Plays music to a player on connect.",
author = "Tair",
version = "1.0",
url = ""
};
public void OnPluginStart()
{
g_cPlayTime = CreateConVar("sm_music_time", "5.0", "The time it takes until the timer plays the music", 0, false, 0.0, false, 0.0);
}
public void OnMapStart()
{
PrecacheSound(JOIN_SOUND);
AddFileToDownloadsTable("sound/" ... JOIN_SOUND);
}
public void OnClientPutInServer(int client)
{
JoinTimer[client] = CreateTimer(g_cPlayTime.FloatValue, MusicTimer, client, 0);
}
public void OnClientDisconnect(int client)
{
if (JoinTimer[client] != null)
{
delete JoinTimer[client];
}
}
public Action MusicTimer(Handle timer, any client)
{
EmitSoundToClient(client, JOIN_SOUND, -2, 0, 75, 0, 1.0, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
delete JoinTimer[client];
return Plugin_Handled;
}
__________________