Skip to content

Instantly share code, notes, and snippets.

@marcogravbrot
Last active October 25, 2016 06:02
Show Gist options
  • Save marcogravbrot/8e453dccb23451af896e4350efac8334 to your computer and use it in GitHub Desktop.
Save marcogravbrot/8e453dccb23451af896e4350efac8334 to your computer and use it in GitHub Desktop.
// INSIDE
// RADIANT
Place wherever the player walks through
trigger_multiple:
targetname : metal_detector
target : (unique string, i suggest "metal_detector_1" for first detector, etc)
These are the beep boops
light(s):
targetname : trigger_multiple(target)
// INSIDE
// SCRIPTS
// usermap/zm_map/scripts/zm_map.gsc
//Put these defines on the top of the script beneath all the #using and before main function
//Amount of beeps
#define AMOUNT_BEEPS 4
//Delay between turn on and turn off
#define AMOUNT_SECONDS 0.4
//The sound alias to use for the beep
#define BEEP_SOUND "Add your beep alias taking all the space inside these two quotes right here >"
//The amount of seconds for the detector to wait until you can use it again
#define AMOUNT_DELAY 10
//Put this piece of code inside the main function
thread metal_detector();
//Now put the remainder of this file anywhere in the gsc file underneath the main function
//If you know scripting you can also organize this in your own files etc
// COMMENTED OUT FOR NOW BECAUSE THIS ENGINE SUCKS ASS
/*
function private lighswitch(state)
{
if(IsDefined(self) && IsDefined(state))
{
foreach(obj in self)
{
if(state == 1)
{
obj SetLightRadius(obj.DefaultRadius);
}
else if(state == 0)
{
obj SetLightRadius(0);
}
}
}
else
{
IPrintLn("Self is undefined in lights_switch");
}
}
*/
function metal_detector()
{
detectors = GetEntArray("metal_detector", "targetname");
num = undefined;
foreach(detector in detectors)
{
thread detector_think(detector);
}
}
function detector_think(detector)
{
//ALSO COMMENTED OUT
/*
lights = GetEntArray(detector.target, "targetname");
foreach(light in lights)
{
light.DefaultRadius = light GetLightRadius();
light SetLightRadius(0);
}
*/
while(true)
{
detector waittill("trigger", player);
while(true)
{
num = undefined;
num = (num || 1);
//AND LIGHTS IN HERE TOO
//lights lightswitch(1);
detector PlaySound(BEEP_SOUND);
wait(AMOUNT_SECONDS);
//lights lightswitch(0);
wait (AMOUNT_SECONDS);
if(num >= AMOUNT_BEEPS)
{
break;
}
num++;
}
wait(AMOUNT_DELAY);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment