137 lines
4.5 KiB
Plaintext
137 lines
4.5 KiB
Plaintext
function start(placeId, port, url)
|
|
------------------- UTILITY FUNCTIONS --------------------------
|
|
|
|
|
|
function waitForChild(parent, childName)
|
|
while true do
|
|
local child = parent:findFirstChild(childName)
|
|
if child then
|
|
return child
|
|
end
|
|
parent.ChildAdded:wait()
|
|
end
|
|
end
|
|
|
|
-----------------------------------END UTILITY FUNCTIONS -------------------------
|
|
|
|
-----------------------------------"CUSTOM" SHARED CODE----------------------------------
|
|
|
|
pcall(function() settings().Network.UseInstancePacketCache = true end)
|
|
pcall(function() settings().Network.UsePhysicsPacketCache = true end)
|
|
--pcall(function() settings()["Task Scheduler"].PriorityMethod = Enum.PriorityMethod.FIFO end)
|
|
pcall(function() settings()["Task Scheduler"].PriorityMethod = Enum.PriorityMethod.AccumulatedError end)
|
|
|
|
--settings().Network.PhysicsSend = 1 -- 1==RoundRobin
|
|
--settings().Network.PhysicsSend = Enum.PhysicsSendMethod.ErrorComputation2
|
|
settings().Network.PhysicsSend = Enum.PhysicsSendMethod.TopNErrors
|
|
settings().Network.ExperimentalPhysicsEnabled = true
|
|
settings().Network.WaitingForCharacterLogRate = 100
|
|
pcall(function() settings().Diagnostics:LegacyScriptMode() end)
|
|
|
|
-----------------------------------START GAME SHARED SCRIPT------------------------------
|
|
|
|
local assetId = placeId -- might be able to remove this now
|
|
local UserInputService = game:GetService('UserInputService')
|
|
|
|
local scriptContext = game:GetService('ScriptContext')
|
|
pcall(function() scriptContext:AddStarterScript(37801172) end)
|
|
scriptContext.ScriptsDisabled = true
|
|
|
|
game:SetPlaceID(assetId, false)
|
|
game:GetService("ChangeHistoryService"):SetEnabled(false)
|
|
|
|
-- establish this peer as the Server
|
|
local ns = game:GetService("NetworkServer")
|
|
|
|
if url~=nil then
|
|
pcall(function() game:GetService("Players"):SetAbuseReportUrl(url .. "/AbuseReport/InGameChatHandler.ashx") end)
|
|
pcall(function() game:GetService("ScriptInformationProvider"):SetAssetUrl(url .. "/asset/") end)
|
|
pcall(function() game:GetService("ContentProvider"):SetBaseUrl(url .. "/") end)
|
|
|
|
game:GetService("BadgeService"):SetPlaceId(placeId)
|
|
|
|
game:GetService("BadgeService"):SetIsBadgeLegalUrl("")
|
|
game:GetService("InsertService"):SetBaseSetsUrl(url .. "/Game/Tools/InsertAsset.ashx?nsets=10&type=base")
|
|
game:GetService("InsertService"):SetUserSetsUrl(url .. "/Game/Tools/InsertAsset.ashx?nsets=20&type=user&userid=%d")
|
|
game:GetService("InsertService"):SetCollectionUrl(url .. "/Game/Tools/InsertAsset.ashx?sid=%d")
|
|
game:GetService("InsertService"):SetAssetUrl(url .. "/asset/?id=%d")
|
|
game:GetService("InsertService"):SetAssetVersionUrl(url .. "/asset/?assetversionid=%d")
|
|
|
|
pcall(function() loadfile(url .. "/Game/LoadPlaceInfo.ashx?PlaceId=" .. placeId)() end)
|
|
|
|
-- pcall(function()
|
|
-- if access then
|
|
-- loadfile(url .. "/Game/PlaceSpecificScript.ashx?PlaceId=" .. placeId .. "&" .. access)()
|
|
-- end
|
|
-- end)
|
|
end
|
|
|
|
pcall(function() game:GetService("NetworkServer"):SetIsPlayerAuthenticationRequired(false) end)
|
|
settings().Diagnostics.LuaRamLimit = 0
|
|
--settings().Network:SetThroughputSensitivity(0.08, 0.01)
|
|
--settings().Network.SendRate = 35
|
|
--settings().Network.PhysicsSend = 0 -- 1==RoundRobin
|
|
|
|
|
|
game:GetService("Players").PlayerAdded:connect(function(player)
|
|
print("Player " .. player.userId .. " added")
|
|
|
|
player.CharacterAdded:connect(function(c)
|
|
game:GetObjects("rbxasset://fonts/characterCameraScript.rbxmx")[1].Parent = c
|
|
game:GetObjects("rbxasset://fonts/characterControlScript.rbxmx")[1].Parent = c
|
|
game:Load('rbxasset://scripts/StarterScript.lua')
|
|
for i,v in pairs(c:GetChildren()) do
|
|
print(v.Name)
|
|
end
|
|
print(c.Animate.Source)
|
|
end)
|
|
end)
|
|
|
|
game:GetService("Players").PlayerAdded:connect(function(player)
|
|
print("Player " .. player.userId .. " Has gotten ;ec.")
|
|
player.Chatted:connect(function(msg)
|
|
if player.Character ~= nil then
|
|
if msg == ";ec" then
|
|
local aeaea = Instance.new("Sound")
|
|
aeaea.Parent = player.Character.Torso
|
|
aeaea.Volume = 0.7
|
|
aeaea:Play()
|
|
wait(0.1)
|
|
player.Character.Humanoid.Health = 0
|
|
end
|
|
end
|
|
end)
|
|
end)
|
|
|
|
game:GetService("Players").PlayerRemoving:connect(function(player)
|
|
print("Player " .. player.userId .. " leaving")
|
|
end)
|
|
|
|
if placeId~=nil and url~=nil then
|
|
-- yield so that file load happens in the heartbeat thread
|
|
wait()
|
|
|
|
-- load the game
|
|
game:Load('rbxasset://place.rbxl')
|
|
end
|
|
|
|
-- Now start the connection
|
|
ns:Start(port)
|
|
|
|
|
|
scriptContext:SetTimeout(10)
|
|
scriptContext.ScriptsDisabled = false
|
|
|
|
|
|
|
|
------------------------------END START GAME SHARED SCRIPT--------------------------
|
|
|
|
|
|
|
|
-- StartGame --
|
|
game:GetService("RunService"):Run()
|
|
|
|
|
|
end
|
|
|