SnZ
01-31-2012, 21:45
Hello,
I've tryed to play sound but I have problem with loop.
The problem is when I trigger sound playing at "tank_spawn" it won't stop.
Was searching through forums and google, but I'm lost, nothing work as I need.
//Include sourcemod
#include <sourcemod>
#include <sdktools>
#define MUSIC_FILE "vehicles/car_alarm/car_alarm.wav"
public OnPluginStart()
{
HookEvent("tank_spawn", tank_spawn);
}
public OnMapStart()
{
PrecacheSound(MUSIC_FILE);
}
public Action:tank_spawn(Handle:event, String:event_name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
//EmitSoundToAll(MUSIC_FILE, client, true, 1);
EmitSoundToAll(MUSIC_FILE, client, SNDCHAN_AUTO, SNDLEVEL_NORMAL, SND_NOFLAGS, SNDVOL_NORMAL, SNDPITCH_NORMAL, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0 );
}
For example: music file have 0: 30seconds, so I want to only play this 30 seconds then stop playing.
Is there any chance to do this?
Thanks in advance
I've tryed to play sound but I have problem with loop.
The problem is when I trigger sound playing at "tank_spawn" it won't stop.
Was searching through forums and google, but I'm lost, nothing work as I need.
//Include sourcemod
#include <sourcemod>
#include <sdktools>
#define MUSIC_FILE "vehicles/car_alarm/car_alarm.wav"
public OnPluginStart()
{
HookEvent("tank_spawn", tank_spawn);
}
public OnMapStart()
{
PrecacheSound(MUSIC_FILE);
}
public Action:tank_spawn(Handle:event, String:event_name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
//EmitSoundToAll(MUSIC_FILE, client, true, 1);
EmitSoundToAll(MUSIC_FILE, client, SNDCHAN_AUTO, SNDLEVEL_NORMAL, SND_NOFLAGS, SNDVOL_NORMAL, SNDPITCH_NORMAL, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0 );
}
For example: music file have 0: 30seconds, so I want to only play this 30 seconds then stop playing.
Is there any chance to do this?
Thanks in advance