Loading Page JavaScript functions

So I’ve read the documentation here: http://wiki.garrysmod.com/page/Loading_URL and everything is running smoothly except for a few things.

For some reason, using the following function



function SetFilesTotal( total )
{

}


‘total’ currently always has the value of 228. I think it’s the number of workshop downloads plus downloads from the server. Is total supposed to be the total number of files required on the server or the total number of files required on the server that the client has not downloaded yet?

ALSO



function SetFilesNeeded( needed )
{

}


I believe this function is supposed to be run whenever a file finishes downloading? Well for me it runs once, and it gives me seemingly the wrong number.

Here’s my problem in action:

Currently, my server downloads 26 files from the workshop when I join it. If I have all those files downloaded already (because I joined the server already), this happens:

https://secure.callumthomson.co.uk/uploads/2014-06-08_00-41-12.png

(26 is the result from the SetFilesNeeded function, it does not change throughout. The 2nd 0 (‘0 overall’) is the result from the SetFilesTotal function.)
It says workshop complete but still says 26 files to download? I have them already, why does it do this?

Now let’s say I delete the 26 gma files downloaded from the workshop and get my game to download them when I rejoin the server. This happens:

https://secure.callumthomson.co.uk/uploads/2014-06-08_00-42-38.png

Now where does this 168 come from?!

Once the download finishes:

https://secure.callumthomson.co.uk/uploads/2014-06-08_00-38-56.png

‘52 of 168’ (52 is double 26, which is the amount of files actually downloaded. For some reason the counter seems to increase by 2 every time a download is completed.). So my download counter almost works… But where has this 168 come from?! If SetFilesNeeded is supposed to tell me how many files are left to download then why does ‘168’ not change throughout the entire download?

I hope I have explained well enough what the issue is. Please let me know if you don’t understand anything or need more details. This has been very frustrating!

Thanks

I don’t think people can help without you posting all the code for that part of your loading screen.



function DownloadingFile( fileName )
{
	filesDownloaded += 1;
	$('#downloadtitle').text( 'Downloading...' )
	$('#downloaditem').text( fileName );
	$('#filesdownloaded').text( filesDownloaded );
	ChangeProgressBar( (filesDownloaded / filesToDownload) * 100 );
}


filesDownloaded is a counter variable I created to track how many files have been downloaded while joining.
filesToDownload is a variable to store the total amount of files needed to download
#downloadtitle is the big text above the progress bar
#downloaditem is the text under the progressbar text
#filesdownloaded is the first number inside the bracket after the percentage
ChangeProgressBar() is a function which changes the the progress of the progress bar and the displayed percentage completion



function SetStatusChanged( status )
{
	$('#status').text( status );
	if(status=="Sending client info...") {
		ChangeProgressBar( 100 );
		$('#downloadtitle').text( 'Download Complete' );
		$('#downloaditem').text('All Downloads Complete!');
	}
}


#status is the text at the bottom



function SetFilesTotal( total )
{
	$('#overall').text( total );
}


#overall is the last number before word ‘overall’



function SetFilesNeeded( needed )
{
	filesToDownload = needed;
	$('#totalitems').text( needed );
}


#totalitems is the number after word ‘of’

Is there anything else you need?