PDA

View Full Version : [L4D2] tank_spawn trigger & sound problems


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

SnZ
02-01-2012, 14:47
*bump*

anybody? :(

McFlurry
02-01-2012, 16:23
StopSound() (http://docs.sourcemod.net/api/index.php?fastload=show&id=678&)

SnZ
02-01-2012, 17:05
Thanks

disawar1
02-02-2012, 12:56
//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)
{
EmitSoundToAll(MUSIC_FILE);
CreateTimer(30.0, Timer);
}

public Action:Timer(Handle:timer)
{
for (new i = 1; i <= MaxClients; i++){

if (IsClientInGame(i) && !IsFakeClient(i))
StopSound(i, SNDCHAN_AUTO, MUSIC_FILE);
}
}

SnZ
02-03-2012, 04:10
[PHP]//Include sourcemod
#include <sourcemod>
#include <sdktools>
...

Wow, many thanks for this disawar1!

I appreciate your effort :)

disawar1
02-03-2012, 05:02
I'm glad that I helped you, can u help me now ? (http://forums.alliedmods.net/showthread.php?t=177545) :) :) :)

SnZ
02-03-2012, 05:09
Huh I want to, but I'm too fresh in coding :(

(Writed pm, because had also another question :P)