Home   Help Search Login Register  

Author Topic: Call To Prayer...  (Read 4399 times)

0 Members and 1 Guest are viewing this topic.

Offline Shadow.D. ^BOB^

  • Members
  • *
Call To Prayer...
« on: 31 Dec 2008, 00:37:00 »
Hey guys, im currently building a template for futur missions on the new Afghan Village aswell as Avani.  I was looking into a "Call To Prayer" script, that would play a sound file at various time of the day. Now i could use the old trigger with rough time delay, but its not perfect and in the template the time is selectable.  Which would render this dead anyway.

Does anybody have an idea of how i could get the sound file to play from a certain point (wether it be a game logic, whatever), at set time of the day?

The call to prayer is done like the following (I think!).

- Sun Up

- Midday (When Sun Is Highest)

- + 3 Hours

- Sun Down
 
- + 1 Hour

Obviously to get states of the sun, is a bit much. But you could get the effect with times of day.  I must admit im a complete script noob, when it comes to actually starting from scratch.  So any help would be greatly appreciated.

Thx in advance...

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Call To Prayer...
« Reply #1 on: 31 Dec 2008, 01:18:34 »
Code: [Select]
_times_to_play = [5, 12, 15, 18, 19];
_played_times = [0, 0, 0, 0, 0];
_i = 0;
while {true} do
{
   _i = 0;
   {
      if (abs (dayTime - _x) < 0.05) then
      {
         if ((_played_times select _i) == 0) then
         {
            _played_times set [_i, 1];
            _gamelogic say "PRAY_SOUND";
         };
      };
      _i = _i + 1;
   } forEach _played_times;

   if (dayTime > (_times_to_play select 4)) then
   {
      _played_times = [0, 0, 0, 0, 0];
   };

   Sleep 10;
};

Offline Shadow.D. ^BOB^

  • Members
  • *
Re: Call To Prayer...
« Reply #2 on: 31 Dec 2008, 01:55:51 »
Will try this asap Mandoble, thanks for such a quick reply.

Edit:  Could i just check i am implemeting this correctly.  I have defined the sound in the description, files are all in.  I then took the code and made an .sqf file, changing the "PRAY_SOUND" for "Adhan.ogg".  Then i run this script from the init.  Is this correct, or have i totally missed the point?
« Last Edit: 31 Dec 2008, 03:04:39 by Shadow.D. ^BOB^ »

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Call To Prayer...
« Reply #3 on: 31 Dec 2008, 03:10:15 »
You need the sound defined in a description.ext file that refers to your .ogg file.  Here is an example of a description.ext file that defines one sound:

Code: [Select]
class CfgSounds
{
sounds[] = {Adhan};

class scream
{
name = "Adhan";
sound[] = {"Adhan.ogg", db+0, 1.0};
titles[] = {0,""};
};
};

Be sure to put the Adhan.ogg file in a subdirectory called /Sound (within your mission directory).

Your say command need only say the name (not including the .ogg extension):

Code: [Select]
_gamelogic say "Adhan";
Note that Mando's example also requires a game logic (shown as a local variable _gamelogic) to exist.  So near the top of Mando's script (before the while loop), you should create the gamelogic:

Code: [Select]
_gamelogic="logic" createVehicle [0,0,0];
« Last Edit: 31 Dec 2008, 03:15:14 by johnnyboy »
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: Call To Prayer...
« Reply #4 on: 31 Dec 2008, 03:21:31 »
Make sure you can play and hear the sound before you try anything fancy. Also if your making lots of changes to the description.ext be sure to save and reload the mission.
Xbox Rocks

Offline Shadow.D. ^BOB^

  • Members
  • *
Re: Call To Prayer...
« Reply #5 on: 31 Dec 2008, 04:08:59 »
Ok i have checked everything, the sound plays fine in the editor if i use a trigger.  But does not play at the specific time when using the script.

Also while i have your attention  :cool2:   This method plays a sound file to all clients, but could it be possible to use is like the "Trigger" option in the trigger effects.  Whereby is plays the sound from a location (e.g a minaret  :D)  and have the sound drown out the further away the client is?

Will keep checking the script, see if i can get it work.

Script now reads:-
Code: [Select]
_gamelogic="logic" createVehicle [0,0,0];
_times_to_play = [5, 12, 15, 18, 19];
_played_times = [0, 0, 0, 0, 0];
_i = 0;
while {true} do
{
   _i = 0;
   {
      if (abs (dayTime - _x) < 0.05) then
      {
         if ((_played_times select _i) == 0) then
         {
            _played_times set [_i, 1];
            _gamelogic say "Adhan";
         };
      };
      _i = _i + 1;
   } forEach _played_times;

   if (dayTime > (_times_to_play select 4)) then
   {
      _played_times = [0, 0, 0, 0, 0];
   };

   Sleep 10;
};

Cheers...
« Last Edit: 31 Dec 2008, 04:11:11 by Shadow.D. ^BOB^ »

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Call To Prayer...
« Reply #6 on: 31 Dec 2008, 08:44:48 »
Change
Code: [Select]
_gamelogic="logic" createVehicle [0,0,0];by
Code: [Select]
_gamelogic="logic" createVehicleLocal [0,0,0];as this script will be running in every client.

Also, you will never hear the sound placing the gamelogic at position [0,0,0]
change [0,0,0] by (getPos player) just for testing, later put there the correct position of the sound source.

Offline Shadow.D. ^BOB^

  • Members
  • *
Re: Call To Prayer...
« Reply #7 on: 31 Dec 2008, 16:29:42 »
Hmmm i have made all the changes, set the logic pos to getPos player.  Still no sound coming through, ive set it to the diff times of day, even waited a couple of minutes either side of the hour, but nothing.  I fear im totally missing something, but i dont really know what to look for.  If i attach the sound file here, is there any chance one of you loverly people could spend some of you valuable time creating a small example of the script?  :-[ :-[

Cheers guys...

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: Call To Prayer...
« Reply #8 on: 31 Dec 2008, 16:50:20 »
Is it possible that your playing the sound at the gamelogic location of 0,0,0?
Are you able to hear the sound if you use playsound? within the script?

If you move the _gamelogic say "Adhan";  to the top of the script are you able to hear it?In the script below I don't see you setting the position of the GL to the playa
Xbox Rocks

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Call To Prayer...
« Reply #9 on: 31 Dec 2008, 16:59:45 »
My mistake:
Code: [Select]
_gamelogic="logic" createVehicle [0,0,0];
_times_to_play = [5, 12, 15, 18, 19];
_played_times = [0, 0, 0, 0, 0];
_i = 0;
while {true} do
{
   _i = 0;
   {
      if (abs (dayTime - _x) < 0.05) then
      {
         if ((_played_times select _i) == 0) then
         {
            _played_times set [_i, 1];
            _gamelogic say "Adhan";
         };
      };
      _i = _i + 1;
   } forEach _times_to_play; 

   if (dayTime > (_times_to_play select 4)) then
   {
      _played_times = [0, 0, 0, 0, 0];
   };

   Sleep 10;
};

Offline Shadow.D. ^BOB^

  • Members
  • *
Re: Call To Prayer...
« Reply #10 on: 31 Dec 2008, 17:23:13 »
Cheers mandoble, kinda working.  At least script wise, although i'm getting that is cant find the sound file.  My description includes
Code: [Select]
class CfgSounds
{
sounds[] = {Adhan};

class scream
{
name = "Adhan";
sound[] = {"Adhan.ogg", db+0, 1.0};
titles[] = {0,""};
};
};

I can then use the sound in triggers, so its def in there some how. Seems the script cant find it.

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Call To Prayer...
« Reply #11 on: 31 Dec 2008, 19:14:06 »
The sound problem was my mistake.  I was replacing "scream" everywhere with "adhan", but missed the class name, so change "class scream" to "class adhan" in the description.ext, so it looks like this:

Code: [Select]
class CfgSounds
{
sounds[] = {Adhan};

class adhan
{
name = "Adhan";
sound[] = {"Adhan.ogg", db+0, 1.0};
titles[] = {0,""};
};
};
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline Shadow.D. ^BOB^

  • Members
  • *
Re: Call To Prayer...
« Reply #12 on: 31 Dec 2008, 20:57:59 »
You guys......

 :good: :good: :good:  Sorted, all seems to be working fine.  Will report back if i have any bugs, thankyou all for your help.


Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Call To Prayer...
« Reply #13 on: 31 Dec 2008, 21:01:52 »
Amen


Sorry totally off-topic, somebody shoot me.....hicc :(


Planck
I know a little about a lot, and a lot about a little.

Offline hoz

  • OFPEC Site
  • Administrator
  • *****
Re: Call To Prayer...
« Reply #14 on: 31 Dec 2008, 21:57:28 »
Bob, consider submitting your work to the ED this is something maybe other people might wish to use in their missions.
Xbox Rocks