Half-Life и Adrenaline Gamer форум
http://aghl.ru/forum/

HLSDK (client) PlaySound
http://aghl.ru/forum/viewtopic.php?f=20&t=2550
Страница 1 из 1

Автор:  Gennaro-HL [ 14 сен 2016, 02:10 ]
Заголовок сообщения:  HLSDK (client) PlaySound

as I can do to make the PlaySound does not repeat

what I want is to be played once

how can I do?
Код:
int CHudTest::Draw(float flTime)
{
PlaySound("misc/red_wins.wav", 1);
return 1;
}

Автор:  Lev [ 14 сен 2016, 06:40 ]
Заголовок сообщения:  Re: HLSDK (client) PlaySound

Use a global variable or a field
Код:
bool g_bPlayOnce = false;
int CHudTest::Draw(float flTime)
{
  if (!g_bPlayOnce)
  {
    PlaySound("misc/red_wins.wav", 1);
    g_bPlayOnce = true;
  }
  return 1;
}
Sure, this sample is logically wrong, but it should give you the idea. You just need to set/reset this field at the right moment.

Автор:  Gennaro-HL [ 15 сен 2016, 01:48 ]
Заголовок сообщения:  Re: HLSDK (client) PlaySound

thanks :)

another question

as I can do to play with an interval of 1 second

Код:
//I was doing testing with m_flTime but I have no success
      //float Time = gHUD.m_flTime;

      if (!g_bPlay0)
      {
         PlaySound("barney/ba_bring.wav", 1);
         g_bPlay0 = true;
      }
      if (!g_bPlay1)
      {
         PlaySound("fvox/one.wav", 1);
         g_bPlay1 = true;
      }
      if (!g_bPlay2)
      {
         PlaySound("fvox/two.wav", 1);
         g_bPlay2 = true;
      }
      if (!g_bPlay3)
      {
         PlaySound("fvox/three.wav", 1);
         g_bPlay3 = true;
      }

Автор:  Lev [ 15 сен 2016, 03:34 ]
Заголовок сообщения:  Re: HLSDK (client) PlaySound

You can use gHUD.m_flTime, but keep in mind that it ticks only when you are in game and not in the console. I.e. HUD needs to be drawn for this to get correct value.

Автор:  Gennaro-HL [ 16 сен 2016, 12:33 ]
Заголовок сообщения:  Re: HLSDK (client) PlaySound

Because only when you start playing the map
I am doing something wrong?
Код:
TimeMatch = gHUD.m_flTime - m_Test;

      if (TimeMatch >= 7 && TimeMatch <= 17)
      {
         if (!g_bPlay3)
         {
            PlaySound("fvox/three.wav", 1);
            g_bPlay3 = true;
         }
      }
      if (TimeMatch >= 8 && TimeMatch <= 18)
      {
         if (!g_bPlay2)
         {
            PlaySound("fvox/two.wav", 1);
            g_bPlay2 = true;
         }
      }
      if (TimeMatch >= 9 && TimeMatch <= 19)
      {
         if (!g_bPlay1)
         {
            PlaySound("fvox/one.wav", 1);
            g_bPlay1 = true;
         }
      }
      if (TimeMatch >= 10 && TimeMatch <= 20)
      {
         if (!g_bPlay0)
         {
            PlaySound("barney/ba_bring.wav", 1);
            g_bPlay0 = true;
         }
      }
 

Страница 1 из 1 Часовой пояс: UTC + 5 часов [ Летнее время ]
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/