• Trouble with Dedicated Server Worshop
    5 replies, posted
Hey guys, i kinda need some help with my GMod server that uses steam workshop to download addons. I have my server switch to different collections for different gamemodes in the batch script, and it downloads everything and works perfectly for the server. The problem i am having is my lua script in the resource.lua file. I want the server to test what gamemode it is, and make the client download those addons using resource.AddWorkshop() but its not working. This is what i have: [CODE] if ( SERVER ) then if (gmod.GetGamemode().Name == "Trouble in Terrorist Town") then --ADDONS(ttt) resource.AddWorkshop("127865722") --More_ttt_ulx_commands resource.AddWorkshop("249131537") --TTT_Flashbang resource.AddWorkshop("254177306") --TTT_S.L.A.M resource.AddWorkshop("185609021") --Atmos resource.AddWorkshop("194965598") --TTT_Wapon_collection resource.AddWorkshop("252189849") --Orbital_bass_cannon resource.AddWorkshop("151583504") --MapVote resource.AddWorkshop("265714452") --TTT_Grappel_hook resource.AddWorkshop("107155115") --Pony_Playermodel resource.AddWorkshop("104694154") --mane_six resource.AddWorkshop("106904944") --My_Little_Other_Ponies resource.AddWorkshop("111567786") --My_Little_Other_Ragdolls --MAPS(ttt) --ttt maps http://maps.theterrornetwork.com/ resource.AddWorkshop("273504738") --TTT_krusty_krab resource.AddWorkshop("270494654") --ttt_mc_tipsky_b4 resource.AddWorkshop("121935805") --TTT_Vessel resource.AddWorkshop("195227686") --TTT_Dolls resource.AddWorkshop("159321088") --TTT_minecraft_b5 resource.AddWorkshop("141103402") --ttt_bb_teenroom_b2 resource.AddWorkshop("264985131") --TTT_Suburb resource.AddWorkshop("104647026") --ttt_67thway_v3 resource.AddWorkshop("260153473") --ttt_mc_mineshaft end if (gmod.GetGamemode().Name == "Sandbox") then --ADDONS(sandbox) resource.AddWorkshop("266915261") --Melon_gun resource.AddWorkshop("160250458") --wiremod resource.AddWorkshop("107155115") --Pony_Playermodel resource.AddWorkshop("104694154") --mane_six resource.AddWorkshop("106904944") --My_Little_Other_Ponies resource.AddWorkshop("111567786") --My_Little_Other_Ragdolls --MAPS(sandbox) end end [/CODE] I dont want the client to download all of the addons, i just want the client to download the addons like MapVote and TTT_Grappel_Hook only when the gamemode is TTT, and only the addons like wiremod when the gamemode is sandbox. I dont know if im writing this script right, because it isnt working. I would like to know if i am doing something wrong or if there is a better way to do this :P Thanks guys, nern P.S. i have intermediate programming experience, but not in lua. [EDIT:] This is my batch script to start up the server: [CODE] @echo off set /p gm=murder(m) or ttt(t) or sandbox(s) : :srcds ::murder if %gm%==m ( set col=277510694 set map=cs_office set players=15 set gamemode=murder goto start ) ::TTT if %gm%==t ( set col=269206640 set map=ttt_minecraft_b5 set players=50 set gamemode=terrortown goto start ) ::sandbox if %gm%==s ( set col=277901674 set map=gm_flatgrass set players=50 set gamemode=sandbox goto start ) goto inval :start cls title SRCDS Watchdog echo (%time%) srcds started. start /wait srcds.exe -console -game garrysmod +gamemode %gamemode% +map %map% +maxplayers %players% +port 27015 +host_workshop_collection %col% -authkey <you dont need to see this :P> echo (%time%) WARNING: srcds closed or crashed, restarting. goto srcds :inval timeout 3 >NUL start Start.bat exit [/CODE]
You should probably just use GAMEMODE_NAME; gmod.GetGamemode().Name is redundant when you can access the table directly. Also, you probably shouldn't send every map at once. Use game.GetMap()
Have you tried elseif on he sandbox? [CODE]if ( SERVER ) then if (gmod.GetGamemode().Name == "Trouble in Terrorist Town") then --ADDONS(ttt) resource.AddWorkshop("127865722") --More_ttt_ulx_commands resource.AddWorkshop("249131537") --TTT_Flashbang resource.AddWorkshop("254177306") --TTT_S.L.A.M resource.AddWorkshop("185609021") --Atmos resource.AddWorkshop("194965598") --TTT_Wapon_collection resource.AddWorkshop("252189849") --Orbital_bass_cannon resource.AddWorkshop("151583504") --MapVote resource.AddWorkshop("265714452") --TTT_Grappel_hook resource.AddWorkshop("107155115") --Pony_Playermodel resource.AddWorkshop("104694154") --mane_six resource.AddWorkshop("106904944") --My_Little_Other_Ponies resource.AddWorkshop("111567786") --My_Little_Other_Ragdolls --MAPS(ttt) --ttt maps http://maps.theterrornetwork.com/ resource.AddWorkshop("273504738") --TTT_krusty_krab resource.AddWorkshop("270494654") --ttt_mc_tipsky_b4 resource.AddWorkshop("121935805") --TTT_Vessel resource.AddWorkshop("195227686") --TTT_Dolls resource.AddWorkshop("159321088") --TTT_minecraft_b5 resource.AddWorkshop("141103402") --ttt_bb_teenroom_b2 resource.AddWorkshop("264985131") --TTT_Suburb resource.AddWorkshop("104647026") --ttt_67thway_v3 resource.AddWorkshop("260153473") --ttt_mc_mineshaft elseif (gmod.GetGamemode().Name == "Sandbox") then --ADDONS(sandbox) resource.AddWorkshop("266915261") --Melon_gun resource.AddWorkshop("160250458") --wiremod resource.AddWorkshop("107155115") --Pony_Playermodel resource.AddWorkshop("104694154") --mane_six resource.AddWorkshop("106904944") --My_Little_Other_Ponies resource.AddWorkshop("111567786") --My_Little_Other_Ragdolls --MAPS(sandbox) end end[/CODE] Hasn't been tested but I think it needed one.
[QUOTE=code_gs;45257526]You should probably just use GAMEMODE_NAME; gmod.GetGamemode().Name is redundant when you can access the table directly. Also, you probably shouldn't send every map at once. Use game.GetMap()[/QUOTE] I tried that, but that doesnt work either. anything else? or do i just have to set up a different server for each?
Print what gmod.GetGamemode().Name and GAMEMODE_NAME are equal to before you call them.
[QUOTE=code_gs;45260090]Print what gmod.GetGamemode().Name and GAMEMODE_NAME are equal to before you call them.[/QUOTE] oops lol forgot to do that. It worked! Thanks for the help, i really needed it :P
Sorry, you need to Log In to post a reply to this thread.