Hello again. This time i need help with this cog... It works when you press the switch but it wont turn off when you press the switch again... The only way to really get it to turn of right now is to have it play silence.
If someone could help me, I would be very nice
- Unlike some people, whose middle name is cogger, my middle name is retard.
# Jedi Knight Cog Script
#
# prl_sectorsound.cog by Sylvicolus - 23 April 2001
#
# Sound triggered by activating switch. Use 1 or 2 switches.
# Activate switch again to turn sound off.
# Sound is heard inside of 1 to 4 sectors.
# Choose volume and wav sound.
#
# This cog is not supported by LucasArts Entertainment Co.
symbols
message activate
surface switch0 linkid=1
surface switch1 linkid=1
sector sector0 nolink
sector sector1 nolink
sector sector2 nolink
sector sector3 nolink
flex volume=1.0
sound wav0=00AlarmLoop03.WAV
int channel0 local
int channel1 local
int channel2 local
int channel3 local
int soundstatus=0 local
flex FadeOut=0.2 local
end
# ===============================================
code
startup:
setwallcel(switch0, 1);
if (switch1) setwallcel(switch1, 1);
return;
## Sets the switch mat to the 2nd cell, which is green or off position.
activate:
if (soundstatus==0)
{
soundstatus=1;
setwallcel(switch0, 0);
if (switch1) setwallcel(switch1, 0);
channel0 = SectorSound(sector0, wav0, volume);
if (sector1) channel1 = SectorSound(sector1, wav0, volume);
if (sector2) channel2 = SectorSound(sector2, wav0, volume);
if (sector3) channel3 = SectorSound(sector3, wav0, volume);
return;
} //else turn off sound
soundstatus=0;
setwallcel(switch0, 1);
if (switch1) setwallcel(switch1, 1);
StopSound(channel0,FadeOut);
if (sector1) StopSound(channel1,FadeOut);
if (sector2) StopSound(channel2,FadeOut);
if (sector3) StopSound(channel3,FadeOut);
return;
end
------------------
Bob Dole likes peanut butter. Bob Dole's never been afraid to admit that
If someone could help me, I would be very nice
- Unlike some people, whose middle name is cogger, my middle name is retard.# Jedi Knight Cog Script
#
# prl_sectorsound.cog by Sylvicolus - 23 April 2001
#
# Sound triggered by activating switch. Use 1 or 2 switches.
# Activate switch again to turn sound off.
# Sound is heard inside of 1 to 4 sectors.
# Choose volume and wav sound.
#
# This cog is not supported by LucasArts Entertainment Co.
symbols
message activate
surface switch0 linkid=1
surface switch1 linkid=1
sector sector0 nolink
sector sector1 nolink
sector sector2 nolink
sector sector3 nolink
flex volume=1.0
sound wav0=00AlarmLoop03.WAV
int channel0 local
int channel1 local
int channel2 local
int channel3 local
int soundstatus=0 local
flex FadeOut=0.2 local
end
# ===============================================
code
startup:
setwallcel(switch0, 1);
if (switch1) setwallcel(switch1, 1);
return;
## Sets the switch mat to the 2nd cell, which is green or off position.
activate:
if (soundstatus==0)
{
soundstatus=1;
setwallcel(switch0, 0);
if (switch1) setwallcel(switch1, 0);
channel0 = SectorSound(sector0, wav0, volume);
if (sector1) channel1 = SectorSound(sector1, wav0, volume);
if (sector2) channel2 = SectorSound(sector2, wav0, volume);
if (sector3) channel3 = SectorSound(sector3, wav0, volume);
return;
} //else turn off sound
soundstatus=0;
setwallcel(switch0, 1);
if (switch1) setwallcel(switch1, 1);
StopSound(channel0,FadeOut);
if (sector1) StopSound(channel1,FadeOut);
if (sector2) StopSound(channel2,FadeOut);
if (sector3) StopSound(channel3,FadeOut);
return;
end
------------------
Bob Dole likes peanut butter. Bob Dole's never been afraid to admit that
![http://forums.massassi.net/html/smile.gif [http://forums.massassi.net/html/smile.gif]](http://forums.massassi.net/html/smile.gif)
#
# The sound wave that is played will loop forever in that sector,
# until switched OFF.
#
# status=0 for OFF ; status=1 for ON
#
# Haven't found a way of allocating a channel to sector sounds
# to get a handle for it :s
# Parsec + JK don't like using SectorSound() verb as an expression...
#
#
# Set verbose=1, if you want to see print out messages.
# (More for test purposes than anything else...)
#
# This COG script is NOT supported by LucasArts or LEC.
#
# Permission is granted to use this script by the author, as long as credit
# is provided in the readme file for any add-on levels that use this script.
#
#
# E-mail: lucky_jackpot@hotmail.com
# [RJS]
#
##
symbols
message startup
message activated
surface switch0 linkid=1
surface switch1 linkid=1
sector triggerSector0 nolink
sector triggerSector1 nolink
sector triggerSector2 nolink
sector triggerSector3 nolink
sector triggerSector4 nolink
sector triggerSector5 nolink
sector triggerSector6 nolink
sector triggerSector7 nolink
sound alarm=00AlarmLoop03.WAV
int status=0
int numSectors=8 local
int counter=0 local
flex volume=1.0
flex silentVolume=0.0 local
thing player local
int verbose=0
end
#====
#====
#====
code
startup:
if (verbose)
Sleep (1.0);
Print ("Startup COG !!!");
if (status == 1) { // Boolean check - equivalent to (status == 1)
SetWallCel (switch0, 1);
SetWallCel (switch1, 1);
}
else
if (status == 0) {
SetWallCel (switch0, 0);
SetWallCel (switch1, 0);
}
return;
#.......................
activated:
player = GetLocalPlayerThing();
if (GetSourceRef() != player)
return;
if (GetSenderID() != 1) // Make sure nothing other than the
return; // switches should send a message...
if (verbose)
Print ("Activated MSG !!!");
if (GetSenderID() == 1) {
if (status == 0) {
if (verbose)
Print ("Status is OFF - switch to ON and START SOUNDS...");
SetWallCel (switch0, 1); // Reset to first cell after starting cell
SetWallCel (switch1, 1);
for (counter=0 ; counter < numSectors ; counter=counter+1) {
if (verbose)
Print ("ALARM !!!");
SectorSound (triggerSector0[counter], alarm, volume);
}
status = 1; // Reset value...
}
else
if (status == 1) {
if (verbose)
Print ("Status is ON --- switch to OFF and STOP SOUNDS !!!");
SetWallCel (switch0, 0); // Reset to starting cell...
SetWallCel (switch1, 0);
for (counter=0 ; counter < numSectors ; counter=counter+1) {
if (verbose)
Print ("FADE OUT !!!");
SectorSound (triggerSector0[counter], alarm, silentVolume);
}
status = 0; // Reset status...
}
}
return;
#.......................
end
