Compare commits
23 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
5f716e8243 | |
|
|
82599e3df8 | |
|
|
d4cb7eebb1 | |
|
|
87ecc1faba | |
|
|
fbd6c7a3f7 | |
|
|
f4e6b4a0fb | |
|
|
1d01d17b0c | |
|
|
32a2748d17 | |
|
|
88135b551b | |
|
|
fa3025faab | |
|
|
ab761f5801 | |
|
|
bcf4b16da9 | |
|
|
9542096bc6 | |
|
|
6a2130f17e | |
|
|
154318b0bb | |
|
|
4ce7c14604 | |
|
|
5e897f89c9 | |
|
|
4d056e9f81 | |
|
|
d835487616 | |
|
|
4298f85632 | |
|
|
75eacef99f | |
|
|
3204aede8a | |
|
|
63990cb43b |
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2023 [fullname]
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
10
example.env
10
example.env
|
|
@ -1,16 +1,16 @@
|
||||||
PORT=
|
PORT=
|
||||||
RCCSERVICE=
|
RCCSERVICE=
|
||||||
|
|
||||||
BASE_URL=https://sitetest.unexp.xyz
|
BASE_URL=https://crapblox.cf
|
||||||
|
|
||||||
ARBITER_TOKEN=
|
ARBITER_TOKEN=
|
||||||
ARBITER_KEY=
|
ARBITER_KEY=
|
||||||
|
|
||||||
RENDER_USER_WIDTH=720
|
RENDER_USER_WIDTH=420
|
||||||
RENDER_USER_HEIGHT=720
|
RENDER_USER_HEIGHT=420
|
||||||
|
|
||||||
RENDER_ASSET_WIDTH=720
|
RENDER_ASSET_WIDTH=420
|
||||||
RENDER_ASSET_HEIGHT=720
|
RENDER_ASSET_HEIGHT=420
|
||||||
|
|
||||||
RENDER_PLACE_WIDTH=854
|
RENDER_PLACE_WIDTH=854
|
||||||
RENDER_PLACE_HEIGHT=480
|
RENDER_PLACE_HEIGHT=480
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,12 @@ class GameJob extends Job {
|
||||||
|
|
||||||
StartGame(id) {
|
StartGame(id) {
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
|
const response = await axios(`${process.env.BASE_URL}/API/Game/${id}?t=${process.env.ARBITER_TOKEN}`).catch((_) => reject(_))
|
||||||
|
const { server_token, server_port } = response.data
|
||||||
|
|
||||||
|
this.serverToken = server_token
|
||||||
this.placeId = id
|
this.placeId = id
|
||||||
|
this.id = id
|
||||||
|
|
||||||
const started = await this.Start()
|
const started = await this.Start()
|
||||||
if (!started) throw new Error("RCCService failed to start")
|
if (!started) throw new Error("RCCService failed to start")
|
||||||
|
|
@ -20,8 +25,6 @@ class GameJob extends Job {
|
||||||
|
|
||||||
logger.info(`[${this.id}] GameJob started for ${id}`)
|
logger.info(`[${this.id}] GameJob started for ${id}`)
|
||||||
|
|
||||||
const port = await randport.udp()
|
|
||||||
|
|
||||||
this.OpenJobEx({
|
this.OpenJobEx({
|
||||||
name: this.id,
|
name: this.id,
|
||||||
script: await readFile(__dirname + "/../../lua/gameserver.lua", { encoding: "utf-8" }),
|
script: await readFile(__dirname + "/../../lua/gameserver.lua", { encoding: "utf-8" }),
|
||||||
|
|
@ -33,12 +36,13 @@ class GameJob extends Job {
|
||||||
{ type: "LUA_TSTRING", value: process.env.BASE_URL },
|
{ type: "LUA_TSTRING", value: process.env.BASE_URL },
|
||||||
|
|
||||||
{ type: "LUA_TNUMBER", value: id },
|
{ type: "LUA_TNUMBER", value: id },
|
||||||
{ type: "LUA_TNUMBER", value: port },
|
{ type: "LUA_TNUMBER", value: server_port },
|
||||||
|
{ type: "LUA_TSTRING", value: this.serverToken },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
}).catch((e) => reject(e))
|
}).catch((e) => reject(e))
|
||||||
|
|
||||||
resolve(port)
|
resolve()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
const { readFile } = require("fs/promises")
|
const { readFile } = require("fs/promises")
|
||||||
const chalk = require("chalk")
|
const chalk = require("chalk")
|
||||||
|
const axios = require("axios")
|
||||||
|
|
||||||
const Job = require("./Job.js")
|
const Job = require("./Job.js")
|
||||||
const logger = require("../logger.js")
|
const logger = require("../logger.js")
|
||||||
|
|
@ -136,6 +137,12 @@ class RenderJob extends Job {
|
||||||
}
|
}
|
||||||
|
|
||||||
async RenderPlace(id) {
|
async RenderPlace(id) {
|
||||||
|
const response = await axios(`${process.env.BASE_URL}/API/Game/${id}?t=${process.env.ARBITER_TOKEN}`).catch((_) => reject(_))
|
||||||
|
const { server_token } = response.data
|
||||||
|
|
||||||
|
this.serverToken = server_token
|
||||||
|
console.log(`${process.env.BASE_URL}/API/Game/${id}?t=${process.env.ARBITER_TOKEN}`, server_token)
|
||||||
|
|
||||||
const running = this.started
|
const running = this.started
|
||||||
if (!running) {
|
if (!running) {
|
||||||
const started = await this.Start()
|
const started = await this.Start()
|
||||||
|
|
@ -161,7 +168,7 @@ class RenderJob extends Job {
|
||||||
|
|
||||||
{ type: "LUA_TSTRING", value: process.env.BASE_URL },
|
{ type: "LUA_TSTRING", value: process.env.BASE_URL },
|
||||||
{ type: "LUA_TNUMBER", value: id },
|
{ type: "LUA_TNUMBER", value: id },
|
||||||
{ type: "LUA_TSTRING", value: process.env.ARBITER_TOKEN },
|
{ type: "LUA_TSTRING", value: this.serverToken },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
}).catch((e) => false)
|
}).catch((e) => false)
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ game:GetService("ContentProvider"):SetBaseUrl(baseUrl)
|
||||||
game:GetService("ScriptContext").ScriptsDisabled = true
|
game:GetService("ScriptContext").ScriptsDisabled = true
|
||||||
|
|
||||||
local Player = game.Players:CreateLocalPlayer(0)
|
local Player = game.Players:CreateLocalPlayer(0)
|
||||||
Player.CharacterAppearance = ("%s/Character?id=%d"):format(baseUrl, assetId)
|
Player.CharacterAppearance = ("%s/v1.1/avatar-fetch/%d"):format(baseUrl, assetId)
|
||||||
Player:LoadCharacter(false)
|
Player:LoadCharacter(false)
|
||||||
|
|
||||||
game:GetService("RunService"):Run()
|
game:GetService("RunService"):Run()
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
local jobId, type, baseUrl, placeId, port = ...
|
local jobId, type, baseUrl, placeId, port, token = ...
|
||||||
|
|
||||||
------------------- 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)
|
||||||
|
|
@ -9,6 +10,39 @@ function waitForChild(parent, childName)
|
||||||
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)
|
||||||
|
pcall(function()
|
||||||
|
game:GetService("HttpService").HttpEnabled = true
|
||||||
|
|
||||||
|
local body = game:GetService("HttpService"):JSONEncode({
|
||||||
|
["ServerIP"] = jobId,
|
||||||
|
["PlaceId"] = game.PlaceId,
|
||||||
|
["PlayerCount"] = #game:GetService("Players"):GetPlayers(),
|
||||||
|
["PlayerList"] = update(LeavingPlayer),
|
||||||
|
})
|
||||||
|
|
||||||
|
return game:GetService("HttpService"):PostAsync("https://dungblx.cf/API/KeepAlive", body)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
-----------------------------------END UTILITY FUNCTIONS -------------------------
|
-----------------------------------END UTILITY FUNCTIONS -------------------------
|
||||||
|
|
||||||
-----------------------------------"CUSTOM" SHARED CODE----------------------------------
|
-----------------------------------"CUSTOM" SHARED CODE----------------------------------
|
||||||
|
|
@ -24,16 +58,19 @@ 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(placeId, false)
|
game:SetPlaceID(assetId, false)
|
||||||
game:GetService("ChangeHistoryService"):SetEnabled(false)
|
game:GetService("ChangeHistoryService"):SetEnabled(false)
|
||||||
|
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)
|
||||||
|
|
@ -48,28 +85,74 @@ if baseUrl ~= nil then
|
||||||
game:GetService("InsertService"):SetAssetVersionUrl(baseUrl .. "/Asset/?assetversionid=%d")
|
game:GetService("InsertService"):SetAssetVersionUrl(baseUrl .. "/Asset/?assetversionid=%d")
|
||||||
|
|
||||||
pcall(function() loadfile(baseUrl .. "/Game/LoadPlaceInfo.ashx?PlaceId=" .. placeId)() end)
|
pcall(function() loadfile(baseUrl .. "/Game/LoadPlaceInfo.ashx?PlaceId=" .. placeId)() end)
|
||||||
|
pcall(function() game:GetService("NetworkServer"):SetIsPlayerAuthenticationRequired(true) end)
|
||||||
end
|
end
|
||||||
|
|
||||||
settings().Diagnostics.LuaRamLimit = 0
|
settings().Diagnostics.LuaRamLimit = 0
|
||||||
|
|
||||||
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.Chatted:connect(function(message, recipient)
|
||||||
|
print("[" .. player.Name .. "]: " .. message)
|
||||||
|
|
||||||
|
-- 1 : needs semicolon
|
||||||
|
-- 2 : doesn't need semicolon
|
||||||
|
local commands = {
|
||||||
|
["ec"] = 1,
|
||||||
|
["energycell"] = 1,
|
||||||
|
["reset"] = 1,
|
||||||
|
["kys"] = 1,
|
||||||
|
["xlxi"] = 1,
|
||||||
|
["egg"] = 2,
|
||||||
|
["pog"] = 2,
|
||||||
|
["poggers"] = 2
|
||||||
|
}
|
||||||
|
|
||||||
|
if commands[message:sub(2):lower()] == 1 or commands[message:lower()] == 2 then
|
||||||
|
if player.Character then
|
||||||
|
local Head = player.Character:FindFirstChild("Head")
|
||||||
|
if Head then
|
||||||
|
local Sound = Instance.new("Sound", Head)
|
||||||
|
Sound.SoundId = "rbxassetid://53357"
|
||||||
|
Sound:Play()
|
||||||
|
end
|
||||||
|
|
||||||
|
player.Character:BreakJoints()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
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 .. "/asset/?id=" .. placeId)
|
game:Load(baseUrl .. "/thumbs/staticimage?r=" .. token)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
------------------------------ RENEW GAME JOB SERVICE -------------------------------
|
||||||
|
|
||||||
|
spawn(function()
|
||||||
|
while wait(30) do
|
||||||
|
if #game.Players:GetPlayers() == 0 then
|
||||||
|
pcall(function() game:HttpGet(baseUrl .. "/arbiter/" .. token .. "/kill") end)
|
||||||
|
else
|
||||||
|
pcall(function() game:HttpGet(baseUrl .. "/arbiter/" .. token .. "/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()
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ game:GetService("ContentProvider"):SetBaseUrl(baseUrl)
|
||||||
game:GetService("ScriptContext").ScriptsDisabled = true
|
game:GetService("ScriptContext").ScriptsDisabled = true
|
||||||
|
|
||||||
local Player = game.Players:CreateLocalPlayer(0)
|
local Player = game.Players:CreateLocalPlayer(0)
|
||||||
Player.CharacterAppearance = ("%s/Character?id=%d"):format(baseUrl, assetId)
|
Player.CharacterAppearance = ("%s/v1.1/avatar-fetch/%d"):format(baseUrl, assetId)
|
||||||
Player:LoadCharacter(false)
|
Player:LoadCharacter(false)
|
||||||
|
|
||||||
game:GetService("RunService"):Run()
|
game:GetService("RunService"):Run()
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
local jobId, type, format, x, y, baseUrl, assetId = ...
|
local jobId, type, format, x, y, baseUrl, assetId, token = ...
|
||||||
|
print(token)
|
||||||
|
|
||||||
print(("[%s] Started RenderJob for type '%s' with assetId %d ..."):format(jobId, type, assetId))
|
print(("[%s] Started RenderJob for type '%s' with assetId %d ..."):format(jobId, type, assetId))
|
||||||
|
|
||||||
|
|
@ -11,7 +12,7 @@ game:GetService("ContentProvider"):SetBaseUrl(baseUrl)
|
||||||
game:GetService("ScriptContext").ScriptsDisabled = true
|
game:GetService("ScriptContext").ScriptsDisabled = true
|
||||||
game:GetService("StarterGui").ShowDevelopmentGui = false
|
game:GetService("StarterGui").ShowDevelopmentGui = false
|
||||||
|
|
||||||
game:Load(("%s/asset/?id=%d"):format(baseUrl, assetId))
|
game:Load(("%s/thumbs/staticimage?r=%s"):format(baseUrl, token))
|
||||||
|
|
||||||
game:GetService("ScriptContext").ScriptsDisabled = true
|
game:GetService("ScriptContext").ScriptsDisabled = true
|
||||||
game:GetService("StarterGui").ShowDevelopmentGui = false
|
game:GetService("StarterGui").ShowDevelopmentGui = false
|
||||||
|
|
|
||||||
|
|
@ -8,16 +8,23 @@ game:GetService("InsertService"):SetAssetVersionUrl(baseUrl .. "/Asset/?assetver
|
||||||
game:GetService("ContentProvider"):SetBaseUrl(baseUrl)
|
game:GetService("ContentProvider"):SetBaseUrl(baseUrl)
|
||||||
game:GetService("ScriptContext").ScriptsDisabled = true
|
game:GetService("ScriptContext").ScriptsDisabled = true
|
||||||
|
|
||||||
local asset = game:GetObjects(("%s/asset/?id=%d"):format(baseUrl, assetId))[1]
|
local Player = game.Players:CreateLocalPlayer(0)
|
||||||
asset.Parent = workspace
|
Player.CharacterAppearance = ("%s/v1.1/asset-render/%d"):format(baseUrl, assetId)
|
||||||
|
Player:LoadCharacter(false)
|
||||||
|
|
||||||
local thumbnailCamera = asset:FindFirstChild("ThumbnailCamera")
|
game:GetService("RunService"):Run()
|
||||||
if thumbnailCamera ~= nil and thumbnailCamera.ClassName == "Camera" then
|
|
||||||
workspace.CurrentCamera = thumbnailCamera
|
Player.Character.Animate.Disabled = true
|
||||||
|
Player.Character.Torso.Anchored = true
|
||||||
|
|
||||||
|
local gear = Player.Backpack:GetChildren()[1]
|
||||||
|
if gear then
|
||||||
|
gear.Parent = Player.Character
|
||||||
|
Player.Character.Torso["Right Shoulder"].CurrentAngle = math.rad(90)
|
||||||
end
|
end
|
||||||
|
|
||||||
print(("[%s] Rendering ..."):format(jobId))
|
print(("[%s] Rendering ..."):format(jobId))
|
||||||
local result = game:GetService("ThumbnailGenerator"):Click(format, x, y, true)
|
local result = game:GetService("ThumbnailGenerator"):Click(format, x, y, true)
|
||||||
print(("[%s] Done!"):format(jobId))
|
print(("[%s] Done!"):format(jobId))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ app.post("/:id", async (request, response) => {
|
||||||
if (!game) return response.status(404).json({ error: "Game is not running" })
|
if (!game) return response.status(404).json({ error: "Game is not running" })
|
||||||
|
|
||||||
const { script } = request.body
|
const { script } = request.body
|
||||||
const jobResponse = await game.Execute(randomUUID(), script)
|
const jobResponse = await game.Execute(randomUUID(), script).catch((_) => _)
|
||||||
|
|
||||||
return response.json({ response: jobResponse })
|
return response.json({ response: jobResponse })
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue