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

How to add a sound that loops when you walk in a room?

HOT
broken avatar :(
Created 7 years ago
by ect0
0 Members and 1 Guest are viewing this topic.
6,498 views
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 3 September 2016
Last active: 6 years ago
Posts
25
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
ect0's Groups
ect0's Contact & Social Links
If you know can you like add me on steam?

www.steamcommunity.com/id/Lokibruv
broken avatar :(
×
broken avatar :(
Location: caCanada, Eh
Date Registered: 24 November 2016
Last active: 5 years ago
Posts
85
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
×
MegaMech43's Groups
MegaMech43's Contact & Social Linksmegamechmegamech.net
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()
Last Edit: March 20, 2017, 04:29:58 pm by MegaMech43
broken avatar :(
×
broken avatar :(
Location: jp
Date Registered: 26 June 2016
Last active: 2 years ago
Posts
86
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
×
Conbini2017's Groups
Conbini2017's Contact & Social Linksdadakhrconbini2017
Because I do not understand script at all,
please tell me in detail. :(
broken avatar :(
×
broken avatar :(
Location: caCanada, Eh
Date Registered: 24 November 2016
Last active: 5 years ago
Posts
85
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
×
MegaMech43's Groups
MegaMech43's Contact & Social Linksmegamechmegamech.net
Modified with more detail
broken avatar :(
×
broken avatar :(
Location: jp
Date Registered: 26 June 2016
Last active: 2 years ago
Posts
86
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
×
Conbini2017's Groups
Conbini2017's Contact & Social Linksdadakhrconbini2017
Thank you very much
How (break_out_of_loop) {break;} is used?
broken avatar :(
×
broken avatar :(
Location: caCanada, Eh
Date Registered: 24 November 2016
Last active: 5 years ago
Posts
85
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
×
MegaMech43's Groups
MegaMech43's Contact & Social Linksmegamechmegamech.net
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.
broken avatar :(
×
broken avatar :(
Location: at
Date Registered: 26 November 2016
Last active: 6 years ago
Posts
45
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
Signature
12 year old music critic, quadrasexual Minecrafter, Linkin Park fan, Hentai enthusiast, intelligent atheist and vegan.
×
Cxwh's Groups
Cxwh's Contact & Social LinksCxwhModsGodAspire
You'd do that using zones
broken avatar :(
×
broken avatar :(
Location: caCanada, Eh
Date Registered: 24 November 2016
Last active: 5 years ago
Posts
85
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
×
MegaMech43's Groups
MegaMech43's Contact & Social Linksmegamechmegamech.net
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.
Last Edit: March 30, 2017, 01:44:31 am by MegaMech43
broken avatar :(
×
broken avatar :(
Location: jp
Date Registered: 26 June 2016
Last active: 2 years ago
Posts
86
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
×
Conbini2017's Groups
Conbini2017's Contact & Social Linksdadakhrconbini2017
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?
broken avatar :(
×
broken avatar :(
Location: caCanada, Eh
Date Registered: 24 November 2016
Last active: 5 years ago
Posts
85
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
×
MegaMech43's Groups
MegaMech43's Contact & Social Linksmegamechmegamech.net
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))

broken avatar :(
×
broken avatar :(
Location: jp
Date Registered: 26 June 2016
Last active: 2 years ago
Posts
86
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
×
Conbini2017's Groups
Conbini2017's Contact & Social Linksdadakhrconbini2017
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?
broken avatar :(
×
broken avatar :(
Location: caCanada, Eh
Date Registered: 24 November 2016
Last active: 5 years ago
Posts
85
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
×
MegaMech43's Groups
MegaMech43's Contact & Social Linksmegamechmegamech.net
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);
}
}
}
}


broken avatar :(
×
broken avatar :(
Location: jp
Date Registered: 26 June 2016
Last active: 2 years ago
Posts
86
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
×
Conbini2017's Groups
Conbini2017's Contact & Social Linksdadakhrconbini2017
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.
Last Edit: April 17, 2017, 09:57:49 am by Conbini2017
broken avatar :(
×
broken avatar :(
Location: caCanada, Eh
Date Registered: 24 November 2016
Last active: 5 years ago
Posts
85
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
×
MegaMech43's Groups
MegaMech43's Contact & Social Linksmegamechmegamech.net
Go watch some tutorials.
broken avatar :(
×
broken avatar :(
Location: jp
Date Registered: 26 June 2016
Last active: 2 years ago
Posts
86
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
×
Conbini2017's Groups
Conbini2017's Contact & Social Linksdadakhrconbini2017
Go watch some tutorials.
Is there a video link for the tutorial?

 
Loading ...