Author Topic: How to add a sound that loops when you walk in a room?  (Read 349 times)

0 Members and 1 Guest are viewing this topic.

Offline ect0

  • - Original Poster (OP) -
  • Legless Crawler
  • Posts: 25
  • Country: us
  • Respect: 2
    • View Profile

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

« on: February 04, 2017, 08:45:52 am »
If you know can you like add me on steam?

[You are not allowed to view external links. Register or Login to see them]

Offline MegaMech43

  • Rotting Walker
  • Posts: 61
  • Country: ca
  • Respect: 12
    • megamech
    • View Profile
    • megamech.net

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

« Reply #1 on: February 04, 2017, 12:07:03 pm »
Code: [Select]
//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, 07:29:58 am by MegaMech43 »

Offline Conbini2017

  • Rotting Walker
  • Posts: 62
  • Country: jp
  • Respect: 3
    • dadakhr
    • View Profile
  • WaW: conbini2017

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

« Reply #2 on: March 20, 2017, 05:36:58 am »
Because I do not understand script at all,
please tell me in detail. :(

Offline MegaMech43

  • Rotting Walker
  • Posts: 61
  • Country: ca
  • Respect: 12
    • megamech
    • View Profile
    • megamech.net

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

« Reply #3 on: March 20, 2017, 07:30:26 am »
Modified with more detail

Offline Conbini2017

  • Rotting Walker
  • Posts: 62
  • Country: jp
  • Respect: 3
    • dadakhr
    • View Profile
  • WaW: conbini2017

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

« Reply #4 on: March 21, 2017, 12:31:20 am »
Thank you very much
How (break_out_of_loop) {break;} is used?

Offline MegaMech43

  • Rotting Walker
  • Posts: 61
  • Country: ca
  • Respect: 12
    • megamech
    • View Profile
    • megamech.net

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

« Reply #5 on: March 22, 2017, 03:36:06 pm »
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.