Modme Forums

How to play sound?

Game Modding | Call of Duty: Black Ops 3 | Scripting


ModmeBot:

Thread By: TCM
I know this has probably been asked before but for some reason I am trying to use

player PlayLocalSound("purchase_accept");


To play a sound, Really I just want to play a sound to the entire lobby when this easter egg for shooting perks to get a perk is done

I get an error saying player isn't recognized.


ModmeBot:

Reply By: Harry Bo21

TCM
I know this has probably been asked before but for some reason I am trying to use player PlayLocalSound("purchase_accept"); To play a sound, Really I just want to play a sound to the entire lobby when this easter egg for shooting perks to get a perk is done I get an error saying player isn't recognized.

lol i could answer this, although id hope its pretty obvious...

instead however, im gonna impart some wisdom and hope you take note

"heed my call oh young one, and take a spell to visit ye-olde SCRIPT_API from the documents folder included in thoust root folder, open in thy name using the great magic of the google chrome or other internet browser and try your salt with the "search / find" function and the keyword that seems relevent"

lol






maybe also look up what "local" means in regards to online gaming


ModmeBot:

Reply By: modric
players = GetPlayers();

foreach (player in players)
{

player Playsoundtoteam( "sound_alias" , "allies" );

}


ModmeBot:

Reply By: Abnormal202

TCM
I know this has probably been asked before but for some reason I am trying to use player PlayLocalSound("purchase_accept"); To play a sound, Really I just want to play a sound to the entire lobby when this easter egg for shooting perks to get a perk is done I get an error saying player isn't recognized.

if you want the whole lobby to hear it, then you should make it a 2D sound in it's alias. That means anyone on the map hears it equally loud. Then you'll want to use a playsound function and play it anywhere (since it's not a 3D sound, location doesn't matter). There are a lot of sound playing functions in the Modme Scriptdocs that you could use. For example:

PlaySoundAtPosition("sound",(0,0,0));


This would play it at point (0,0,0) in your map but since it's a 2D sound it doesn't matter where it plays, everyone will hear it.


ModmeBot:

Reply By: Harry Bo21

modric
players = GetPlayers(); foreach (player in players) { player Playsoundtoteam( "sound_alias" , "allies" ); }



2d soounds "should" be played like this ^ - although playsound "will" handle it yes - good practice says to try and use the appropriate functions tho obviously

but sadly modric also got it wrong


you have the function right, but you wouldnt use that in a loop, the function plays to all 4 players, so your saying play to all 4 players potentially 4 times in a row, with no delay

i assume you meant either - no loop - or - playSoundToPlayer


ModmeBot:

Reply By: TCM

Abnormal202
TCM I know this has probably been asked before but for some reason I am trying to use player PlayLocalSound("purchase_accept"); To play a sound, Really I just want to play a sound to the entire lobby when this easter egg for shooting perks to get a perk is done I get an error saying player isn't recognized. if you want the whole lobby to hear it, then you should make it a 2D sound in it's alias. That means anyone on the map hears it equally loud. Then you'll want to use a playsound function and play it anywhere (since it's not a 3D sound, location doesn't matter). There are a lot of sound playing functions in the Modme Scriptdocs that you could use. For example: PlaySoundAtPosition("sound",(0,0,0)); This would play it at point (0,0,0) in your map but since it's a 2D sound it doesn't matter where it plays, everyone will hear it.


Shouldn't this work?

PlaySoundAtPosition("mus_packapunch_sting",(self.origin));


EDIT: Did that with no luck of hearing the sound at all.. I just want it to play to everyone in the lobby.


ModmeBot:

Reply By: Harry Bo21

TCM
Abnormal202 TCM I know this has probably been asked before but for some reason I am trying to use player PlayLocalSound("purchase_accept"); To play a sound, Really I just want to play a sound to the entire lobby when this easter egg for shooting perks to get a perk is done I get an error saying player isn't recognized. if you want the whole lobby to hear it, then you should make it a 2D sound in it's alias. That means anyone on the map hears it equally loud. Then you'll want to use a playsound function and play it anywhere (since it's not a 3D sound, location doesn't matter). There are a lot of sound playing functions in the Modme Scriptdocs that you could use. For example: PlaySoundAtPosition("sound",(0,0,0)); This would play it at point (0,0,0) in your map but since it's a 2D sound it doesn't matter where it plays, everyone will hear it. Shouldn't this work? PlaySoundAtPosition("mus_packapunch_sting",(self.origin)); EDIT: Did that with no luck of hearing the sound at all.. I just want it to play to everyone in the lobby.

then your alias is prob wrong

again yes that "would work" but its not the way it should be done really

playSound and playSoundAtPosition are intended for 3d sounds


players = getPlayers();

foreach ( player in players )
{
	if ( isAlive( player ) )
	 level PlaySoundToPlayer( "alias", player );
 
}


ModmeBot:

Reply By: TCM

Harry Bo21
TCM Abnormal202 TCM I know this has probably been asked before but for some reason I am trying to use player PlayLocalSound("purchase_accept"); To play a sound, Really I just want to play a sound to the entire lobby when this easter egg for shooting perks to get a perk is done I get an error saying player isn't recognized. if you want the whole lobby to hear it, then you should make it a 2D sound in it's alias. That means anyone on the map hears it equally loud. Then you'll want to use a playsound function and play it anywhere (since it's not a 3D sound, location doesn't matter). There are a lot of sound playing functions in the Modme Scriptdocs that you could use. For example: PlaySoundAtPosition("sound",(0,0,0)); This would play it at point (0,0,0) in your map but since it's a 2D sound it doesn't matter where it plays, everyone will hear it. Shouldn't this work? PlaySoundAtPosition("mus_packapunch_sting",(self.origin)); EDIT: Did that with no luck of hearing the sound at all.. I just want it to play to everyone in the lobby. then your alias is prob wrong again yes that "would work" but its not the way it should be done really playSound and playSoundAtPosition are intended for 3d sounds players = getPlayers(); foreach ( player in players ) { if ( isAlive( player ) ) level PlaySoundToPlayer( "alias", player ); }



So Something like this

thread playwhenfinished();


function playwhenfinished()
{
players = getPlayers();
foreach ( player in players )
{
	if ( isAlive( player ) )
	 level PlaySoundToPlayer( "ee_finish", player );
 
}
}


ModmeBot:

Reply By: TCM

Harry Bo21
TCM Abnormal202 TCM I know this has probably been asked before but for some reason I am trying to use player PlayLocalSound("purchase_accept"); To play a sound, Really I just want to play a sound to the entire lobby when this easter egg for shooting perks to get a perk is done I get an error saying player isn't recognized. if you want the whole lobby to hear it, then you should make it a 2D sound in it's alias. That means anyone on the map hears it equally loud. Then you'll want to use a playsound function and play it anywhere (since it's not a 3D sound, location doesn't matter). There are a lot of sound playing functions in the Modme Scriptdocs that you could use. For example: PlaySoundAtPosition("sound",(0,0,0)); This would play it at point (0,0,0) in your map but since it's a 2D sound it doesn't matter where it plays, everyone will hear it. Shouldn't this work? PlaySoundAtPosition("mus_packapunch_sting",(self.origin)); EDIT: Did that with no luck of hearing the sound at all.. I just want it to play to everyone in the lobby. then your alias is prob wrong again yes that "would work" but its not the way it should be done really playSound and playSoundAtPosition are intended for 3d sounds players = getPlayers(); foreach ( player in players ) { if ( isAlive( player ) ) level PlaySoundToPlayer( "alias", player ); }


Yeah I have been trying this every way I could its not giving me the sound, I am also trying to add points when it does it as well but no luck there as well.

I know my threads are being called properly and working though as I added into it iprintlnbold messages that are showing fine.


ModmeBot:

Reply By: TCM
This is what I have right now doing that


function step_completed()
{
	level thread playsoundwhenshot();
	if(level.perk_steps_comp >= 7)
	{
		level thread playwhenfinished();
		thread ee_completed();
		
	}
}

function ee_completed()
{
	zm_powerups::specific_powerup_drop( "free_perk", level.perk_spawn.origin);
}

function playwhenfinished()
{
foreach(player in getPlayers())
{
	if ( isAlive( player ) )
	level PlaySoundToPlayer( "vox_invincible_song", player );
	player iprintlnbold("Test Finished");
	player zm_score::add_to_player_score(500);
}
}

function playsoundwhenshot()
{
foreach(player in getPlayers())
{
	if ( isAlive( player ) )
	level PlaySoundToPlayer( "vox_invincible_song", player );	
	player zm_score::add_to_player_score(75);
	player iprintlnbold("Test Has Been Shot");
}
}


EDIT: Points are given but still, No sounds are ever played.

EDIT: BELIEVE I FINALLY GOT IT THANKS.