Advertisement
CoolDocterWho

Untitled

Jun 17th, 2016
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.85 KB | None | 0 0
  1. --rbxsig%AjN++di77v686DuwPvgvEYyOzcI+8jhhnSkv+ty78ijehgxP22S4ZpoYhyI8Qt8OMs+VtzlJk70nekX2GUrUzpRO3qhIuTb2fi6339vaDMmWYLB2ZOoXXx6IjxOPJxyHCkJ4Y8f6x5+aXlQhQj2PtkrwBuOWB3fCT1dH8DSIIUA=%
  2. -- Start Game Script Arguments
  3. local placeId, port, gameId, sleeptime, access, deprecated, timeout, machineAddress, gsmInterval, baseUrl, maxPlayers, maxGameInstances, injectScriptAssetID, apiKey, libraryRegistrationScriptAssetID, deprecated_pingTimesReportInterval, gameCode, universeId, preferredPlayerCapacity, matchmakingContextId, placeVisitAccessKey, assetGameSubdomain, protocol = ...
  4.  
  5. -----------------------------------"CUSTOM" SHARED CODE----------------------------------
  6.  
  7. pcall(function() settings().Network.UseInstancePacketCache = true end)
  8. pcall(function() settings().Network.UsePhysicsPacketCache = true end)
  9. pcall(function() settings()["Task Scheduler"].PriorityMethod = Enum.PriorityMethod.AccumulatedError end)
  10.  
  11.  
  12. settings().Network.PhysicsSend = Enum.PhysicsSendMethod.TopNErrors
  13. settings().Network.ExperimentalPhysicsEnabled = true
  14. settings().Network.WaitingForCharacterLogRate = 100
  15. pcall(function() settings().Diagnostics:LegacyScriptMode() end)
  16.  
  17. -----------------------------------START GAME SHARED SCRIPT------------------------------
  18.  
  19. placeId = 1818
  20. local assetId = placeId -- might be able to remove this now
  21. local url = nil
  22. local assetGameUrl = nil
  23. if baseUrl~=nil and protocol ~= nil then
  24. url = protocol .. "www." .. baseUrl --baseUrl is actually the domain, no leading .
  25. assetGameUrl = protocol .. assetGameSubdomain .. "." .. baseUrl
  26. end
  27.  
  28. local scriptContext = game:GetService('ScriptContext')
  29. pcall(function() scriptContext:AddStarterScript(libraryRegistrationScriptAssetID) end)
  30. scriptContext.ScriptsDisabled = true
  31.  
  32. game:SetPlaceID(assetId, false)
  33. pcall(function () if universeId ~= nil then game:SetUniverseId(universeId) end end)
  34. game:GetService("ChangeHistoryService"):SetEnabled(false)
  35.  
  36. -- establish this peer as the Server
  37. local ns = game:GetService("NetworkServer")
  38. -- Detect cloud edit mode by checking for the dedicated cloud edit matchmaking context
  39. local isCloudEdit = matchmakingContextId == 3
  40. if isCloudEdit then
  41. print("Configuring as cloud edit server!")
  42. game:SetServerSaveUrl(url .. "/ide/publish/UploadFromCloudEdit")
  43. ns:ConfigureAsCloudEditServer()
  44. end
  45.  
  46. if matchmakingContextId == 4 then
  47. print("Configuring as team test server!")
  48. local success, message = pcall(function() ns:ConfigureAsTeamTestServer() end)
  49. if not success then
  50. print("Failed to start team test server: ", message)
  51. end
  52. end
  53.  
  54. local badgeUrlFlagExists, badgeUrlFlagValue = pcall(function () return settings():GetFFlag("NewBadgeServiceUrlEnabled") end)
  55. local newBadgeUrlEnabled = badgeUrlFlagExists and badgeUrlFlagValue
  56. if url~=nil then
  57. local apiProxyUrl = "https://api." .. baseUrl -- baseUrl is really the domain
  58.  
  59. pcall(function() game:GetService("Players"):SetAbuseReportUrl(url .. "/AbuseReport/InGameChatHandler.ashx") end)
  60. pcall(function() game:GetService("ScriptInformationProvider"):SetAssetUrl(assetGameUrl .. "/Asset/") end)
  61. pcall(function() game:GetService("ContentProvider"):SetBaseUrl(url .. "/") end)
  62. pcall(function() game:GetService("Players"):SetChatFilterUrl(assetGameUrl .. "/Game/ChatFilter.ashx") end)
  63.  
  64. if gameCode then
  65. game:SetVIPServerId(tostring(gameCode))
  66. end
  67.  
  68. game:GetService("BadgeService"):SetPlaceId(placeId)
  69.  
  70. if newBadgeUrlEnabled then
  71. game:GetService("BadgeService"):SetAwardBadgeUrl(apiProxyUrl .. "/assets/award-badge?userId=%d&badgeId=%d&placeId=%d")
  72. end
  73.  
  74. if access ~= nil then
  75. if not newBadgeUrlEnabled then
  76. game:GetService("BadgeService"):SetAwardBadgeUrl(assetGameUrl .. "/Game/Badge/AwardBadge.ashx?UserID=%d&BadgeID=%d&PlaceID=%d")
  77. end
  78.  
  79. game:GetService("BadgeService"):SetHasBadgeUrl(assetGameUrl .. "/Game/Badge/HasBadge.ashx?UserID=%d&BadgeID=%d")
  80. game:GetService("BadgeService"):SetIsBadgeDisabledUrl(assetGameUrl .. "/Game/Badge/IsBadgeDisabled.ashx?BadgeID=%d&PlaceID=%d")
  81.  
  82. game:GetService("FriendService"):SetMakeFriendUrl(assetGameUrl .. "/Game/CreateFriend?firstUserId=%d&secondUserId=%d")
  83. game:GetService("FriendService"):SetBreakFriendUrl(assetGameUrl .. "/Game/BreakFriend?firstUserId=%d&secondUserId=%d")
  84. game:GetService("FriendService"):SetGetFriendsUrl(assetGameUrl .. "/Game/AreFriends?userId=%d")
  85. end
  86. game:GetService("BadgeService"):SetIsBadgeLegalUrl("")
  87. game:GetService("InsertService"):SetBaseSetsUrl(assetGameUrl .. "/Game/Tools/InsertAsset.ashx?nsets=10&type=base")
  88. game:GetService("InsertService"):SetUserSetsUrl(assetGameUrl .. "/Game/Tools/InsertAsset.ashx?nsets=20&type=user&userid=%d")
  89. game:GetService("InsertService"):SetCollectionUrl(assetGameUrl .. "/Game/Tools/InsertAsset.ashx?sid=%d")
  90. game:GetService("InsertService"):SetAssetUrl(assetGameUrl .. "/Asset/?id=%d")
  91. game:GetService("InsertService"):SetAssetVersionUrl(assetGameUrl .. "/Asset/?assetversionid=%d")
  92.  
  93. if gameCode then
  94. pcall(function() loadfile(assetGameUrl .. "/Game/LoadPlaceInfo.ashx?PlaceId=" .. placeId .. "&gameCode=" .. tostring(gameCode))() end)
  95. else
  96. pcall(function() loadfile(assetGameUrl .. "/Game/LoadPlaceInfo.ashx?PlaceId=" .. placeId)() end)
  97. end
  98.  
  99. pcall(function()
  100. if access then
  101. loadfile(assetGameUrl .. "/Game/PlaceSpecificScript.ashx?PlaceId=" .. placeId)()
  102. end
  103. end)
  104. end
  105.  
  106. pcall(function() game:GetService("NetworkServer"):SetIsPlayerAuthenticationRequired(true) end)
  107. settings().Diagnostics.LuaRamLimit = 0
  108.  
  109. game:GetService("Players").PlayerAdded:connect(function(player)
  110. print("Player " .. player.userId .. " added")
  111.  
  112. if assetGameUrl and access and placeId and player and player.userId then
  113. local didTeleportIn = "False"
  114. if player.TeleportedIn then didTeleportIn = "True" end
  115.  
  116. game:HttpGet(assetGameUrl .. "/Game/ClientPresence.ashx?action=connect&PlaceID=" .. placeId .. "&UserID=" .. player.userId)
  117. if not isCloudEdit then
  118. game:HttpPost(assetGameUrl .. "/Game/PlaceVisit.ashx?UserID=" .. player.userId .. "&AssociatedPlaceID=" .. placeId .. "&placeVisitAccessKey=" .. placeVisitAccessKey .. "&IsTeleport=" .. didTeleportIn, "")
  119. end
  120. end
  121. end)
  122.  
  123. game:GetService("Players").PlayerRemoving:connect(function(player)
  124. print("Player " .. player.userId .. " leaving")
  125.  
  126. local isTeleportingOut = "False"
  127. if player.Teleported then isTeleportingOut = "True" end
  128.  
  129. if assetGameUrl and access and placeId and player and player.userId then
  130. game:HttpGet(assetGameUrl .. "/Game/ClientPresence.ashx?action=disconnect&PlaceID=" .. placeId .. "&UserID=" .. player.userId .. "&IsTeleport=" .. isTeleportingOut)
  131. end
  132. end)
  133.  
  134. local onlyCallGameLoadWhenInRccWithAccessKey = newBadgeUrlEnabled
  135. if placeId ~= nil and assetGameUrl ~= nil and ((not onlyCallGameLoadWhenInRccWithAccessKey) or access ~= nil) then
  136. -- yield so that file load happens in the heartbeat thread
  137. wait()
  138.  
  139. -- load the game
  140. game:Load(assetGameUrl .. "/asset/?id=" .. placeId)
  141. end
  142.  
  143. -- Configure CloudEdit saving after place has been loaded
  144. if isCloudEdit then
  145. local doPeriodicSaves = true
  146. local delayBetweenSavesSeconds = 5 * 60 -- 5 minutes
  147. local function periodicSave()
  148. if doPeriodicSaves then
  149. game:ServerSave()
  150. delay(delayBetweenSavesSeconds, periodicSave)
  151. end
  152. end
  153. -- Spawn thread to save in the future
  154. delay(delayBetweenSavesSeconds, periodicSave)
  155. -- Hook into OnClose to save on shutdown
  156. game.OnClose = function()
  157. doPeriodicSaves = false
  158. game:ServerSave()
  159. end
  160. end
  161.  
  162. -- Now start the connection
  163. ns:Start(port, sleeptime)
  164.  
  165. if timeout then
  166. scriptContext:SetTimeout(timeout)
  167. end
  168. scriptContext.ScriptsDisabled = false
  169.  
  170.  
  171. -- StartGame --
  172. if not isCloudEdit then
  173. if injectScriptAssetID and (injectScriptAssetID < 0) then
  174. pcall(function() Game:LoadGame(injectScriptAssetID * -1) end)
  175. else
  176. pcall(function() Game:GetService("ScriptContext"):AddStarterScript(injectScriptAssetID) end)
  177. end
  178.  
  179. Game:GetService("RunService"):Run()
  180. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement