Unable to play a sound with ClientPlaySound

Discussions about Coding and Scripting
Inpu
Novice
Posts: 12
Joined: Thu Apr 04, 2024 1:10 pm

Unable to play a sound with ClientPlaySound

Post by Inpu »

Hi !

I'm trying to do a simple thing : playing a sound for a PlayerPawn, using an existing sound.

My code if as follow:

Code: Select all

PlayerPawn(Killer).ClientPlaySound(sound'Announcer.Multikill');
But the sound doesn't play.

I'm 100% that "Killer" is valid as I can send him a message with ClientMessage.

Am I missing something obvious ?

I've alsy tried :

Code: Select all

PlayerPawn(Killer).ClientPlaySound(sound'Announcer.Multikill, true, true');
Or :

Code: Select all

PlayerPawn(Killer).ClientPlaySound(sound'Announcer.Multikill',, true);
Still no luck.

Thanks !
User avatar
Barbie
Godlike
Posts: 2923
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Unable to play a sound with ClientPlaySound

Post by Barbie »

Inpu wrote: Fri Apr 05, 2024 7:46 am Hi !

I'm trying to do a simple thing : playing a sound for a PlayerPawn, using an existing sound.

My code if as follow:

Code: Select all

PlayerPawn(Killer).ClientPlaySound(sound'Announcer.Multikill');
That should work; your other variants are wrong and cannot work - always have a look at the UnrealTournament.log!
<EDIT>
Your variant PlayerPawn(Killer).ClientPlaySound(sound'Announcer.Multikill',, true); should work, too.
</EDIT>
Little test Actor:

Code: Select all

class SoundMaker expands Actor;

function Trigger( actor Other, pawn EventInstigator ) {
local pawn P;

	PlayerPawn(EventInstigator).ClientPlaySound(sound'Announcer.Multikill');
}
Test map with Actor "SoundMaker" attached.
You do not have the required permissions to view the files attached to this post.
"If Origin not in center it be not in center." --Buggie
Inpu
Novice
Posts: 12
Joined: Thu Apr 04, 2024 1:10 pm

Re: Unable to play a sound with ClientPlaySound

Post by Inpu »

Thanks for the reply!

The class where I'm running this code is extending "UBrowserHTTPClient", and not "Mutator" or "Actor". Could that be the issue ?
Eternity
Skilled
Posts: 178
Joined: Sat Nov 30, 2019 10:56 pm

Re: Unable to play a sound with ClientPlaySound

Post by Eternity »

Issue (one of them) could be, for example, that the sound object is not loaded on the client side...
User avatar
Barbie
Godlike
Posts: 2923
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Unable to play a sound with ClientPlaySound

Post by Barbie »

Show more of your code to investigate deeper.
"If Origin not in center it be not in center." --Buggie
Inpu
Novice
Posts: 12
Joined: Thu Apr 04, 2024 1:10 pm

Re: Unable to play a sound with ClientPlaySound

Post by Inpu »

Eternity wrote: Fri Apr 05, 2024 6:42 pm Issue (one of them) could be, for example, that the sound object is not loaded on the client side...
It's a sound that exist by default so It should always be loaded I guess ?   
Auto merged new post submitted 1 minute later
Barbie wrote: Fri Apr 05, 2024 8:08 pm Show more of your code to investigate deeper.
It's pretty simple actually :

Code: Select all

function logKillEvent(Pawn Killer, Pawn Other){
	        PlayerPawn(Other).ClientPlaySound(sound'Announcer.Multikill');
	        PlayerPawn(Other).ClientMessage("Hello there!", 'Event', true);
}
The "Hello there!" is working properly, but not the sound
User avatar
Barbie
Godlike
Posts: 2923
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Unable to play a sound with ClientPlaySound

Post by Barbie »

Maybe the BEEP overrides the sound? Have you tried without ClientMessage or beep?

Code: Select all

event ClientMessage( coerce string S, optional Name Type, optional bool bBeep )
"If Origin not in center it be not in center." --Buggie
Inpu
Novice
Posts: 12
Joined: Thu Apr 04, 2024 1:10 pm

Re: Unable to play a sound with ClientPlaySound

Post by Inpu »

Great idea, I set the bBeep to false but it didn't change anything unfortunately :(

Definitely at a loss here ^^
Eternity
Skilled
Posts: 178
Joined: Sat Nov 30, 2019 10:56 pm

Re: Unable to play a sound with ClientPlaySound

Post by Eternity »

Inpu wrote: Mon Apr 08, 2024 6:33 amIt's a sound that exist by default so It should always be loaded I guess ?
The fact a package with the sound object exists at the client side doesn't mean it should be always loaded.
But if your client side code contains a direct reference to that sound, then yes, it should be always loaded.

Client might have a modified Announcer.uax package, overwritten by something different with the same name when installed some map or mod. There might be conflicting package names, or some else issues... (need more info to figure out what is the issue)
User avatar
Barbie
Godlike
Posts: 2923
Joined: Fri Sep 25, 2015 9:01 pm
Location: moved without proper hashing

Re: Unable to play a sound with ClientPlaySound

Post by Barbie »

Wait... are you talking about playing sound on client from a server? This has never worked for me, I always had to extract the sounds from package "Botpack.u" and imported them into MyLevel.
"If Origin not in center it be not in center." --Buggie
Eternity
Skilled
Posts: 178
Joined: Sat Nov 30, 2019 10:56 pm

Re: Unable to play a sound with ClientPlaySound

Post by Eternity »

Because OP mentioned "UBrowserHTTPClient" i think that code is probably being run client side (i don't get why doesn't it play in this case then).

If it is actually called from the server, then of course it is necessary to make sure the client has this sound loaded. You can DLO any existing client side sound objects via RPC prior to play it, the sound should be playing properly then.

By the way, client side logs may contain some useful info about the issue - need to look into them...
Inpu
Novice
Posts: 12
Joined: Thu Apr 04, 2024 1:10 pm

Re: Unable to play a sound with ClientPlaySound

Post by Inpu »

Thanks! I'll check that out