Forum

"cd play XX" when you die

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

"cd play XX" when you die

Postby dr_mabuse » Wed Jan 04, 2012 7:21 pm

Hey there,

I want my MOD playing an MP3 when you die in the singleplayer, not in multiplayer...
Can i do this via QuakeC or do i need to mod the engine (PSP ProQuake)?

The only music thing i have done so far is via "trigger_command" brushes on my map, and it changes the music
when you enter a different area.
User avatar
dr_mabuse
 
Posts: 80
Joined: Sat Sep 03, 2011 6:07 pm

Re: "cd play XX" when you die

Postby Spirit » Wed Jan 04, 2012 8:54 pm

Should be easy. In player.qc's PlayerDie() (or elsewhere?) check if you are in a multiplayer game and if not, stuffcmd the "cd play XX".

edit:
Code: Select all
if (!(deathmatch || coop))
      stuffcmd (self, "cd play 123\n");



If that works I shall from now on be called Spirit of QC.
Improve Quaddicted, send me a pull request: https://github.com/SpiritQuaddicted/Quaddicted-reviews
Spirit
 
Posts: 1031
Joined: Sat Nov 20, 2004 9:00 pm

Re: "cd play XX" when you die

Postby dr_mabuse » Wed Jan 04, 2012 9:13 pm

thanks i will try it and tell you if it works ;)
User avatar
dr_mabuse
 
Posts: 80
Joined: Sat Sep 03, 2011 6:07 pm

Re: "cd play XX" when you die

Postby Max_Salivan » Thu Jan 05, 2012 8:57 pm

mmm without cd

Code: Select all
void() DeathSound =
{
   local float      rs;

   // water death sounds
   if (self.waterlevel == 3)
   {
      DeathBubbles(20);

      sound (self, CHAN_VOICE, "player/h2odeath.wav", 1, ATTN_NORM);
      return;
   }
   if (self.invisible_finished > time)
      return;

   rs = rint ((random() * 4) + 1);
   if (rs == 1)
      self.noise = "player/death1.wav";
   if (rs == 2)
      self.noise = "player/death2.wav";
   if (rs == 3)
      self.noise = "player/death3.wav";
   if (rs == 4)
      self.noise = "player/death4.wav";
   if (rs == 5)
      self.noise = "player/death5.wav";

   sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
   AttractNoise(400); // Attract monsters
   return;
};
Sorry for my english :)
Max_Salivan
 
Posts: 93
Joined: Thu Dec 15, 2011 1:00 pm

Re: "cd play XX" when you die

Postby Baker » Thu Jan 05, 2012 9:25 pm

As far as I know, the "correct" way is

Code: Select all
      WriteByte (MSG_ALL, SVC_CDTRACK);
      WriteByte (MSG_ALL, 2); // 2 is track number
      WriteByte (MSG_ALL, 2); // 2 is track number


Yes that WriteByte message needs to occur twice. According to the docs ...

http://www.gamers.org/dEngine/quake/Qc/qc-net.htm

Code: Select all
Message: Set CD Track

  WriteByte (MSG_ALL, SVC_CDTRACK);
  WriteByte (MSG_ALL, val1);        // CD start track
  WriteByte (MSG_ALL, val2);        // CD end track


The SVC_CDTRACK message takes 2 bytes so two WriteBytes must be sent. Otherwise the client will probably get some sort of fail to console with a "bad network message" of some sort.
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest