Results 1 to 8 of 8

Thread: How complete a script?

  1. #1
    Ace 1lokos's Avatar
    Join Date
    Jan 2012
    Posts
    5,323
    Post Thanks / Like
    Total Downloaded
    1.04 GB

    How complete a script?

    I find this partial scrip in Forum1c/Cliffs, what is need add to be able to test?

    Or what set for start the "SoundPlayer"?

    Code:
    public void playSound(string sound, int trigger)
        {
            try
            {
                SoundPlayer singleSound = new SoundPlayer("parts\\Sounds\\" + sound + ".wav");
                if ((trigger < 0) || (trigger > 2))
                {
                    trigger = 2;
                }
    
                if (trigger == 0)   // To play a sound
                {
                    singleSound.Play();
                }
                if (trigger == 1)   // To loop a sound
                {
                    singleSound.PlayLooping();
                }
                if (trigger == 2)    // to stop looping
                {
                    singleSound.Stop();
                }
            }
            catch (Exception e) { }	
    	}
    }
    // playSound("scream01", 0); 
    // This will play the sound scream01.wav one time

  2. #2
    Ace 1lokos's Avatar
    Join Date
    Jan 2012
    Posts
    5,323
    Post Thanks / Like
    Total Downloaded
    1.04 GB

    Re: How complete a script?

    In Desastersoft Demo scrip are some custom sounds, played by this part of the script:

    Code:
    //$reference "parts\desastersoft\psCampaign.dll"
    //$reference "parts\desastersoft\psCoD.dll"
    //-$debug
    ...
    using PSCoD;
    ....
    
    {
                        if (Campaign != null)
                            Campaign.battleSuccess = true;
    
                        TC.addMessage(msgOutputType.all, "MISSION ACCOMPLISHED! They have " + Pilot.getMyTargetNumberByRef("SpitfireMkI").ToString() + " Spitfire shot down!", "Desastersoft\\DFC\\Sounds\\de\\1_2.wav");
                        TC.noTarget = true;
                    }
    I guess that using the custom psCoD.dll

  3. #3
    ATAG_Colander's Avatar
    Join Date
    Nov 2011
    Location
    Bir Tawil
    Posts
    11,128
    Post Thanks / Like
    Total Downloaded
    255.73 MB

    Re: How complete a script?

    Hi Sokol,

    I think what you are asking is all there....

    This is where you define a variable "singleSound" that has the indicated WAV defined as what to play (relative path of the wav file starting from the game installation folder):
    Code:
    SoundPlayer singleSound = new SoundPlayer("parts\\Sounds\\" + sound + ".wav");
    This is where you tell the variable defined above to play (once) the sound it has defined:
    Code:
    singleSound.Play();
    This is where you can tell the variable defined above to play the sound it has defined in a constant loop over and over:
    Code:
    singleSound.PlayLooping();
    This is where you tell the variable defined above to stop playing the sound that was started with "play" or "playlooping" above:
    Code:
    singleSound.Stop();

  4. #4
    Ace 1lokos's Avatar
    Join Date
    Jan 2012
    Posts
    5,323
    Post Thanks / Like
    Total Downloaded
    1.04 GB

    Re: How complete a script?

    The thing is that FMB compiler ask for a reference for SoundPlayer, say that "namespace" was not found.

  5. #5
    ATAG Member ATAG_Oskar's Avatar
    Join Date
    Nov 2017
    Location
    Canada
    Posts
    986
    Post Thanks / Like
    Total Downloaded
    908.31 MB

    Re: How complete a script?

    Quote Originally Posted by 1lokos View Post
    The thing is that FMB compiler ask for a reference for SoundPlayer, say that "namespace" was not found.
    Are you:

    using System.Media

  6. #6
    Ace 1lokos's Avatar
    Join Date
    Jan 2012
    Posts
    5,323
    Post Thanks / Like
    Total Downloaded
    1.04 GB

    Re: How complete a script?

    Adding this "System.Media" fix the last warning, but still nothing to hear.

  7. #7
    ATAG Member ATAG_Oskar's Avatar
    Join Date
    Nov 2017
    Location
    Canada
    Posts
    986
    Post Thanks / Like
    Total Downloaded
    908.31 MB

    Re: How complete a script?

    For

    SoundPlayer singleSound = new SoundPlayer("parts\\Sounds\" + sound + ".wav");

    Try

    SoundPlayer singleSound = new SoundPlayer("C:\\myRealSoundFile.wav");

    Check your log file for 'file not found' errors.

  8. #8
    Ace 1lokos's Avatar
    Join Date
    Jan 2012
    Posts
    5,323
    Post Thanks / Like
    Total Downloaded
    1.04 GB

    Re: How complete a script?

    Tried with several parts of C# scripts with "SoundPlayer" but not luck, seems that are lacking a "start play" event...

    But, I can confirm that play a .wav file in game is possible.

    I find there in an old backup files of Desastersoft Campaign Demo, although are not able to make the demo start (in 4.312) anymore, probable due the auto update no longer available.

    But be set the files as ordinary 3rd part campaign, keeping the reference for they custom .DLL, an custom audio file in the mission (a .wav simulating a radio call) work OK.

    Their script use TC. - that seems "a reference to the TgPlayOgg project and import the TG.Sound namespace."

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •