Start work on gameservers
This commit is contained in:
parent
f75619c39e
commit
bb974f8f9c
|
|
@ -1,52 +1,25 @@
|
||||||
local jobId, type, baseUrl, placeId, port, owner = ...
|
local jobId, baseUrl, placeId, port = ...
|
||||||
|
|
||||||
------------------- UTILITY FUNCTIONS --------------------------
|
------------------- UTILITY FUNCTIONS --------------------------
|
||||||
|
|
||||||
function waitForChild(parent, childName)
|
function waitForChild(parent, childName)
|
||||||
while true do
|
while true do
|
||||||
local child = parent:findFirstChild(childName)
|
local child = parent:findFirstChild(childName)
|
||||||
if child then
|
if child then return child end
|
||||||
return child
|
|
||||||
end
|
|
||||||
parent.ChildAdded:wait()
|
parent.ChildAdded:wait()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function update(LeavingPlayer)
|
|
||||||
local names = {}
|
|
||||||
for _, player in pairs(game:GetService("Players"):GetPlayers()) do
|
|
||||||
if (player ~= LeavingPlayer) then
|
|
||||||
table.insert(names, player.Name)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local str = (#names > 0) and (#names > 1) and (names[1] .. ",") or names[1] or ""
|
|
||||||
|
|
||||||
for i = 2, #names -1, 1 do
|
|
||||||
str = str .. names[i] .. ","
|
|
||||||
end
|
|
||||||
|
|
||||||
str = (#names > 0) and (#names > 1) and (str .. names[#names]) or names[1] or ""
|
|
||||||
return str
|
|
||||||
end
|
|
||||||
|
|
||||||
function keepAlive(LeavingPlayer)
|
|
||||||
game:GetService("HttpService"):PostAsync("https://dungblx.cf/API/KeepAlive", game:GetService("HttpService"):JSONEncode({
|
|
||||||
["ServerIP"] = jobId,
|
|
||||||
["PlaceId"] = game.PlaceId,
|
|
||||||
["PlayerCount"] = #game:GetService("Players"):GetPlayers(),
|
|
||||||
["PlayerList"] = update(LeavingPlayer),
|
|
||||||
}))
|
|
||||||
end
|
|
||||||
|
|
||||||
-----------------------------------END UTILITY FUNCTIONS -------------------------
|
-----------------------------------END UTILITY FUNCTIONS -------------------------
|
||||||
|
|
||||||
-----------------------------------"CUSTOM" SHARED CODE----------------------------------
|
-----------------------------------"CUSTOM" SHARED CODE----------------------------------
|
||||||
|
|
||||||
pcall(function() settings().Network.UseInstancePacketCache = true end)
|
pcall(function() settings().Network.UseInstancePacketCache = true end)
|
||||||
pcall(function() settings().Network.UsePhysicsPacketCache = 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)
|
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.PhysicsSend = Enum.PhysicsSendMethod.TopNErrors
|
||||||
settings().Network.ExperimentalPhysicsEnabled = true
|
settings().Network.ExperimentalPhysicsEnabled = true
|
||||||
settings().Network.WaitingForCharacterLogRate = 100
|
settings().Network.WaitingForCharacterLogRate = 100
|
||||||
|
|
@ -54,20 +27,16 @@ pcall(function() settings().Diagnostics:LegacyScriptMode() end)
|
||||||
|
|
||||||
-----------------------------------START GAME SHARED SCRIPT------------------------------
|
-----------------------------------START GAME SHARED SCRIPT------------------------------
|
||||||
|
|
||||||
local assetId = placeId
|
|
||||||
|
|
||||||
local scriptContext = game:GetService("ScriptContext")
|
local scriptContext = game:GetService("ScriptContext")
|
||||||
pcall(function() scriptContext:AddStarterScript(37801172) end)
|
pcall(function() scriptContext:AddStarterScript(37801172) end)
|
||||||
scriptContext.ScriptsDisabled = true
|
scriptContext.ScriptsDisabled = true
|
||||||
|
|
||||||
game:SetPlaceID(assetId, false)
|
game:SetPlaceID(placeId, false)
|
||||||
game:GetService("ChangeHistoryService"):SetEnabled(false)
|
game:GetService("ChangeHistoryService"):SetEnabled(false)
|
||||||
game:SetCreatorId(owner, Enum.CreatorType.User)
|
|
||||||
game:GetService("HttpService").HttpEnabled = true
|
|
||||||
|
|
||||||
local ns = game:GetService("NetworkServer")
|
local ns = game:GetService("NetworkServer")
|
||||||
|
|
||||||
if baseUrl~=nil then
|
if baseUrl ~= nil then
|
||||||
pcall(function() game:GetService("Players"):SetAbuseReportUrl(baseUrl .. "/AbuseReport/InGameChatHandler.ashx") end)
|
pcall(function() game:GetService("Players"):SetAbuseReportUrl(baseUrl .. "/AbuseReport/InGameChatHandler.ashx") end)
|
||||||
pcall(function() game:GetService("ScriptInformationProvider"):SetAssetUrl(baseUrl .. "/Asset/") end)
|
pcall(function() game:GetService("ScriptInformationProvider"):SetAssetUrl(baseUrl .. "/Asset/") end)
|
||||||
pcall(function() game:GetService("ContentProvider"):SetBaseUrl(baseUrl .. "/") end)
|
pcall(function() game:GetService("ContentProvider"):SetBaseUrl(baseUrl .. "/") end)
|
||||||
|
|
@ -84,53 +53,30 @@ if baseUrl~=nil then
|
||||||
pcall(function() loadfile(baseUrl .. "/Game/LoadPlaceInfo.ashx?PlaceId=" .. placeId)() end)
|
pcall(function() loadfile(baseUrl .. "/Game/LoadPlaceInfo.ashx?PlaceId=" .. placeId)() end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- pcall(function() game:GetService("NetworkServer"):SetIsPlayerAuthenticationRequired(true) end)
|
||||||
settings().Diagnostics.LuaRamLimit = 0
|
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)
|
game:GetService("Players").PlayerAdded:connect(function(player)
|
||||||
keepAlive()
|
|
||||||
print("Player " .. player.userId .. " added")
|
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
|
|
||||||
|
|
||||||
for i,v in pairs(c:GetChildren()) do
|
|
||||||
print(v.Name)
|
|
||||||
end
|
|
||||||
|
|
||||||
print(c.Animate.Source)
|
|
||||||
end)
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
game:GetService("Players").PlayerRemoving:connect(function(player)
|
game:GetService("Players").PlayerRemoving:connect(function(player)
|
||||||
keepAlive(player)
|
|
||||||
print("Player " .. player.userId .. " leaving")
|
print("Player " .. player.userId .. " leaving")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if placeId~=nil and baseUrl~=nil then
|
if placeId ~= nil and baseUrl ~= nil then
|
||||||
wait()
|
wait()
|
||||||
game:Load(baseUrl .. "/thumbs/staticimage?r=" .. jobId)
|
game:Load(baseUrl .. "/asset/?id=" .. placeId)
|
||||||
end
|
end
|
||||||
|
|
||||||
------------------------------ RENEW GAME JOB SERVICE -------------------------------
|
|
||||||
|
|
||||||
spawn(function()
|
|
||||||
while true do
|
|
||||||
wait(30)
|
|
||||||
if #game.Players:GetPlayers() == 0 then
|
|
||||||
pcall(function() game:HttpGet(baseUrl .. "/arbiter/" .. jobId .. "/kill") end)
|
|
||||||
else
|
|
||||||
pcall(function() game:HttpGet(baseUrl .. "/arbiter/" .. jobId .. "/renew?s=360") end)
|
|
||||||
keepAlive()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
------------------------------END START GAME SHARED SCRIPT--------------------------
|
|
||||||
|
|
||||||
ns:Start(port)
|
ns:Start(port)
|
||||||
|
|
||||||
scriptContext:SetTimeout(10)
|
scriptContext:SetTimeout(10)
|
||||||
scriptContext.ScriptsDisabled = false
|
scriptContext.ScriptsDisabled = false
|
||||||
|
|
||||||
|
------------------------------END START GAME SHARED SCRIPT--------------------------
|
||||||
|
|
||||||
game:GetService("RunService"):Run()
|
game:GetService("RunService"):Run()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue