Detect if a player has CS:S mounted/installed.

Hey guys!

From my experience, half the people on Garry’s Mod don’t even have CS:S installed. This can cause many problems and will cause many people to leave due to the missing textures, models, etc.

I am launching a “game-server” dedicated to downloading ALL the content in CS:S from a FastDL server. However, I need to find a way to detect where they have it installed or not.

This is basically the script:


if LocalPlayer():HasCSS() then
LocalPlayer():ConCommand("connect downloadcss.auroraen.com")
end

HasCSS() doesn’t exist of course, so is there a working solution?

This server will be free for server owners to use by the way. Just refer the players to go there and they will be automatically kicked when they finish downloading.

There’s a couple of inherent issues with doing this.

  1. IsMounted( “cstrike” ) can be used to detect if the player has CSS, but it’s broken serverside on dedicated servers: http://wiki.garrysmod.com/page/Global/IsMounted
  2. Sending a content pack to players could interfere with content packs that the player already has with CSS content.

Thanks!

The script is going to ran client-side so I don’t think that’s going to be a problem.

There will be a window popup with 3 buttons if they are detected without CS:S mounted.

| Download | Close | Do not ask me again |

Very useful idea if this pans out

Since IsMounted doesnt exactly work if they have a content pack you could check to see if the player is in posession of certain specific files using file.Exists.

IsMounted works fine clientside iirc. file.Exists is unreliable for detecting if a player has a game since they could have downloaded individual files from a server.

Hmm, you’re right.
Wait OP, how are you downloading your content?

Extracted from CS:S vpk’s from steamcmd.
Then uploaded onto server using SourceRSC.
Then resource.AddFile to everything


	local function AddResourceDir(dir)
		local files, dirs = file.Find(dir.."/*", "GAME")

		for _, fdir in pairs(dirs) do
			if fdir != ".svn" then
				AddResourceDir(dir.."/"..fdir)
			end
		end

		for k,v in pairs(files) do
			//print(dir.."/"..v)
			resource.AddSingleFile(dir.."/"..v)
		end
	end

But how are you going to send it to the player? If they’re already in the server, how could they download the content? Make them copy a link and download it in their browser?

The only way I could think about handling it would to redirect them to a server specifically setup to download the content via FastDL/WorkshopDL, and then redirect them back to the main server. That would just be unreliable and unoptimized, though.

[editline]17th March 2014[/editline]

Just resource.AddFile .mdl, .wav, and .vmt files only. It’s much more efficient.

If you havent noticed that’s exactly what he’s doing

In the original post, I said I was going to send them to a SEPARATE server dedicated to downloading CS:S from a FastDL server. They will be kicked afterwards and they will keep the files for all servers unless they delete their download folder.

Unoptimized, yes, but I cannot see a better way. Players aren’t forced to download the files, they can just ignore the window and it will never be shown again.

You could just do it with your main server, by doing something like


if playerChoice == yes then
      resource.AddFile("content")
      LocalPlayer():ConCommand("connect main server")
end

All done by one server, no need for any redirects.

The issue with that is CS:S extracted has a LOT of files. You’re limited t 4096 or so for FastDL… Sending CS:S content isn’t recommended either, Garry’s Mod comes with fallbacks so they won’t have ERROR models.

Don’t send paid content… GMod has fallbacks…

I think you’re right.

Though, I haven’t seen any of Gmod’s fallbacks working. My brother only has Garry’s Mod and every map that requires CS:S is COMPLETELY purple. Not just legacy maps like cs_office, but maps like 67th way.

There’s not a fallback for every single texture, just necessary stuff.

Perhaps I should only make it download materials, not models.
That should make things at least playable. No more purple textures everywhere.

They should really include CSS skyboxes in gmod, those are super popular among map builders.

There are workshop files with css content in them, just add workshop items in your download server rather serving in fastdl, much quicker when there’s large amount of small files that way anyway.

This for example http://steamcommunity.com/sharedfiles/filedetails/?id=237108108

The point is to not force people to download a content pack if they already have content

Besides, workshop addons have a degree of indurability… they seem to be auto deleted after a short while.

Well, sending 18k+ files over FastDL is not really going to work.

Lots of small files slows down FastDL majorly, and FastDL has a file limit.
There’s not really any other choice.

File limit is around 4096 for FastDL. Workshop is much faster too.