Raised This Month: $12 Target: $400
 3% 

Help playing a sound


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
honorcode23
BANNED
Join Date: Mar 2010
Location: Chile
Old 03-27-2010 , 21:30   Help playing a sound
Reply With Quote #1

Hey guys, im a newbie using c++ language, so it is really hard to me to realise how to do basic stuff. I tried to make a simple plugin, for Left 4 dead 2, to simply spawn a horde or panic event every time i wrote a command.

Indeed, it is working, but i'd like to play a sound when the panic event occurs.
This sound is allocated on GameFolder/left4dead2/music/the_end/finalnail.wav and, from the source of some aproved plugins, and reading around here, i figured how to play a sound. But, it isn't working and i don't know what to do next.

If someone could help me, i would really appreciate it.

Here's the code

PHP Code:
#include <sourcemod>
#include <sdktools>
#define PLUGIN_VERSION "1.0"
#define SOUND_SPAWN "music/the_end/finalnail.wav"

public Plugin:myinfo =
{
    
name "Spawn_Horde",
    
author "unnamed",
    
description "Spawn Horde",
    
version PLUGIN_VERSION,
    
url ""
}

public 
OnPluginStart ()
{
    
CreateConVar("l4d2_hordespawner_version"PLUGIN_VERSION"Horde spawner version"FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_NOTIFY|FCVAR_DONTRECORD);

    
RegConsoleCmd("sm_spawnmob"CmdSpawnMob);
    
RegConsoleCmd("sm_spawnmmob"CmdSpawnMegaMob);
}

public 
OnMapStart()
{
    if (!
IsSoundPrecached(SOUND_SPAWN))
        
PrecacheSound(SOUND_SPAWNtrue)
}        

public 
Action:CmdSpawnMob(clientargs)
{
    
CheatCommand(client"z_spawn""mob");
    return 
Plugin_Handled;
}

public 
Action:CmdSpawnMegaMob(clientargs)
{
    
CheatCommand(client"director_force_panic_event""director_force_panic_event");
        
EmitSoundToAll(SOUND_SPAWN);
    return 
Plugin_Handled;
}

CheatCommand(client, const String:command [], const String:arguments [])
{
    if (!
client) return;
    new 
admindata GetUserFlagBits(client);
    
SetUserFlagBits(clientADMFLAG_ROOT);
    new 
flags GetCommandFlags (command);
    
SetCommandFlags(commandflags & ~FCVAR_CHEAT);
    
FakeClientCommand(client"%s %s"commandarguments);
    
SetCommandFlags(commandflags);
    
SetUserFlagBits(clientadmindata)

Thanks in advance, for you patient and support.

Last edited by honorcode23; 03-28-2010 at 10:11. Reason: Changed to PHP instead of CODe
honorcode23 is offline
kossolax
AlliedModders Donor
Join Date: Jan 2008
Location: Belgium
Old 03-28-2010 , 04:37   Re: Help playing a sound
Reply With Quote #2

This work in CSS, no idea about l4d2:
PHP Code:
for(new i=1i<=GetMaxClients(); i++) {
    if( !
IsClientInGame(i) )
        continue;
        
    
ClientCommand(i"play %s"SOUND_SPAWN);

kossolax is offline
honorcode23
BANNED
Join Date: Mar 2010
Location: Chile
Old 03-28-2010 , 10:08   Re: Help playing a sound
Reply With Quote #3

Thanks, i'll try it inmediatly

Edit:

THANKS!, it is really working!. Now my people inside gets really scared when i call a horde xD

You made my day. Thanks!!

Last edited by honorcode23; 03-28-2010 at 10:35.
honorcode23 is offline
noodleboy347
AlliedModders Donor
Join Date: Mar 2009
Old 03-28-2010 , 12:16   Re: Help playing a sound
Reply With Quote #4

Quote:
Originally Posted by kossolax View Post
This work in CSS, no idea about l4d2:
PHP Code:
for(new i=1i<=GetMaxClients(); i++) {
    if( !
IsClientInGame(i) )
        continue;
        
    
ClientCommand(i"play %s"SOUND_SPAWN);

You should use MAXPLAYERS instead of GetMaxClients();
noodleboy347 is offline
honorcode23
BANNED
Join Date: Mar 2010
Location: Chile
Old 03-28-2010 , 12:20   Re: Help playing a sound
Reply With Quote #5

Quote:
Originally Posted by noodleboy347 View Post
You should use MAXPLAYERS instead of GetMaxClients();
As i know, MAXPLAYERS is the maximum amount of player that SourceMod can handle. So it might play the sound to bots too, am i wrong?
honorcode23 is offline
pheadxdll
AlliedModders Donor
Join Date: Jun 2008
Old 03-28-2010 , 14:00   Re: Help playing a sound
Reply With Quote #6

Code:
EmitSoundToAll(SOUND_SPAWN);
It'll save you a few lines of code.
pheadxdll is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 03-28-2010 , 15:09   Re: Help playing a sound
Reply With Quote #7

honorcode23: and what?
__________________
Leonardo is offline
Dragonshadow
BANNED
Join Date: Jun 2008
Old 03-28-2010 , 16:20   Re: Help playing a sound
Reply With Quote #8

Quote:
Originally Posted by noodleboy347 View Post
You should use MAXPLAYERS instead of GetMaxClients();
Quote:
Originally Posted by honorcode23 View Post
As i know, MAXPLAYERS is the maximum amount of player that SourceMod can handle. So it might play the sound to bots too, am i wrong?
No, you should use MaxClients

MAXPLAYERS is for array init, GetMaxClients() is deprecated
Dragonshadow is offline
peteraugusts
New Member
Join Date: Mar 2010
Old 03-31-2010 , 09:17   Re: Help playing a sound
Reply With Quote #9

I used MaxClients instead of GetMaxClients() but i got error.not play a sound.Is there any way to play sound?
__________________
r4
peteraugusts is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 03-31-2010 , 09:55   Re: Help playing a sound
Reply With Quote #10

just debug before where command to play sound
__________________
Leonardo is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:53.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode