I made a music cog, but it isn't working. It s supposed to start the channel as soon as you spawn, but what happens, is that it plays the punching sound over and over, and if you hit the activate button, it prints the message, and then starts playing the sound when a bryar bolt hits over and over. Pls help.
thanks
Code:
# Jedi Knight Cog Script
#
# muscic2.cog
#
# Plays music on the user's computer localy.
#
#
symbols
thing player
sound musicSound=music.wav local
int channel=-1 local
int music=0
message startup
message activated
message killed
end
# ========================================================================================
code
startup:
player = GetLocalPlayerThing();
channel = PlaySoundlocal(music, 1.0, 0, 0x181);
Return;
# ========================================================================================
activated:
if(music == 0)
{
Print("Music OFF");
StopSound(channel, 0.1);
channel = -1;
music = 1;
}
if(music == 1)
{
Print("Music ON");
channel = PlaySoundlocal(music, 1.0, 0, 0x181);
music = 0;
}
Return;
# ========================================================================================
killed:
call stop_power;
Return;
# ========================================================================================
stop_power:
if(channel != -1)
{
StopSound(channel, 0.1);
channel = -1;
}
Return;
endthanks
"The world is neither black nor white but differing shades of gray."
-By me.
-By me.
![http://forums.massassi.net/html/smile.gif [http://forums.massassi.net/html/smile.gif]](http://forums.massassi.net/html/smile.gif)
![http://forums.massassi.net/html/wink.gif [http://forums.massassi.net/html/wink.gif]](http://forums.massassi.net/html/wink.gif)