> For the complete documentation index, see [llms.txt](https://captaindiqhedd.gitbook.io/caps-archive-space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://captaindiqhedd.gitbook.io/caps-archive-space/caps-titanfall-2-mods-v1/mod-guides/almost-done-music.md).

# Almost Done Music

This is an alternate version of specific time music, where instead of checking the match's time remaining you instead check what the score is. It's also my personal favorite type of music mod.

## File Location

Almost Done Music uses the file located in:\
**scripts/vscripts/client/cl\_gamestate.gnut**

[**Click here for more info on unpacking/repacking vpks**](/caps-archive-space/caps-titanfall-2-mods-v1/how-to-guides/unpack-repack-.vpk-files.md)

## What To Do

Because of the location we write our almost done music code in, we need to force it to only run our code one time, because the area we put it in is repeatedly run for updating the game's score.\
To do this, at the top we'll establish our integer. In this example we'll call it **almostdone** and set it to 0.

<figure><img src="https://3229178430-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyzWpbBNlNErdKoq8n9DL%2Fuploads%2FFeQKhJry9iPWAzjGjdnP%2Fspaces_-MbT6A_iN6z35klmSlMZ_uploads_JguOSHzuE7mqlgZOxxcm_bandicam%202021-10-11%2011-46-24-406.webp?alt=media&amp;token=7bf8acd0-15a0-4f2a-bb34-67fa76c55c77" alt=""><figcaption></figcaption></figure>

Scroll through until you get to `void function TEMP_UpdateRuiScores` which should be around line 350.

<figure><img src="https://3229178430-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyzWpbBNlNErdKoq8n9DL%2Fuploads%2FUKZZFHKlXMhSKGzHAUDC%2Fbandicam%202021-10-11%2011-50-10-774.png?alt=media&amp;token=2f1686a9-8caf-4e05-b146-873076835cd1" alt=""><figcaption></figcaption></figure>

**Scroll all the way to the bottom of this particular function.**

**Under the line** `RuiSetGameTime` **is where we'll put our code.**

<figure><img src="https://3229178430-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyzWpbBNlNErdKoq8n9DL%2Fuploads%2FnYJ7PzpXUAKsgyszyaWD%2Fspaces_-MbT6A_iN6z35klmSlMZ_uploads_nCOK00AD2Lvi7xvUd67W_bandicam%202021-10-15%2013-21-59-816.webp?alt=media&amp;token=3eb89d14-6568-4bd1-8424-6ce89484d757" alt=""><figcaption></figcaption></figure>

### Checking Mode Scores

Because we are directly checking the numbers of the score, and these numbers vary widely depending on your gamemode, we'll have to specify scores for each gamemode individually. If you want your music to play near the end of every mode, this can take a while.

Here is a full list of the playable modes with their corresponding GAMETYPE:

`AI_TDM = Attrition`\
`ATTRITION = Bounty Hunt`\
`CAPTURE_POINT = Amped Hardpoint`\
`LAST_TITAN_STANDING = Last Titan Standing`\
`CAPTURE_THE_FLAG = Capture The Flag`\
`PILOT_SKIRMISH = Pilots VS Pilots`\
`SPEEDBALL = Live Fire`\
`TITAN_BRAWL = Titan Brawl`\
`COLISEUM = Coliseum`\
`MARKED_FOR_DEATH = Marked For Death`

For checking the match score of a particular gamemode, you would write it out like this:

```
	if(GAMETYPE==[GAMETYPE] && (GameRules_GetTeamScore(friendlyTeam) > [score] || GameRules_GetTeamScore(enemyTeam) > [score]) && almostdone==0)
	{
		int totalnumber = RandomInt([number])
		GetLocalClientPlayer().ClientCommand("almostdone"+totalnumber)
		almostdone=1
	}
```

Where **\[GAMETYPE]** is one of the gametypes from above, **\[score]** is the amount of points you would want either team to have before this music starts to play - 1, and **\[number]** is the amount of possible music tracks that can play.

I have the code set up for all the main modes below. These also show my recommended settings for each mode.

<figure><img src="https://3229178430-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyzWpbBNlNErdKoq8n9DL%2Fuploads%2Fps9gUfrzIjzGiHab8RCK%2Fbandicam%202021-10-11%2019-27-48-415.png?alt=media&amp;token=f4e7c7c9-8251-4f07-85b6-ea36d07aa7f4" alt=""><figcaption></figcaption></figure>

For LTS and Live Fire, I recommend setting it up where the music will play if both teams are tied and that round has to be the last. This makes it a bit more climactic and it won't play if one team is one round away but the other team takes it. You can do this by simply putting **&&** between the two team score checks instead of **||**.

If you want certain modes to have alternate music play, you can just set up a different variable like you did for **almostdone**, and check for that instead. This would mainly be good if you want the music in Live Fire, but the buildup is too slow for that mode specifically, so you can make versions with quicker buildups.

## How to force music to stop at end of the match

You probably don't want your Almost Done music to continue playing after the round/match has reached its conclusion. To turn it off, we have to run the **stopvideos** command in the area that runs when the match ends. If you've done [**Victory/Defeat/Draw Music**](broken://pages/-MjW2mLBspdasYgveL8p), you'll know where this is.

Scroll until you get to `void function ServerCallback_AnnounceWinner` which should be around line 796. You'll see multiple if statements with things in them, the ones we care about contain `#GAMEMODE_DRAW`, `#GAMEMODE_VICTORY`, `#GAMEMODE_DEFEATED`, `#GAMEMODE_ROUND_DRAW`, `#GAMEMODE_ROUND_WIN`, and `#GAMEMODE_ROUND_LOSS`

At the end of each of these areas *(the same place you would put custom end of match music)* you need to add this code:

```
GetLocalClientPlayer().ClientCommand("stopvideos")
```

This runs the **stopvideos** command, which basically turns off any currently playing custom sounds you have. Because of this, you should put this code **BEFORE** your custom end of match music, if you have any.

<figure><img src="https://3229178430-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyzWpbBNlNErdKoq8n9DL%2Fuploads%2FlBiCgd6qULcCppSkLvLa%2Fbandicam%202021-10-15%2013-15-04-011.png?alt=media&amp;token=11a6a961-f0d3-465b-bfd5-6aa9c598e1e0" alt=""><figcaption></figcaption></figure>

With all that done, you can repack your vpk.

## media and autoexec.cfg

{% hint style="info" %}
Keep in mind when making your custom audio tracks for this, there's no guarantee on how long it will take the match to end after getting to the score threshold you set up. I recommend making your custom tracks at least 3 minutes long if you want to ensure they don't end before the match does. Of course, the earlier you set your music to play, the larger the margin of error you should account for. Anything can happen!

For round-based modes like LTS and Live Fire, you don't really need to worry about this since the maximum amount of time that the music can play will always be the same, assuming you set it up like I did.
{% endhint %}

As usual, put your custom .bik files into the media folder and ensure they're named correctly.

<figure><img src="https://3229178430-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyzWpbBNlNErdKoq8n9DL%2Fuploads%2FfWgUdwTb1AZewpsTuE4D%2Fspaces_-MbT6A_iN6z35klmSlMZ_uploads_u1Ov57kjoZcW76AR6Xn8_bandicam%202021-10-15%2013-27-51-160.webp?alt=media&amp;token=292b3466-d754-4fa7-af2e-8ec539a2e2e0" alt=""><figcaption><p><a href="/caps-archive-space/caps-titanfall-2-mods-v1/how-to-guides/converting-to-.bik.md"><strong>Click here for more info on .bik files</strong></a></p></figcaption></figure>

Not sure what music to use? You can check out the one's I've already made [here](https://mega.nz/folder/pcVWATYL#RyTDgMara2woVMDL5uHGnA/folder/NMlFFYZQ).

Write out your aliases in the autoexec like so:

<figure><img src="https://3229178430-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FyzWpbBNlNErdKoq8n9DL%2Fuploads%2FxqxVnq4xJz9LTC4pg3oU%2Fspaces_-MbT6A_iN6z35klmSlMZ_uploads_PQiuEhGfLH4gNnKMqnpb_bandicam%202021-10-15%2013-29-25-932.webp?alt=media&amp;token=d34ec340-cb26-4670-9aca-1a17a9f6fe0a" alt=""><figcaption><p><a href="/caps-archive-space/caps-titanfall-2-mods-v1/how-to-guides/autoexec.cfg.md"><strong>Click here for more info on the autoexec</strong></a></p></figcaption></figure>

Your music should now be working!
