Post: How do i make a sound play every second without repeating a code?
04-24-2017, 06:42 PM #1
xSins
Bounty hunter
(adsbygoogle = window.adsbygoogle || []).push({}); I Need This For My Project!Tustin
04-24-2017, 08:59 PM #2
anthonything
Space Ninja
Originally posted by ManningCFW View Post
I Need This For My Project!Tustin


Use a while loop and a wait.
    
while( true )
{
//replace this line with your "play sound code"
wait 1; // Waits 1 second
}

The following user thanked anthonything for this useful post:

xSins
04-25-2017, 01:03 PM #3
MrXcell1
Pokemon Trainer
You mean like:
playSound(sound)
{
self playlocalsound(sound);
self iPrintln(sound +" played!");
}

Then when you wanna call it...::

::playSound, "put sound here");
04-25-2017, 08:44 PM #4
Hydrogen
Super Mod
Originally posted by ManningCFW View Post
I Need This For My Project!Tustin


I'm not a programmer, but I can probably answer this myself lmao.

You make your function name, insert the commands in it (playing whatever the sound it is) then make sure you add loops in order to make it keep going without actually needing to do it yourself all the time. Whenever you want at the end, call the function by pressing whatever the function name was before.

Hopefully I answered a question I wouldn't know, but I did learn a lil sum in my CS class Claps
04-25-2017, 08:48 PM #5
xSins
Bounty hunter
Originally posted by Hydrogen View Post
I'm not a programmer, but I can probably answer this myself lmao.

You make your function name, insert the commands in it (playing whatever the sound it is) then make sure you add loops in order to make it keep going without actually needing to do it yourself all the time. Whenever you want at the end, call the function by pressing whatever the function name was before.

Hopefully I answered a question I wouldn't know, but I did learn a lil sum in my CS class Claps


what is the code for loops? return;? repeat;?
04-25-2017, 09:09 PM #6
Hydrogen
Super Mod
Originally posted by ManningCFW View Post
what is the code for loops? return;? repeat;?


Wouldn't be able to help you man. I just know the understanding of programming, but sadly never got into it. Hope someone helps you out with the code, good luck!
04-25-2017, 11:11 PM #7
anthonything
Space Ninja
Originally posted by Hydrogen View Post
I'm not a programmer, but I can probably answer this myself lmao.

You make your function name, insert the commands in it (playing whatever the sound it is) then make sure you add loops in order to make it keep going without actually needing to do it yourself all the time. Whenever you want at the end, call the function by pressing whatever the function name was before.

Hopefully I answered a question I wouldn't know, but I did learn a lil sum in my CS class Claps


Why cant we groan staff. So lame.
04-25-2017, 11:13 PM #8
anthonything
Space Ninja
Originally posted by ManningCFW View Post
what is the code for loops? return;? repeat;?


As I previously answered - a while loop.

You can modify the condition in the while loop, as well as the time in the wait, then simply replace my commented line with playsound. That will loop infinitely and play a sound every 'x' seconds.

You can also use a function to call to repeat this entire process if you need to.
04-26-2017, 12:23 AM #9
Hydrogen
Super Mod
Originally posted by DamnMagician View Post
Why cant we groan staff. So lame.


The same reason why I can't groan you. *plot twist* Kappa
04-26-2017, 02:55 AM #10
SyGnUs
Give a F*** About Your Lifestyle
Originally posted by ManningCFW View Post
I Need This For My Project!Tustin


You should be able to just use the GSC function meant exactly for this -

    
PlayLoopSound(soundName, interval or time to be played?) // Not sure on the second argument/parameter, but it's optional so you can experiment with it if you like.

Based on the decompiled scripts should be something like this -

yourSound = spawn("script_origin", (0, 0, 0));
yourSound playLoopSound(alias);

yourSound stopLoopSound();
wait 0.1;
yourSound delete();

or

self playLoopSound(soundName);


Edit:

There is also a function in maps\mp\_utility.gsc that you can call called - loop_sound_in_space(alias, origin, ender)
Last edited by SyGnUs ; 04-26-2017 at 03:02 AM.

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo