UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

Play sound

HOT
broken avatar :(
Created 10 years ago
by fanmagic
0 Members and 1 Guest are viewing this topic.
11,734 views
broken avatar :(
×
broken avatar :(
Location: deDortmund
Date Registered: 20 December 2015
Last active: 2 years ago
Posts
307
Respect
Forum Rank
Perk Hacker
Primary Group
Scripter
My Groups
More
Personal Quote
Payback
Signature
Tears Of The Fallen | Join the project https://discord.gg/8gDNQRj
×
fanmagic's Groups
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
fanmagic's Contact & Social LinksTears Of The Fallen
Hello guys,
today i want to know how i can play a sound after a player use a trigger. I also need to know how i can convert the sounds or something like this and where i have to place the soundfile.

I would like to play the sound in this function:

Code Snippet
Plaintext
main()
{
trig = getEnt ("mysound","targetname");
trig setHintString ("Press &&1 to play sound");
trig setCursorHint ("HINT_NOICON");
trig UseTriggerRequireLookAt();
trig waittill ("trigger");
trig Delete();

        //////// Play sound here \\\\\\\\
}

Thanks for your help.

-fanmagic.

If you could give an example i will be very thankful coz i'm a noob in scripting.
This topic contains a post which is marked as the Best Answer. Click here to view it.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 11 March 2014
Last active: 5 years ago
Posts
264
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
Signature
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."
×
buttkicker845's Groups
buttkicker845's Contact & Social Links
you can do it by using playSound which will make it sound like the sound is coming from the entity its self.
heres the link to its discription http://ugx-mods.com/script/#core.Sound.playSound
Code Snippet
Plaintext
trig ("soundAlias", "sounddone");
trig waittill("sounddone");//will wait until the sound is finished playing
heres a tutorial on how to make custom sounds its for main menu but can be used for this as well
https://confluence.ugx-mods.com/display/UGXMODS/Custom+Main+Menu+Music
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 6 years ago
Posts
6,875
Respect
Forum Rank
Immortal
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
Signature
If you want scripts / features made for you, then contact me by PM or email / skype etc
it will cost you tho so if you have no intention of reciprocating don't even waste my time ;)
×
Harry Bo21's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Harry Bo21's Contact & Social LinksHarryBo000[email protected]HarryBo21
you can do it by using playSound which will make it sound like the sound is coming from the entity its self.
heres the link to its discription http://ugx-mods.com/script/#core.Sound.playSound
Code Snippet
Plaintext
trig ("soundAlias", "sounddone");
trig waittill("sounddone");//will wait until the sound is finished playing
heres a tutorial on how to make custom sounds its for main menu but can be used for this as well
https://confluence.ugx-mods.com/display/UGXMODS/Custom+Main+Menu+Music
do not play sounds "on" triggers, it makes models spawn randomly

spawn a ent,, play on that then delete
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 27 January 2015
Last active: 10 years ago
Posts
337
Respect
Forum Rank
Perk Hacker
Primary Group
Member
Signature
×
liamsa669's Groups
liamsa669's Contact & Social Links
do not play sounds "on" triggers, it makes models spawn randomly

spawn a ent,, play on that then delete
y not do sountatpos()?
Code Snippet
Plaintext
playsoundatposition("mortar_dirt", origin);
that way all u need is the soundallieas name and the origin
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 11 March 2014
Last active: 5 years ago
Posts
264
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
×
buttkicker845's Groups
buttkicker845's Contact & Social Links
y not do sountatpos()?
Code Snippet
Plaintext
playsoundatposition("mortar_dirt", origin);
that way all u need is the soundallieas name and the origin
From what I've read in 3archs scripts playsoundatposition is really only used for playing sounds on players. Or at least that's the only time they use it in _ambientPackage.

do not play sounds "on" triggers, it makes models spawn randomly

spawn a ent,, play on that then delete
ive never seen this. When you say it makes models spawn randomly what do you mean exactly?
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 27 January 2015
Last active: 10 years ago
Posts
337
Respect
Forum Rank
Perk Hacker
Primary Group
Member
×
liamsa669's Groups
liamsa669's Contact & Social Links
From what I've read in 3archs scripts playsoundatposition is really only used for playing sounds on players. Or at least that's the only time they use it in _ambientPackage.
ive never seen this. When you say it makes models spawn randomly what do you mean exactly?
they use for the blockers that u  buy.. _zombiemode_blockers.gsc:438  _zombiemode_blockers_new.gsc:197 _zombiemode_dogs.gsc:316

this is the best method for 3d sounds... but 2d sounds i recommend playsound()
Marked as best answer by fanmagic 10 years ago
broken avatar :(
×
broken avatar :(
Location: nl
Date Registered: 22 September 2013
Last active: 6 months ago
Posts
326
Respect
Forum Rank
Perk Hacker
Primary Group
Mapper
My Groups
More
Personal Quote
Zombie Mapper and Gamer
Signature
My Custom Zombie Maps:

- Nazi zombie Legion
- City of Hell
- The Abandoned Mine
- The Last Undead House (Finished)

more custom zombie maps coming soon
×
gamer9294's Groups
Mapper Has released one or more maps to the UGX-Mods community.
gamer9294's Contact & Social Links
hi man,

I have also made a video how you know need to make sound or song playing by a trigger.

https://www.youtube.com/watch?v=v02mCfx0h4Q  - Part 1
https://www.youtube.com/watch?v=K8zOINWP5hE - Part 2

I hope that it will help you out of the problem.

in the video I will show you how you need to convert the sound file and where you need to place them and also I have a simple script made that you can use it.

I will explain all that in the video and maybe more ;)


Best regards,
Gamer9294
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 11 March 2014
Last active: 5 years ago
Posts
264
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
×
buttkicker845's Groups
buttkicker845's Contact & Social Links
they use for the blockers that u  buy.. _zombiemode_blockers.gsc:438  _zombiemode_blockers_new.gsc:197 _zombiemode_dogs.gsc:316

this is the best method for 3d sounds... but 2d sounds i recommend playsound()
from looking at _ambientpackage and those 3 scripts i dont think it matters between 2d and 3d sounds. it looks is it is based on a combination of scripter preference and if said scripter wants the thread to stop and wait for the sound to end or not
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 6 years ago
Posts
6,875
Respect
Forum Rank
Immortal
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Harry Bo21's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Harry Bo21's Contact & Social LinksHarryBo000[email protected]HarryBo21
From what I've read in 3archs scripts playsoundatposition is really only used for playing sounds on players. Or at least that's the only time they use it in _ambientPackage.
ive never seen this. When you say it makes models spawn randomly what do you mean exactly?
trust me it does, took me forever to find out why a random zombie pair of legs kept appearing at my pap - that was why


same thing happened to sethnorris, again by playing his sound during firesales on the trigger
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 11 March 2014
Last active: 5 years ago
Posts
264
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
×
buttkicker845's Groups
buttkicker845's Contact & Social Links
i trust you, it just sounds really weird for an engine function to randomly spawn models like that. but then again it is WAW so lots of weird things happen with the engine
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 6 years ago
Posts
6,875
Respect
Forum Rank
Immortal
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Harry Bo21's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Harry Bo21's Contact & Social LinksHarryBo000[email protected]HarryBo21
i trust you, it just sounds really weird for an engine function to randomly spawn models like that. but then again it is WAW so lots of weird things happen with the engine
I think its coz it cannot use a trigger to do it, so spawns a ent so it can - and assigns a random model

my theory anyway
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 10 years ago
Posts
2,789
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
Signature
Let's keep this thread on topic from here on in. -DBZ

+1 to off-topic reply -DBZ

lmao. Too funny.

Goliath Script Placer: http://ugx-mods.com/forum/index.php/topic,11234.msg125257/topicseen.html#new

"...Christ, people. Learn C, instead of just stringing random characters
together until it compiles (with warnings)..."

-Linus Torvalds
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
Code Snippet
Plaintext
playsoundatposition()

Works just fine, however...

Code Snippet
Plaintext
playSound()

is a bit strange. Looks like it spawns an entity near origin (0,0,0) and only plays the sound at that origin instead of the specified entity. Perhaps its because i'm using trigger_radius's for triggers... not really sure TBH.

You can try play_sound_on_entity...

Quote
I think its coz it cannot use a trigger to do it, so spawns a ent so it can - and assigns a random model

Sounds more like an extremely bad script runtime error screwing with the engine.

Had something random like that happen WAY back when i started scripting and didn't know anything - tried creating an alternate power switch and it would always become an STG or FG42 buy trigger, was like: "WTF!?". The trigger had literally nothing to do with the weapon buy trigs and wasn't anywhere near them.

Turns out it was because I didn't have the actual power switch in the map... or atleast that fixed the trigger bug.  :poker:

i trust you, it just sounds really weird for an engine function to randomly spawn models like that. but then again it is WAW so lots of weird things happen with the engine

Assuming your talking purely scripting...

99% of that is from people not debugging their scripts and running code on undefined entities/objects(script runtime errors) or general logic fails. That is entirely on the person who made the code, not the engine.  Given how bad some of the scripts people use are at times, I'm shocked the CoD engine doesn't implode more often.
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 6 years ago
Posts
6,875
Respect
Forum Rank
Immortal
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Harry Bo21's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Harry Bo21's Contact & Social LinksHarryBo000[email protected]HarryBo21
Code Snippet
Plaintext
playsoundatposition()

Works just fine, however...

Code Snippet
Plaintext
playSound()

is a bit strange. Looks like it spawns an entity near origin (0,0,0) and only plays the sound at that origin instead of the specified entity. Perhaps its because i'm using trigger_radius's for triggers... not really sure TBH.

You can try play_sound_on_entity...

Sounds more like an extremely bad script runtime error screwing with the engine.

Had something random like that happen WAY back when i started scripting and didn't know anything - tried creating an alternate power switch and it would always become an STG or FG42 buy trigger, was like: "WTF!?". The trigger had literally nothing to do with the weapon buy trigs and wasn't anywhere near them.

Turns out it was because I didn't have the actual power switch in the map... or atleast that fixed the trigger bug.  :poker:

Assuming your talking purely scripting...

99% of that is from people not debugging their scripts and running code on undefined entities/objects(script runtime errors) or general logic fails. That is entirely on the person who made the code, not the engine.  Given how bad some of the scripts people use are at times, I'm shocked the CoD engine doesn't implode more often.
there was nothing wrong with mine or seths code, was literally just caused by calling play sound on a trigger use...

You may notice in treyarchs scripts they never play a sound "on" a trigger - possibly because of this. This is how I worked it out, spawn a ent to play on now and it's fine

Play sound at position is what treyarch do tho yea, just means it has to finish, can't end it early
Last Edit: March 30, 2016, 11:02:51 pm by Harry Bo21
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 11 March 2014
Last active: 5 years ago
Posts
264
Respect
Forum Rank
Mr. Elemental
Primary Group
Member
×
buttkicker845's Groups
buttkicker845's Contact & Social Links
Play sound at position is what treyarch do tho yea, just means it has to finish, can't end it early
with playSoundAtPosition will the current thread wait until the sound is finished like it would with playSound?
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 6 years ago
Posts
6,875
Respect
Forum Rank
Immortal
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Harry Bo21's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Harry Bo21's Contact & Social LinksHarryBo000[email protected]HarryBo21
with playSoundAtPosition will the current thread wait until the sound is finished like it would with playSound?
no

But playsound() actually doesn't either, it just notifies "sound_done" at the end or whatever, so people usually add the following to "make" it wait

Soundobject waittill( "sound_done" );

 
Loading ...