MAP resource

hey! im making a server and i only want the map to download if we are playing on it i know there is a function for it so


if map = "one we are using" then resource.AddWorkshop("themap")

just not sure if i need a hook or what function to put it in. there was a tut for this for ttt on the wiki but i cannot find it

Put in lua/autorun/server/

Name it what you want

If you want to do this for multiple maps, do this:



local MapResources = { }

--MapResources[ "gm_flatgrass" ] = "12341456"
--MapResources[ "your map" ] = the map id
--and so on

hook.Add( "Initialize", "Add Map To Downloads" function()
  local x = MapResources[ game.GetMap( ) ]

  if x then resource.AddWorkshop( x ) end
end )


If it is only going to be this map, do this:


hook.Add( "Initialize", "Add Map To Downloads" function()
  if game.GetMap( ) == "the map" then resource.AddWorkshop( "the map id" ) end
end )

sweet thanks! exactly what i was looking for!