Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → cog problem
cog problem
2002-01-18, 1:46 PM #1
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.
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;

end

thanks
"The world is neither black nor white but differing shades of gray."
-By me.
2002-01-19, 5:31 AM #2
^Bump^
Well, could anybody tell me what's wrong with the cog? I checked the syntax with cogwriter, and there's nothing wrong there, so could anybody tell me waht's freaking it out?
"The world is neither black nor white but differing shades of gray."
-By me.
2002-01-19, 5:46 AM #3
You need to be playing musicSound instead of the music integer.

So replace:
Code:
PlaySoundlocal(music, 1.0, 0, 0x181);


with:
Code:
PlaySoundlocal(musicSound, 1.0, 0, 0x181);


And if there are no other errors with your cog, it will play your music.

BTW, Cogwriter is only checking syntax. If your cog had a syntax error , it wouldn't run.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.
2002-01-19, 5:54 AM #4
OMG... Can't beleive I did that... Thanks SaberMaster. Much thanks. I'll try it, and see what it does.
"The world is neither black nor white but differing shades of gray."
-By me.
2002-01-19, 6:31 AM #5
Thanks, It works just fine, I did have to tweak it, so that instead of the two if statements, I just did one and an else statement. That made my day thanks [http://forums.massassi.net/html/smile.gif]
"The world is neither black nor white but differing shades of gray."
-By me.
2002-01-19, 10:27 AM #6
You're welcome [http://forums.massassi.net/html/wink.gif]

------------------
More matter with less art.
Author of the JK DataMaster, Parsec, Scribe, and the EditPlus Cog Files.

↑ Up to the top!