UGX-Mods

Call of Duty: Black Ops 3 => Help Desk => Scripting => Topic started by: ect0 on February 04, 2017, 05:45:52 pm

Title: How to add a sound that loops when you walk in a room?
Post by: ect0 on February 04, 2017, 05:45:52 pm
If you know can you like add me on steam?

www.steamcommunity.com/id/Lokibruv (http://www.steamcommunity.com/id/Lokibruv)
Title: Re: How to add a sound that loops when you walk in a room?
Post by: MegaMech43 on February 04, 2017, 09:07:03 pm
Code Snippet
Plaintext
//A comment is //comment. Compiler skips code with //
#using scripts\zm\_zm_utility; //use a script outside of current scope
while(1) { //loop begin. Run code while true. If 1 becomes zero loop stops.
ent = GetEnt("ent","targetname"); //locates an object named "ent". Make this a script_struct or script_origin
zm_utility::play_sound_at_pos("a_sound", ent.origin);  // play sound with name "a_sound" at the object
if (break_out_of_loop) {break;} //clause to stop the sound if necessary
wait(insert_sound_length_here); //ex. wait(3) stops code for 3 seconds
} //loop end

Put code in function. Run function with thread functionname()
Title: Re: How to add a sound that loops when you walk in a room?
Post by: Conbini2017 on March 20, 2017, 02:36:58 pm
Because I do not understand script at all,
please tell me in detail. :(
Title: Re: How to add a sound that loops when you walk in a room?
Post by: MegaMech43 on March 20, 2017, 04:30:26 pm
Modified with more detail
Title: Re: How to add a sound that loops when you walk in a room?
Post by: Conbini2017 on March 21, 2017, 09:31:20 am
Thank you very much
How (break_out_of_loop) {break;} is used?
Title: Re: How to add a sound that loops when you walk in a room?
Post by: MegaMech43 on March 23, 2017, 12:36:06 am
Depends on what you're doing. For example

if (variable_name) {break;}

(Code elsewhere)

if (blah) {variable_name = true;}
or you could just do
variable_name = true;
Now next time the code runs it will stop. Actually you probably want this code BEFORE the sound plays to prevent it from playing again.
Title: Re: How to add a sound that loops when you walk in a room?
Post by: Cxwh on March 29, 2017, 11:54:56 pm
You'd do that using zones
Title: Re: How to add a sound that loops when you walk in a room?
Post by: MegaMech43 on March 30, 2017, 01:32:03 am
Not necessarily. You could make the zone trigger a script but the OP didn't specify. I find it easier to use a trigger.
My example didn't explain how to trigger the code. It's easy enough to figure out.
Title: Re: How to add a sound that loops when you walk in a room?
Post by: Conbini2017 on April 01, 2017, 05:42:35 pm
Not necessarily. You could make the zone trigger a script but the OP didn't specify. I find it easier to use a trigger.
My example didn't explain how to trigger the code. It's easy enough to figure out.
Could you tell me how to use the zone?
Title: Re: How to add a sound that loops when you walk in a room?
Post by: MegaMech43 on April 01, 2017, 08:23:31 pm
Make a trigger_multiple surround the entrance or the entire room, whatever.
Add a key/value and use these functions:
It's  up to you to make it work. You won't learn anything if I do it for you. Search the forums for answers how to use these if you can't figure out how or look it up on the API
Code Snippet
Plaintext

trigger = GetEnt("damagebox", "targetname");

players = getplayers();

if(players[i] isTouching(trigger))

Title: Re: How to add a sound that loops when you walk in a room?
Post by: Conbini2017 on April 16, 2017, 01:20:59 pm
Code Snippet
Plaintext
//A comment is //comment. Compiler skips code with //
#using scripts\zm\_zm_utility; //use a script outside of current scope
while(1) { //loop begin. Run code while true. If 1 becomes zero loop stops.
ent = GetEnt("ent","targetname"); //locates an object named "ent". Make this a script_struct or script_origin
zm_utility::play_sound_at_pos("a_sound", ent.origin);  // play sound with name "a_sound" at the object
if (break_out_of_loop) {break;} //clause to stop the sound if necessary
wait(insert_sound_length_here); //ex. wait(3) stops code for 3 seconds
} //loop end



Put code in function. Run function with thread functionname()
I encountered such an error.
Code Snippet
Plaintext
^1}
^1^
^1ERR(0) scripts/zm/zm_test.gsc (269,1)  : syntax error, unexpected $end, expecting TOKEN_RIGHT_CURLY : }
Would you please show me an example script you actually used on the map?
Title: Re: How to add a sound that loops when you walk in a room?
Post by: MegaMech43 on April 16, 2017, 07:40:46 pm
I encountered such an error.
Code Snippet
Plaintext
^1}
^1^
^1ERR(0) scripts/zm/zm_test.gsc (269,1)  : syntax error, unexpected $end, expecting TOKEN_RIGHT_CURLY : }
Would you please show me an example script you actually used on the map?
I think the error is due to you not putting: #using scripts\zm\_zm_utility; at the top of the code where it's supposed to go.

Here's some code:
Code Snippet
Plaintext

function damagebox() {
trigger = GetEnt("damagebox", "targetname");
trigger SetHintString("");
trigger SetCursorHint("HINT_NOICON");
while(1) {
wait(2);
players = getplayers();
for( i=0;i<players.size;i++ )
{
if(players[i] isTouching(trigger))
{
players[i] DoDamage(15,players[i].origin);
}
}
}
}


Title: Re: How to add a sound that loops when you walk in a room?
Post by: Conbini2017 on April 17, 2017, 08:32:35 am
I think the error is due to you not putting: #using scripts\zm\_zm_utility; at the top of the code where it's supposed to go.

Here's some code:
Code Snippet
Plaintext

function damagebox() {
trigger = GetEnt("damagebox", "targetname");
trigger SetHintString("");
trigger SetCursorHint("HINT_NOICON");
while(1) {
wait(2);
players = getplayers();
for( i=0;i<players.size;i++ )
{
if(players[i] isTouching(trigger))
{
players[i] DoDamage(15,players[i].origin);
}
}
}
}
I will try it at once. :)
How can I do with radiant?
What is it, trigger?
Is entity info better to write script_sound and script_label?
please tell me. Please.
Title: Re: How to add a sound that loops when you walk in a room?
Post by: MegaMech43 on April 17, 2017, 10:44:25 pm
Go watch some tutorials.
Title: Re: How to add a sound that loops when you walk in a room?
Post by: Conbini2017 on April 18, 2017, 07:57:20 am
Go watch some tutorials.
Is there a video link for the tutorial?
Title: Re: How to add a sound that loops when you walk in a room?
Post by: Harry Bo21 on April 18, 2017, 01:09:00 pm
You would either use "playloopsound" - on - the ent

Or not have a ent and use playsoundatposition - which isn't looping

Not spawn a ent and use its origin in this case, that's completely backwards and not what he asked

Main reason is breaking the loop won't stop the sound, it'll carry on to completion. Play it "on" something using playloopsound - then to stop it delete the ent it's on
Title: Re: How to add a sound that loops when you walk in a room?
Post by: Conbini2017 on April 18, 2017, 03:04:14 pm
Code Snippet
Plaintext
//A comment is //comment. Compiler skips code with //
#using scripts\zm\_zm_utility; //use a script outside of current scope
while(1) { //loop begin. Run code while true. If 1 becomes zero loop stops.
ent = GetEnt("ent","targetname"); //locates an object named "ent". Make this a script_struct or script_origin
zm_utility::play_sound_at_pos("a_sound", ent.origin);  // play sound with name "a_sound" at the object
if (break_out_of_loop) {break;} //clause to stop the sound if necessary
wait(insert_sound_length_here); //ex. wait(3) stops code for 3 seconds
} //loop end
What should I change this code and what should I put in there?
Will you teach me?
Title: Re: How to add a sound that loops when you walk in a room?
Post by: MegaMech43 on April 20, 2017, 07:37:07 am
Literally just youtube search "black ops 3 mod tools triggers" or "trigger_multiple"
Or try "Radiant black tutorial triggers".

You'll find something. Sometimes it may not be a tutorial about your specific purpose, but you can re-purpose things to do what you want them to do. Also some things apply across the board. Once you know how to setup one trigger, all triggers are pretty much the same.