Results 1 to 7 of 7

Thread: Timer in Script not work

  1. #1
    Combat pilot Veteran66's Avatar
    Join Date
    Jan 2013
    Posts
    114
    Post Thanks / Like
    Total Downloaded
    195.39 MB

    Timer in Script not work

    Hi all

    Message and Sound work fine, but with the Timer not, what is wrong?
    -----------------------------------------------------------------------------------------------------------------------------

    if ("trigger_zielgetroffen1".Equals(shortName) && active)

    double initTime = 0.0;
    Timeout(initTime += 20.0, () =>

    {
    GamePlay.gpHUDLogCenter("Ziel getroffen 1");
    System.Media.SoundPlayer player = new System.Media.SoundPlayer(BaseMissionPath + "sound1.wav");
    player.Play();
    }
    My System:
    Windows 11
    RAM 64,0 GB
    Intel i7 3.80GHz
    NIVIDIA GeForce RTX 3070

  2. #2
    Ace Bonditaria's Avatar
    Join Date
    Oct 2015
    Location
    Rotterdam
    Posts
    1,119
    Post Thanks / Like
    Total Downloaded
    2.77 GB

    Re: Timer in Script not work

    You have an uneven number of brackets in the line "Timeout(initTime += 20.0, () =>" ?

  3. #3
    Team Fusion Artist's Avatar
    Join Date
    Mar 2010
    Posts
    2,823
    Post Thanks / Like
    Total Downloaded
    319.55 MB

    Re: Timer in Script not work

    After you fixed the missing brace Bonditaria pointed out - if that was not just not a copy paste error - try with first command only

    Code:
    if ("trigger_zielgetroffen1".Equals(shortName) && active)
    {
        double initTime = 0.0;
        Timeout(initTime += 20.0, () => {
            GamePlay.gpHUDLogCenter("Ziel getroffen 1");
            // System.Media.SoundPlayer player = new System.Media.SoundPlayer(BaseMissionPath + "sound1.wav");
            // player.Play();
        });
    }

  4. #4
    ATAG_Colander's Avatar
    Join Date
    Nov 2011
    Location
    Bir Tawil
    Posts
    10,995
    Post Thanks / Like
    Total Downloaded
    211.76 MB

    Re: Timer in Script not work

    And...
    initTime is not really needed/used there. You can just do this:
    Code:
    if ("trigger_zielgetroffen1".Equals(shortName) && active)
    {
        Timeout(20.0, () => {
            GamePlay.gpHUDLogCenter("Ziel getroffen 1");
            // System.Media.SoundPlayer player = new System.Media.SoundPlayer(BaseMissionPath + "sound1.wav");
            // player.Play();
        });
    }

  5. Likes Veteran66 liked this post
  6. #5
    Combat pilot Veteran66's Avatar
    Join Date
    Jan 2013
    Posts
    114
    Post Thanks / Like
    Total Downloaded
    195.39 MB

    Re: Timer in Script not work

    thx, work fine
    My System:
    Windows 11
    RAM 64,0 GB
    Intel i7 3.80GHz
    NIVIDIA GeForce RTX 3070

  7. #6
    Novice Pilot Pernix2's Avatar
    Join Date
    Jul 2016
    Posts
    67
    Post Thanks / Like
    Total Downloaded
    35.19 MB

    Re: Timer in Script not work

    Good evening.
    I would like to hear the music in my headphones while I fly my biplane over the Libyan desert.
    I tried to insert the script, attached above, in the File.cs, but nothing, it doesn't work.
    Can anyone tell me step by step how to do it?
    Thank you

    Pernix

  8. #7
    Supporting Member
    Join Date
    Dec 2019
    Posts
    458
    Post Thanks / Like
    Total Downloaded
    11.81 MB

    Re: Timer in Script not work

    Quote Originally Posted by Pernix2 View Post
    Good evening.
    I would like to hear the music in my headphones while I fly my biplane over the Libyan desert.
    I tried to insert the script, attached above, in the File.cs, but nothing, it doesn't work.
    Can anyone tell me step by step how to do it?
    Thank you

    Pernix
    You'd need to let people know what level of scripting you are at, do you make missions already, don't know a thing etc.

    I'd suggest to start a new thread with code from a test mission you are trying to get to work and see if someone can help.

    I don't have time to help right now, but if you are totally a novice check out my guide in the stickies and set up a mission that triggers some text when you take off, or after some timer, or on a trigger you fly thorugh. Then when you know that is working, add in the music playing script at that very point and see if you can get it to work.

    If you are not a total beginner then the first mission of my 303 campaign (for our freedom and yours) plays music when you are within a certain distance of an enemy (I think that is what I used). Download my campaign, open up the first mission and you should be able to find the bit playing the music and pull it apart from there.

    If you want to 'just hear music whilst flying', I'd suggest just use a music player like foobar2000 with whatever it is you require. I picked up some cheap WWII/30s/40s themed music that I use for 'atmopsphere'.
    I am Yo-Yo not YoYo (that's someone else)

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
  •