This commit is contained in:
parent
ae6f369986
commit
87a96a7595
|
|
@ -3,6 +3,7 @@ RCCSERVICE=
|
|||
BASE_URL=
|
||||
|
||||
RENDER_FORMAT=
|
||||
RENDER_BASE64=
|
||||
|
||||
RENDER_USER_WIDTH=
|
||||
RENDER_USER_HEIGHT=
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
The Bingle arbiter is designed to be used with almost any revival backend.
|
||||
|
||||
It comes preloaded with some Lua scripts made by kinery.
|
||||
It comes preloaded with some Lua scripts made by kinery and jackd900.
|
||||
|
||||
You **will** have to replace/modify these scripts when implementing for your own projects.
|
||||
|
||||
Set your desired settings in `.env.example`, then rename it to `.env`.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
"start": "node .",
|
||||
"dev": "nodemon ."
|
||||
"dev": "nodemon . --exec \"clear; npm run start\""
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
const Job = require("./Job.js")
|
||||
|
||||
class GameJob extends Job {
|
||||
constructor() {}
|
||||
constructor({ placeId }) {
|
||||
super()
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = GameJob
|
||||
|
|
|
|||
|
|
@ -100,6 +100,7 @@ class RenderJob extends Job {
|
|||
|
||||
{ type: "LUA_TSTRING", value: process.env.BASE_URL },
|
||||
{ type: "LUA_TNUMBER", value: id },
|
||||
{ type: "LUA_TBOOLEAN", value: "true" },
|
||||
],
|
||||
},
|
||||
}).catch((e) => false)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ game:GetService("ContentProvider"):SetBaseUrl(baseUrl)
|
|||
game:GetService("ScriptContext").ScriptsDisabled = true
|
||||
|
||||
local Player = game.Players:CreateLocalPlayer(0)
|
||||
Player.CharacterAppearance = ("%s/Users/%d/CharApp"):format(baseUrl, assetId)
|
||||
Player.CharacterAppearance = ("%s/v1.1/avatar-fetch/%d"):format(baseUrl, assetId)
|
||||
Player:LoadCharacter(false)
|
||||
|
||||
game:GetService("RunService"):Run()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,135 @@
|
|||
local jobId, type, baseUrl, placeId, port, owner = ...
|
||||
|
||||
------------------- 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
|
||||
|
||||
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(baseUrl .. "/API/KeepAlive", game:GetService("HttpService"):JSONEncode({
|
||||
["ServerIP"] = jobId,
|
||||
["PlaceId"] = game.PlaceId,
|
||||
["PlayerCount"] = #game:GetService("Players"):GetPlayers(),
|
||||
["PlayerList"] = update(LeavingPlayer),
|
||||
}))
|
||||
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.AccumulatedError end)
|
||||
|
||||
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
|
||||
|
||||
local scriptContext = game:GetService("ScriptContext")
|
||||
pcall(function() scriptContext:AddStarterScript(37801172) end)
|
||||
scriptContext.ScriptsDisabled = true
|
||||
|
||||
game:SetPlaceID(assetId, false)
|
||||
game:GetService("ChangeHistoryService"):SetEnabled(false)
|
||||
game:SetCreatorId(owner, Enum.CreatorType.User)
|
||||
game:GetService("HttpService").HttpEnabled = true
|
||||
|
||||
local ns = game:GetService("NetworkServer")
|
||||
|
||||
if baseUrl~=nil then
|
||||
pcall(function() game:GetService("Players"):SetAbuseReportUrl(baseUrl .. "/AbuseReport/InGameChatHandler.ashx") end)
|
||||
pcall(function() game:GetService("ScriptInformationProvider"):SetAssetUrl(baseUrl .. "/Asset/") end)
|
||||
pcall(function() game:GetService("ContentProvider"):SetBaseUrl(baseUrl .. "/") end)
|
||||
pcall(function() game:GetService("Players"):SetChatFilterUrl(baseUrl .. "/Game/ChatFilter.ashx") end)
|
||||
|
||||
game:GetService("BadgeService"):SetPlaceId(placeId)
|
||||
game:GetService("BadgeService"):SetIsBadgeLegalUrl("")
|
||||
game:GetService("InsertService"):SetBaseSetsUrl(baseUrl .. "/Game/Tools/InsertAsset.ashx?nsets=10&type=base")
|
||||
game:GetService("InsertService"):SetUserSetsUrl(baseUrl .. "/Game/Tools/InsertAsset.ashx?nsets=20&type=user&userid=%d")
|
||||
game:GetService("InsertService"):SetCollectionUrl(baseUrl .. "/Game/Tools/InsertAsset.ashx?sid=%d")
|
||||
game:GetService("InsertService"):SetAssetUrl(baseUrl .. "/Asset/?id=%d")
|
||||
game:GetService("InsertService"):SetAssetVersionUrl(baseUrl .. "/Asset/?assetversionid=%d")
|
||||
|
||||
pcall(function() loadfile(baseUrl .. "/Game/LoadPlaceInfo.ashx?PlaceId=" .. placeId)() end)
|
||||
end
|
||||
|
||||
settings().Diagnostics.LuaRamLimit = 0
|
||||
|
||||
game:GetService("Players").PlayerAdded:connect(function(player)
|
||||
keepAlive()
|
||||
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)
|
||||
|
||||
game:GetService("Players").PlayerRemoving:connect(function(player)
|
||||
keepAlive(player)
|
||||
print("Player " .. player.userId .. " leaving")
|
||||
end)
|
||||
|
||||
if placeId~=nil and baseUrl~=nil then
|
||||
wait()
|
||||
game:Load(baseUrl .. "/thumbs/staticimage?r=" .. jobId)
|
||||
end
|
||||
|
||||
------------------------------ RENEW GAME JOB SERVICE -------------------------------
|
||||
|
||||
coroutine.resume(coroutine.create((function()
|
||||
while wait(30) do
|
||||
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)
|
||||
|
||||
scriptContext:SetTimeout(10)
|
||||
scriptContext.ScriptsDisabled = false
|
||||
|
||||
game:GetService("RunService"):Run()
|
||||
|
|
@ -9,12 +9,12 @@ game:GetService("ContentProvider"):SetBaseUrl(baseUrl)
|
|||
game:GetService("ScriptContext").ScriptsDisabled = true
|
||||
|
||||
local Player = game.Players:CreateLocalPlayer(0)
|
||||
Player.CharacterAppearance = ("%s/Users/%d/CharApp"):format(baseUrl, assetId)
|
||||
Player.CharacterAppearance = ("%s/v1.1/avatar-fetch/%d"):format(baseUrl, assetId)
|
||||
Player:LoadCharacter(false)
|
||||
|
||||
game:GetService("RunService"):Run()
|
||||
|
||||
Player.Character.Animate.Disabled = true
|
||||
Player.Character.Animate.Disabled = true
|
||||
Player.Character.Torso.Anchored = true
|
||||
|
||||
-- Headshot Camera
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
local jobId, type, format, x, y, baseUrl, assetId = ...
|
||||
local jobId, type, format, x, y, baseUrl, assetId, mannequin = ...
|
||||
|
||||
print(("[%s] Started RenderJob for type '%s' with assetId %d ..."):format(jobId, type, assetId))
|
||||
|
||||
|
|
@ -8,12 +8,18 @@ game:GetService("InsertService"):SetAssetVersionUrl(baseUrl .. "/Asset/?assetver
|
|||
game:GetService("ContentProvider"):SetBaseUrl(baseUrl)
|
||||
game:GetService("ScriptContext").ScriptsDisabled = true
|
||||
|
||||
local asset = game:GetObjects(("%s/asset?id=%d"):format(baseUrl, assetId))[1]
|
||||
asset.Parent = workspace
|
||||
if mannequin then
|
||||
local Player = game.Players:CreateLocalPlayer(0)
|
||||
Player.CharacterAppearance = ("%s/v1.1/asset-render/%d"):format(baseUrl, assetId)
|
||||
Player:LoadCharacter(false)
|
||||
else
|
||||
local asset = game:GetObjects(("%s/Asset/?id=%d"):format(baseUrl, assetId))[1]
|
||||
asset.Parent = workspace
|
||||
|
||||
local thumbnailCamera = asset:FindFirstChild("ThumbnailCamera")
|
||||
if thumbnailCamera ~= nil and thumbnailCamera.ClassName == "Camera" then
|
||||
workspace.CurrentCamera = thumbnailCamera
|
||||
local thumbnailCamera = asset:FindFirstChild("ThumbnailCamera")
|
||||
if thumbnailCamera ~= nil and thumbnailCamera.ClassName == "Camera" then
|
||||
workspace.CurrentCamera = thumbnailCamera
|
||||
end
|
||||
end
|
||||
|
||||
print(("[%s] Rendering ..."):format(jobId))
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ const RenderJob = require("../../lib/classes/RenderJob.js")
|
|||
|
||||
app.get("/:id", async (request, response) => {
|
||||
const job = new RenderJob()
|
||||
const result = await job.RenderAsset(request.params.id).catch((_) => _)
|
||||
const result = await job.RenderAsset(request.params.id, process.env.RENDER_BASE64).catch((_) => _)
|
||||
|
||||
if (result?.message) return response.status(500).json({ error: result.message })
|
||||
else return response.end(result)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ const RenderJob = require("../../lib/classes/RenderJob.js")
|
|||
|
||||
app.get("/:id", async (request, response) => {
|
||||
const job = new RenderJob()
|
||||
const result = await job.RenderBodyshot(request.params.id).catch((_) => _)
|
||||
const result = await job.RenderBodyshot(request.params.id, process.env.RENDER_BASE64).catch((_) => _)
|
||||
|
||||
if (result?.message) return response.status(500).json({ error: result.message })
|
||||
else return response.end(result)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ const RenderJob = require("../../lib/classes/RenderJob.js")
|
|||
|
||||
app.get("/:id", async (request, response) => {
|
||||
const job = new RenderJob()
|
||||
const result = await job.RenderHeadshot(request.params.id).catch((_) => _)
|
||||
const result = await job.RenderHeadshot(request.params.id, process.env.RENDER_BASE64).catch((_) => _)
|
||||
|
||||
if (result?.message) return response.status(500).json({ error: result.message })
|
||||
else return response.end(result)
|
||||
|
|
|
|||
Loading…
Reference in New Issue