Scripts / Need help with random sound script.

Author
Message
Disturbing 13
3D Media Maker
19
Years of Service
User Offline
Joined: 12th Apr 2005
Location: Murder Capital of the World
Posted: 27th Jun 2016 08:22 Edited at: 27th Jun 2016 08:55
Please let me preface this request with - I have no ability to script/program. I am willing to help out anyone who helps me with art assets that I can provide. With that, I have a request.
I need to be able to press the left mouse button and have one of 10 random sounds in a folder play. The only real specification is that the sound has to be able to fully play; even if the left mouse button is pressed again, a second sound cannot interrupt the currently playing sound. If I have to make each sound the same length to do so would be fine. I tried again to combine scripts that I found on the forums to no avail. I truly admire you guys who script as I am totally inept at it. I wish there was a script request board like 3d models and media has for those who are more skilled and want to help or those who are learning can cut their teeth with a variety of request. Thanks to any who can help me in this endeavor.

EDIT:- Here are the snippits I have been trying to cobble together-


cybernescence
GameGuru Master
11
Years of Service
User Offline
Joined: 28th Jan 2013
Playing: Cogwheel Chronicles
Posted: 27th Jun 2016 12:06
When do you want this to happen? Whenever a player left clicks so if armed the gun will fire and random sound also plays ? Or only when player doesn't have a weapon or something else? Cheers.
Disturbing 13
3D Media Maker
19
Years of Service
User Offline
Joined: 12th Apr 2005
Location: Murder Capital of the World
Posted: 27th Jun 2016 16:24
Greetings Cybernescence! I would like this to happen with a gun. The weapon will be silent and I can I can make the fire animation last as long as necessary. The important parts to this are 1. playing one of a random sound from a specific sound bank each time the left mouse button is clicked and 2. The sounds do not overlap each other.
Thanks for your interest in helping me. If you need anything model wise I would be more than willing to help.
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 27th Jun 2016 17:27


Quote: "1. playing one of a random sound from a specific sound bank each time the left mouse button is clicked and 2. The sounds do not overlap each other. "


It should be something like this, thought. Do not touch sounds commands yet, and it is untested yet.



Ignore if you has to merge this with some weapon to get it playing yours sound instead of their own; or perhaps you've your own weapon model, with your own anims, so you can use it to fit yours needs.

Do you need mouse working to in the script?

Sorry man, not time now to right a most elaborate script.

hth

3com


Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics

PM
Disturbing 13
3D Media Maker
19
Years of Service
User Offline
Joined: 12th Apr 2005
Location: Murder Capital of the World
Posted: 27th Jun 2016 18:14 Edited at: 27th Jun 2016 18:15
Hey 3com! Thanks for your help. The weapon itself need not contain the sounds, in fact I would prefer it not to so that I can change the soundset with each level.

Quote: "Do you need mouse working to in the script?"

I'm not sure what you mean by this. The very basic of what I need is -

If the Leftmouse button is pressed(or clicked),
Then play random sound (1-10) from a specified folder
In the folder would be-
sound1.ogg
sound2.ogg
sound3.ogg
sound4.ogg
sound5.ogg , ect.

Hope that helps clear things up.
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 27th Jun 2016 18:24 Edited at: 27th Jun 2016 18:24
you say
Quote: "a second sound cannot interrupt the currently playing sound"
and
Quote: " The sounds do not overlap each other. "

so does this mean the previous sound should stop if the gun is fired again? or the gun can't be fired again until the first sound is done? (the later i dont think is really possible via scripting and would require the firerate or something to be adjusted in the gunspec.txt)
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
Disturbing 13
3D Media Maker
19
Years of Service
User Offline
Joined: 12th Apr 2005
Location: Murder Capital of the World
Posted: 27th Jun 2016 18:47
Sup Smallg! The sound would need to be able to play fully before any other sound from the script could be played. If it needed to be timed I could make each sound a specific length if that helps. as for the weapon fireing , I can take care of the length of time before you can fire. Thanks!
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 27th Jun 2016 18:54 Edited at: 27th Jun 2016 18:55
well the sound will play as long as the fire rate is longer/slower than the sound so this script will work fine (if the fire rate is fast then the sound will get stopped but you can remove the StopGlobalSound() line, though this would make the sounds overlap)
so remove any sounds from the gunspec.txt and adjust the fire speed to suit the sounds you have (making all sounds roughly equal in length will give best results), instructions for set up are in with the settings
oh and of course this will need to be set to an always active = yes, static = no entity
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11

Attachments

Login to view attachments
Disturbing 13
3D Media Maker
19
Years of Service
User Offline
Joined: 12th Apr 2005
Location: Murder Capital of the World
Posted: 28th Jun 2016 00:46 Edited at: 28th Jun 2016 00:48
Thank You so very much! The project I'm working on so hinges on this mechanic. I'm going to get some sounds together and give this puppy a whirl tonight. I'll report back on how well it works. If you need anything within my power, please don't hesitate to ask.
Disturbing 13
3D Media Maker
19
Years of Service
User Offline
Joined: 12th Apr 2005
Location: Murder Capital of the World
Posted: 28th Jun 2016 09:52
Greetings, I'm here to report that it works like a charm! There is some odd static right before each sound but it actually works for my purposes. Thank You so much! PM me anytime you need me for anything!
smallg
Community Leader
19
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 28th Jun 2016 14:49
I tested with stock sounds and didn't notice any odd static so might be something in the sounds you're using? (To be fair I used stock guns that already had sounds playing so it was hard to tell, perhaps simply having no sound set for a gun causes the issue alone?)

Otherwise happy to help and glad its working for your needs
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11

Login to post a reply

Server time is: 2024-12-22 18:38:30
Your offset time is: 2024-12-22 18:38:30