how to make a on/off alarm button?


(GRouZER) #1

I want to make a button that sounds an alarm, and can be turned off by pressing the button again.


(Drakir) #2
  1. Make a door as your button.

  2. Target a func_timer with the door.

  3. Target a target_speaker with the timer.


(GRouZER) #3

Thanks, but how do you let the alarm go off when an func_explosive has been destroyed?

i already have this, but when i load the map in ET i get an error that says that he cannot recognize the command “playsound” or something like that.

and also, the alarm state is on when i enter the map, how do i set the state to off?

game_manager
{
   spawn 
    {
    }
}


alarm_script
{
	spawn
	{
	wait 200
	}
        
        playsound
        {
        sound/world/alarm_01.wav
        }
}

(damocles) #4

Make the fiunc_explosive target the alarm timer also.

That’s not how playsound works. Playsound is a command that appears inside a function, not as a function, eg:


functionName
{
    playsound soundfolder/soundname.wav looping
}

You may be better off using a target_speaker (or several) depending on where you weant the alarm sound. EG do you want it near a speaker(s) or all over the map?


(GRouZER) #5

near the speaker, so without the spawnflags cheked it’s “near the speaker”?

how do i make sure that the sound loops when triggered, cause when you check the spawnflag looped on, the sound starts playing when entering the map, can this be done without scripting?


(damocles) #6

If you want it near the speaker simply use target_speaker(s) near the speaker brushwork. Make the func_timer mentioned above target the speaker(s) and it will trigger them every X seconds.

Or you could remoce the timer altogether. Use looped speakers and make the alarm button and func_explosive target the target_speakers instead. That way they will turn on and off as needed.


(GRouZER) #7

It doen’t work :frowning:

the sound starts playing when entering the map.

check the source of the map if want to (save source to file with map extention):

// entity 0
{
"mapcoordsmaxs" "256 -256"
"mapcoordsmins" "-256 256"
"classname" "worldspawn"
// brush 0
{
( 136 192 0 ) ( -192 192 0 ) ( -192 -192 0 ) bunker_sd/concrete_c07bcmp_sand 0 0 0 0.500000 0.500000 0 0 0
( -192 -192 8 ) ( 136 -192 8 ) ( 136 -192 0 ) bunker_sd/concrete_c07bcmp_sand 0 0 0 0.500000 0.500000 0 0 0
( 192 -200 8 ) ( 192 184 8 ) ( 192 184 0 ) bunker_sd/concrete_c07bcmp_sand 0 0 0 0.500000 0.500000 0 0 0
( 136 192 8 ) ( -192 192 8 ) ( -192 192 0 ) bunker_sd/concrete_c07bcmp_sand 0 0 0 0.500000 0.500000 0 0 0
( -192 192 8 ) ( -192 -192 8 ) ( -192 -192 0 ) bunker_sd/concrete_c07bcmp_sand 0 0 0 0.500000 0.500000 0 0 0
( -192 192 8 ) ( 136 192 8 ) ( -192 -192 8 ) bunker_sd/concrete_c07bcmp_sand 0 0 0 0.500000 0.500000 0 0 0
}
// brush 1
{
( -200 -192 192 ) ( -200 192 192 ) ( 128 192 192 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
( -192 -192 8 ) ( 136 -192 8 ) ( 136 -192 0 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
( 192 -200 8 ) ( 192 184 8 ) ( 192 184 0 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
( 136 192 8 ) ( -192 192 8 ) ( -192 192 0 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
( -192 192 8 ) ( -192 -192 8 ) ( -192 -192 0 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
( -200 192 184 ) ( -200 -192 184 ) ( 128 192 184 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
}
// brush 2
{
( 136 192 0 ) ( -192 192 0 ) ( -192 -192 0 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
( -200 -192 192 ) ( -200 192 192 ) ( 128 192 192 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
( -192 -192 8 ) ( 136 -192 8 ) ( 136 -192 0 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
( 192 -200 8 ) ( 192 184 8 ) ( 192 184 0 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
( -192 192 8 ) ( -192 -192 8 ) ( -192 -192 0 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
( 136 -184 8 ) ( -192 -184 8 ) ( 136 -184 0 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
}
// brush 3
{
( 136 192 0 ) ( -192 192 0 ) ( -192 -192 0 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
( -200 -192 192 ) ( -200 192 192 ) ( 128 192 192 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
( -192 -192 8 ) ( 136 -192 8 ) ( 136 -192 0 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
( 192 -200 8 ) ( 192 184 8 ) ( 192 184 0 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
( 136 192 8 ) ( -192 192 8 ) ( -192 192 0 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
( 184 184 8 ) ( 184 -200 8 ) ( 184 184 0 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
}
// brush 4
{
( 136 192 0 ) ( -192 192 0 ) ( -192 -192 0 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
( -200 -192 192 ) ( -200 192 192 ) ( 128 192 192 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
( 192 -200 8 ) ( 192 184 8 ) ( 192 184 0 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
( 136 192 8 ) ( -192 192 8 ) ( -192 192 0 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
( -192 192 8 ) ( -192 -192 8 ) ( -192 -192 0 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
( -192 184 8 ) ( 136 184 8 ) ( -192 184 0 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
}
// brush 5
{
( 136 192 0 ) ( -192 192 0 ) ( -192 -192 0 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
( -200 -192 192 ) ( -200 192 192 ) ( 128 192 192 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
( -192 -192 8 ) ( 136 -192 8 ) ( 136 -192 0 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
( 136 192 8 ) ( -192 192 8 ) ( -192 192 0 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
( -192 192 8 ) ( -192 -192 8 ) ( -192 -192 0 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
( -184 -192 8 ) ( -184 192 8 ) ( -184 -192 0 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
}
// brush 6
{
( 24 184 152 ) ( -8 184 152 ) ( -8 152 152 ) metal_misc/metal_m03 0 0 0 0.500000 0.500000 0 0 0
( -16 152 184 ) ( 16 152 184 ) ( 16 152 112 ) metal_misc/metal_m03 0 0 0 0.500000 0.500000 0 0 0
( 16 152 184 ) ( 16 184 184 ) ( 16 184 112 ) metal_misc/metal_m03 0 0 0 0.500000 0.500000 0 0 0
( 16 184 184 ) ( -16 184 184 ) ( -16 184 112 ) metal_misc/metal_m03 0 0 0 0.500000 0.500000 0 0 0
( -16 184 184 ) ( -16 152 184 ) ( -16 152 112 ) metal_misc/metal_m03 0 0 0 0.500000 0.500000 0 0 0
( -8 184 160 ) ( 24 184 160 ) ( -8 152 160 ) metal_misc/metal_m03 0 0 0 0.500000 0.500000 0 0 0
}
// brush 7
{
( -16 152 184 ) ( -16 184 184 ) ( 16 184 184 ) metal_misc/metal_m03 0 0 0 0.500000 0.500000 0 0 0
( -16 152 184 ) ( 16 152 184 ) ( 16 152 112 ) metal_misc/metal_m03 0 0 0 0.500000 0.500000 0 0 0
( 16 152 184 ) ( 16 184 184 ) ( 16 184 112 ) metal_misc/metal_m03 0 0 0 0.500000 0.500000 0 0 0
( 16 184 184 ) ( -16 184 184 ) ( -16 184 112 ) metal_misc/metal_m03 0 0 0 0.500000 0.500000 0 0 0
( -16 184 184 ) ( -16 152 184 ) ( -16 152 112 ) metal_misc/metal_m03 0 0 0 0.500000 0.500000 0 0 0
( -16 184 176 ) ( -16 152 176 ) ( 16 184 176 ) metal_misc/metal_m03 0 0 0 0.500000 0.500000 0 0 0
}
// brush 8
{
( 24 184 152 ) ( -8 184 152 ) ( -8 152 152 ) metal_misc/metal_m03 0 0 0 0.500000 0.500000 0 0 0
( -16 152 184 ) ( -16 184 184 ) ( 16 184 184 ) metal_misc/metal_m03 0 0 0 0.500000 0.500000 0 0 0
( -16 152 184 ) ( 16 152 184 ) ( 16 152 112 ) metal_misc/metal_m03 0 0 0 0.500000 0.500000 0 0 0
( 16 152 184 ) ( 16 184 184 ) ( 16 184 112 ) metal_misc/metal_m03 0 0 0 0.500000 0.500000 0 0 0
( 16 184 184 ) ( -16 184 184 ) ( -16 184 112 ) metal_misc/metal_m03 0 0 0 0.500000 0.500000 0 0 0
( 8 184 184 ) ( 8 152 184 ) ( 8 184 112 ) metal_misc/metal_m03 0 0 0 0.500000 0.500000 0 0 0
}
// brush 9
{
( 24 184 152 ) ( -8 184 152 ) ( -8 152 152 ) metal_misc/metal_m03 0 0 0 0.500000 0.500000 0 0 0
( -16 152 184 ) ( -16 184 184 ) ( 16 184 184 ) metal_misc/metal_m03 0 0 0 0.500000 0.500000 0 0 0
( 16 152 184 ) ( 16 184 184 ) ( 16 184 112 ) metal_misc/metal_m03 0 0 0 0.500000 0.500000 0 0 0
( 16 184 184 ) ( -16 184 184 ) ( -16 184 112 ) metal_misc/metal_m03 0 0 0 0.500000 0.500000 0 0 0
( -16 184 184 ) ( -16 152 184 ) ( -16 152 112 ) metal_misc/metal_m03 0 0 0 0.500000 0.500000 0 0 0
( -16 176 184 ) ( 16 176 184 ) ( -16 176 112 ) metal_misc/metal_m03 0 0 0 0.500000 0.500000 0 0 0
}
// brush 10
{
( 24 184 152 ) ( -8 184 152 ) ( -8 152 152 ) metal_misc/metal_m03 0 0 0 0.500000 0.500000 0 0 0
( -16 152 184 ) ( -16 184 184 ) ( 16 184 184 ) metal_misc/metal_m03 0 0 0 0.500000 0.500000 0 0 0
( -16 152 184 ) ( 16 152 184 ) ( 16 152 112 ) metal_misc/metal_m03 0 0 0 0.500000 0.500000 0 0 0
( 16 184 184 ) ( -16 184 184 ) ( -16 184 112 ) metal_misc/metal_m03 0 0 0 0.500000 0.500000 0 0 0
( -16 184 184 ) ( -16 152 184 ) ( -16 152 112 ) metal_misc/metal_m03 0 0 0 0.500000 0.500000 0 0 0
( -8 152 184 ) ( -8 184 184 ) ( -8 152 112 ) metal_misc/metal_m03 0 0 0 0.500000 0.500000 0 0 0
}
}
// entity 1
{
"origin" "0 16 96"
"classname" "info_player_deathmatch"
}
// entity 2
{
"origin" "-128 -96 32"
"classname" "team_CTF_bluespawn"
}
// entity 3
{
"origin" "128 -112 32"
"classname" "team_CTF_redspawn"
}
// entity 4
{
"targetname" "button"
"lip" "2"
"wait" "1"
"target" "t2"
"angle" "90"
"classname" "func_door"
// brush 0
{
( 16 72 8 ) ( -8 72 8 ) ( -8 48 8 ) metal_misc/metal_m06 0 0 0 0.500000 0.500000 0 0 0
( -8 48 64 ) ( -8 72 64 ) ( 16 72 64 ) metal_misc/metal_m06 0 0 0 0.500000 0.500000 0 0 0
( -8 48 40 ) ( 16 48 40 ) ( 16 48 8 ) metal_misc/metal_m06 0 0 0 0.500000 0.500000 0 0 0
( 16 48 40 ) ( 16 72 40 ) ( 16 72 8 ) metal_misc/metal_m06 0 0 0 0.500000 0.500000 0 0 0
( 16 72 40 ) ( -8 72 40 ) ( -8 72 8 ) metal_misc/metal_m06 0 0 0 0.500000 0.500000 0 0 0
( -8 72 40 ) ( -8 48 40 ) ( -8 48 8 ) metal_misc/metal_m06 0 0 0 0.500000 0.500000 0 0 0
}
}
// entity 5
{
"target" "speaker"
"spawnflags" "1"
"noise" "sound/world/alarm_01.wav"
"targetname" "speaker"
"origin" "0 144 168"
"classname" "target_speaker"
}
// entity 6
{
"targetname" "wall"
"target" "t2"
"health" "50"
"type" "brick"
"classname" "func_explosive"
// brush 0
{
( -176 152 192 ) ( -176 128 192 ) ( -176 128 0 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
( -40 152 192 ) ( -176 152 192 ) ( -176 152 0 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
( -40 128 192 ) ( -40 152 192 ) ( -40 152 0 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
( -176 128 192 ) ( -40 128 192 ) ( -40 128 0 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
( -176 128 184 ) ( -176 152 184 ) ( -40 152 184 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
( -40 152 8 ) ( -176 152 8 ) ( -176 128 8 ) bunker_sd/int_wall01 0 0 0 0.500000 0.500000 0 0 0
}
}
// entity 7
{
"target" "speaker"
"targetname" "t2"
"origin" "64 96 96"
"classname" "func_timer"
}


(damocles) #8

In your target speaker, set the spawn flags to Looped OFF not looped ON.


(GRouZER) #9

ok the sound starting when entering the map is fixed, but the sound randomly plays parts of the sound file.

And i can’t turn it off by pressing the button.


(damocles) #10

Are you using func_timers? If so, get rid of them like I outlined above. Are you doing it purely by triggers and entities, or are you using scripting?


(GRouZER) #11

no script, it works when i destroy the func_explosive, but i can’t turn off the sound by pressing the button.


(damocles) #12

Did you remember to set the button as a func_door and have it target the speaker(s)? IS there definitely a green line between the button and speakers in the editor? Perhaps try something simpler than a button. Make the button shaped brushwork, then add a func_invis_user around it so it can be “activated” and have the invis_user target the speakers.


(GRouZER) #13

It works now thanks!
To bad the func_door (button) doesn’t work, that looks just a bit more realistic.