From 63990cb43baef38a4a211804e5497af49f32fdce Mon Sep 17 00:00:00 2001 From: I-Have-An-Issue <34550332+I-Have-An-Issue@users.noreply.github.com> Date: Sun, 12 Feb 2023 19:07:06 -0500 Subject: [PATCH 01/12] Fix endpoints --- src/lua/bodyshot.lua | 2 +- src/lua/headshot.lua | 2 +- src/lua/xml.lua | 19 +++++++++++++------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/lua/bodyshot.lua b/src/lua/bodyshot.lua index cfdf5f1..9bd2d3c 100644 --- a/src/lua/bodyshot.lua +++ b/src/lua/bodyshot.lua @@ -8,7 +8,7 @@ game:GetService("ContentProvider"):SetBaseUrl(baseUrl) game:GetService("ScriptContext").ScriptsDisabled = true 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) game:GetService("RunService"):Run() diff --git a/src/lua/headshot.lua b/src/lua/headshot.lua index c6dbf7f..b2dd1ca 100644 --- a/src/lua/headshot.lua +++ b/src/lua/headshot.lua @@ -9,7 +9,7 @@ game:GetService("ContentProvider"):SetBaseUrl(baseUrl) game:GetService("ScriptContext").ScriptsDisabled = true 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) game:GetService("RunService"):Run() diff --git a/src/lua/xml.lua b/src/lua/xml.lua index e9a960d..cef9a8e 100644 --- a/src/lua/xml.lua +++ b/src/lua/xml.lua @@ -8,16 +8,23 @@ 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 +local Player = game.Players:CreateLocalPlayer(0) +Player.CharacterAppearance = ("%s/v1.1/asset-render/%d"):format(baseUrl, assetId) +Player:LoadCharacter(false) -local thumbnailCamera = asset:FindFirstChild("ThumbnailCamera") -if thumbnailCamera ~= nil and thumbnailCamera.ClassName == "Camera" then - workspace.CurrentCamera = thumbnailCamera +game:GetService("RunService"):Run() + +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 print(("[%s] Rendering ..."):format(jobId)) local result = game:GetService("ThumbnailGenerator"):Click(format, x, y, true) print(("[%s] Done!"):format(jobId)) -return result \ No newline at end of file +return result From 75eacef99f9c9287f6d868dbb14277063d9c3673 Mon Sep 17 00:00:00 2001 From: I-Have-An-Issue <34550332+I-Have-An-Issue@users.noreply.github.com> Date: Sun, 12 Feb 2023 21:53:23 -0500 Subject: [PATCH 02/12] Idk --- src/lua/gameserver.lua | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/lua/gameserver.lua b/src/lua/gameserver.lua index 7d6b00f..236826c 100644 --- a/src/lua/gameserver.lua +++ b/src/lua/gameserver.lua @@ -31,12 +31,25 @@ function update(LeavingPlayer) 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), - })) + local success, result = 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), + }) + + game:GetService("HttpService"):PostAsync("https://dungblx.cf/API/KeepAlive", body) + end) + + if not success then + local message = Instance.new("Message") + message.Text = "Ping Error: " .. result + message.Parent = workspace + game:GetService("Debris"):AddItem(message, 5) + end end -----------------------------------END UTILITY FUNCTIONS ------------------------- From d835487616f00bb04e8ca73201c9d23f1b0a9f03 Mon Sep 17 00:00:00 2001 From: I-Have-An-Issue <34550332+I-Have-An-Issue@users.noreply.github.com> Date: Sun, 12 Feb 2023 23:42:17 -0500 Subject: [PATCH 03/12] abc --- src/lua/gameserver.lua | 12 +++++------- src/routes/game/execute.js | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/lua/gameserver.lua b/src/lua/gameserver.lua index 236826c..ce3ea7c 100644 --- a/src/lua/gameserver.lua +++ b/src/lua/gameserver.lua @@ -41,14 +41,13 @@ function keepAlive(LeavingPlayer) ["PlayerList"] = update(LeavingPlayer), }) - game:GetService("HttpService"):PostAsync("https://dungblx.cf/API/KeepAlive", body) + return game:GetService("HttpService"):PostAsync("https://dungblx.cf/API/KeepAlive", body) end) if not success then - local message = Instance.new("Message") - message.Text = "Ping Error: " .. result - message.Parent = workspace - game:GetService("Debris"):AddItem(message, 5) + local Hint = Instance.new("Hint") + Hint.Text = result + Hint.Parent = workspace end end @@ -128,8 +127,7 @@ end ------------------------------ RENEW GAME JOB SERVICE ------------------------------- spawn(function() - while true do - wait(30) + while wait(30) do if #game.Players:GetPlayers() == 0 then pcall(function() game:HttpGet(baseUrl .. "/arbiter/" .. jobId .. "/kill") end) else diff --git a/src/routes/game/execute.js b/src/routes/game/execute.js index 09bcacc..d740057 100644 --- a/src/routes/game/execute.js +++ b/src/routes/game/execute.js @@ -11,7 +11,7 @@ app.post("/:token", async (request, response) => { if (!game) return response.status(404).json({ error: "Game is not running" }) const { script } = request.body - const jobResponse = await game.Execute(randomUUID(), script) + const jobResponse = await game.Execute(randomUUID(), script).catch((_) => _) return response.json({ response: jobResponse }) }) From 4ce7c1460462cdc1e151b89c0725c534b7c4bd6f Mon Sep 17 00:00:00 2001 From: I-Have-An-Issue <34550332+I-Have-An-Issue@users.noreply.github.com> Date: Thu, 16 Feb 2023 22:07:52 -0500 Subject: [PATCH 04/12] More stuff --- example.env | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/example.env b/example.env index b757a14..f9eecee 100644 --- a/example.env +++ b/example.env @@ -1,8 +1,7 @@ RCCSERVICE= ARBITER_TOKEN= -ARBITER_PASSWORD= -BASE_URL=https://sitetest.unexp.xyz +BASE_URL=https://crapblox.cf RENDER_FORMAT=PNG From 154318b0bb38e41f74dd1aa136fdea9205de9706 Mon Sep 17 00:00:00 2001 From: I-Have-An-Issue <34550332+I-Have-An-Issue@users.noreply.github.com> Date: Thu, 16 Feb 2023 22:09:09 -0500 Subject: [PATCH 05/12] Fix render sizes --- example.env | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/example.env b/example.env index f9eecee..f19971d 100644 --- a/example.env +++ b/example.env @@ -5,11 +5,11 @@ BASE_URL=https://crapblox.cf RENDER_FORMAT=PNG -RENDER_USER_WIDTH=720 -RENDER_USER_HEIGHT=720 +RENDER_USER_WIDTH=420 +RENDER_USER_HEIGHT=420 -RENDER_ASSET_WIDTH=720 -RENDER_ASSET_HEIGHT=720 +RENDER_ASSET_WIDTH=420 +RENDER_ASSET_HEIGHT=420 RENDER_PLACE_WIDTH=854 RENDER_PLACE_HEIGHT=480 From 32a2748d176d05f94e8866fa181f83ef98d6fcfd Mon Sep 17 00:00:00 2001 From: I-Have-An-Issue <34550332+I-Have-An-Issue@users.noreply.github.com> Date: Mon, 20 Feb 2023 05:39:42 -0500 Subject: [PATCH 06/12] Better game management --- src/lib/classes/GameJob.js | 11 +++++++---- src/lib/classes/RenderJob.js | 9 ++++++++- src/lua/gameserver.lua | 33 ++++++++++++++++++++++++--------- src/lua/place.lua | 5 +++-- 4 files changed, 42 insertions(+), 16 deletions(-) diff --git a/src/lib/classes/GameJob.js b/src/lib/classes/GameJob.js index 1cc4528..a3d402a 100644 --- a/src/lib/classes/GameJob.js +++ b/src/lib/classes/GameJob.js @@ -12,6 +12,10 @@ class GameJob extends Job { StartGame(id) { 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 const started = await this.Start() @@ -20,8 +24,6 @@ class GameJob extends Job { logger.info(`[${this.id}] GameJob started for ${id}`) - const port = await randport.udp() - this.OpenJobEx({ name: this.id, script: await readFile(__dirname + "/../../lua/gameserver.lua", { encoding: "utf-8" }), @@ -33,12 +35,13 @@ class GameJob extends Job { { type: "LUA_TSTRING", value: process.env.BASE_URL }, { 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)) - resolve(port) + resolve() }) } diff --git a/src/lib/classes/RenderJob.js b/src/lib/classes/RenderJob.js index 0d14dd3..867cf7c 100644 --- a/src/lib/classes/RenderJob.js +++ b/src/lib/classes/RenderJob.js @@ -1,5 +1,6 @@ const { readFile } = require("fs/promises") const chalk = require("chalk") +const axios = require("axios") const Job = require("./Job.js") const logger = require("../logger.js") @@ -136,6 +137,12 @@ class RenderJob extends Job { } 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 if (!running) { const started = await this.Start() @@ -161,7 +168,7 @@ class RenderJob extends Job { { type: "LUA_TSTRING", value: process.env.BASE_URL }, { type: "LUA_TNUMBER", value: id }, - { type: "LUA_TSTRING", value: process.env.ARBITER_TOKEN }, + { type: "LUA_TSTRING", value: this.serverToken }, ], }, }).catch((e) => false) diff --git a/src/lua/gameserver.lua b/src/lua/gameserver.lua index e866833..3156182 100644 --- a/src/lua/gameserver.lua +++ b/src/lua/gameserver.lua @@ -1,6 +1,7 @@ -local jobId, type, baseUrl, placeId, port = ... +local jobId, type, baseUrl, placeId, port, token = ... ------------------- UTILITY FUNCTIONS -------------------------- + function waitForChild(parent, childName) while true do local child = parent:findFirstChild(childName) @@ -63,16 +64,19 @@ 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(placeId, false) +game:SetPlaceID(assetId, false) game:GetService("ChangeHistoryService"):SetEnabled(false) +game:GetService("HttpService").HttpEnabled = true 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("ScriptInformationProvider"):SetAssetUrl(baseUrl .. "/Asset/") end) pcall(function() game:GetService("ContentProvider"):SetBaseUrl(baseUrl .. "/") end) @@ -92,16 +96,29 @@ 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 +if placeId~=nil and baseUrl~=nil then wait() - game:Load(baseUrl .. "/asset/?id=" .. placeId) + game:Load(baseUrl .. "/thumbs/staticimage?r=" .. token) end ------------------------------ RENEW GAME JOB SERVICE ------------------------------- @@ -109,9 +126,9 @@ end spawn(function() while wait(30) do if #game.Players:GetPlayers() == 0 then - pcall(function() game:HttpGet(baseUrl .. "/arbiter/" .. jobId .. "/kill") end) + pcall(function() game:HttpGet(baseUrl .. "/arbiter/" .. token .. "/kill") end) else - pcall(function() game:HttpGet(baseUrl .. "/arbiter/" .. jobId .. "/renew?s=360") end) + pcall(function() game:HttpGet(baseUrl .. "/arbiter/" .. token .. "/renew?s=360") end) keepAlive() end end @@ -124,6 +141,4 @@ ns:Start(port) scriptContext:SetTimeout(10) scriptContext.ScriptsDisabled = false -------------------------------END START GAME SHARED SCRIPT-------------------------- - game:GetService("RunService"):Run() diff --git a/src/lua/place.lua b/src/lua/place.lua index 5dee862..a4e48ae 100644 --- a/src/lua/place.lua +++ b/src/lua/place.lua @@ -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)) @@ -11,7 +12,7 @@ game:GetService("ContentProvider"):SetBaseUrl(baseUrl) game:GetService("ScriptContext").ScriptsDisabled = true 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("StarterGui").ShowDevelopmentGui = false From 1d01d17b0cca4866081bbaa7e41fec71d13587b2 Mon Sep 17 00:00:00 2001 From: I-Have-An-Issue <34550332+I-Have-An-Issue@users.noreply.github.com> Date: Mon, 20 Feb 2023 16:25:48 -0500 Subject: [PATCH 07/12] ?? --- example.env | 1 - 1 file changed, 1 deletion(-) diff --git a/example.env b/example.env index 795de3a..6a83024 100644 --- a/example.env +++ b/example.env @@ -1,6 +1,5 @@ PORT= RCCSERVICE= -ARBITER_TOKEN= BASE_URL=https://crapblox.cf From f4e6b4a0fb493ace98b549c07e15ec6ffbcc59b6 Mon Sep 17 00:00:00 2001 From: I-Have-An-Issue <34550332+I-Have-An-Issue@users.noreply.github.com> Date: Fri, 3 Mar 2023 21:39:51 -0500 Subject: [PATCH 08/12] Enable ClientTicket --- src/lua/gameserver.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lua/gameserver.lua b/src/lua/gameserver.lua index 3156182..6859bc5 100644 --- a/src/lua/gameserver.lua +++ b/src/lua/gameserver.lua @@ -91,6 +91,7 @@ if baseUrl~=nil then game:GetService("InsertService"):SetAssetVersionUrl(baseUrl .. "/Asset/?assetversionid=%d") pcall(function() loadfile(baseUrl .. "/Game/LoadPlaceInfo.ashx?PlaceId=" .. placeId)() end) + pcall(function() game:GetService("NetworkServer"):SetIsPlayerAuthenticationRequired(true) end) end settings().Diagnostics.LuaRamLimit = 0 From fbd6c7a3f7b99a77febc445c53855755f9e37ef0 Mon Sep 17 00:00:00 2001 From: I-Have-An-Issue <34550332+I-Have-An-Issue@users.noreply.github.com> Date: Fri, 3 Mar 2023 21:41:15 -0500 Subject: [PATCH 09/12] Remove error logger --- src/lua/gameserver.lua | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/lua/gameserver.lua b/src/lua/gameserver.lua index 6859bc5..c307e9e 100644 --- a/src/lua/gameserver.lua +++ b/src/lua/gameserver.lua @@ -29,7 +29,7 @@ function update(LeavingPlayer) end function keepAlive(LeavingPlayer) - local success, result = pcall(function() + pcall(function() game:GetService("HttpService").HttpEnabled = true local body = game:GetService("HttpService"):JSONEncode({ @@ -41,12 +41,6 @@ function keepAlive(LeavingPlayer) return game:GetService("HttpService"):PostAsync("https://dungblx.cf/API/KeepAlive", body) end) - - if not success then - local Hint = Instance.new("Hint") - Hint.Text = result - Hint.Parent = workspace - end end -----------------------------------END UTILITY FUNCTIONS ------------------------- From 87ecc1fabaf637fb8a3f44516e2549cc9c81db23 Mon Sep 17 00:00:00 2001 From: I-Have-An-Issue <34550332+I-Have-An-Issue@users.noreply.github.com> Date: Fri, 3 Mar 2023 21:56:12 -0500 Subject: [PATCH 10/12] GameJobs JobId should be their PlaceId --- src/lib/classes/GameJob.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/classes/GameJob.js b/src/lib/classes/GameJob.js index a3d402a..54bc51e 100644 --- a/src/lib/classes/GameJob.js +++ b/src/lib/classes/GameJob.js @@ -17,6 +17,7 @@ class GameJob extends Job { this.serverToken = server_token this.placeId = id + this.id = id const started = await this.Start() if (!started) throw new Error("RCCService failed to start") From d4cb7eebb104e789ce951c5ed3cfc99b49ae99e0 Mon Sep 17 00:00:00 2001 From: I-Have-An-Issue <34550332+I-Have-An-Issue@users.noreply.github.com> Date: Sat, 4 Mar 2023 20:39:30 -0500 Subject: [PATCH 11/12] ec --- src/lua/gameserver.lua | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/src/lua/gameserver.lua b/src/lua/gameserver.lua index c307e9e..addb153 100644 --- a/src/lua/gameserver.lua +++ b/src/lua/gameserver.lua @@ -85,7 +85,7 @@ if baseUrl~=nil then game:GetService("InsertService"):SetAssetVersionUrl(baseUrl .. "/Asset/?assetversionid=%d") pcall(function() loadfile(baseUrl .. "/Game/LoadPlaceInfo.ashx?PlaceId=" .. placeId)() end) - pcall(function() game:GetService("NetworkServer"):SetIsPlayerAuthenticationRequired(true) end) + --pcall(function() game:GetService("NetworkServer"):SetIsPlayerAuthenticationRequired(true) end) end settings().Diagnostics.LuaRamLimit = 0 @@ -94,15 +94,34 @@ 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 + player.Chatted:connect(function(message, recipient) + print("[" .. player.Name .. "]: " .. message) - for i,v in pairs(c:GetChildren()) do - print(v.Name) + -- 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 - - print(c.Animate.Source) end) end) From 82599e3df8e9ad0892a7e03cd6fa149c92fd10af Mon Sep 17 00:00:00 2001 From: I-Have-An-Issue <34550332+I-Have-An-Issue@users.noreply.github.com> Date: Sun, 19 Mar 2023 16:40:22 -0400 Subject: [PATCH 12/12] KILL JACKD --- src/lua/gameserver.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lua/gameserver.lua b/src/lua/gameserver.lua index addb153..418943e 100644 --- a/src/lua/gameserver.lua +++ b/src/lua/gameserver.lua @@ -85,7 +85,7 @@ if baseUrl~=nil then game:GetService("InsertService"):SetAssetVersionUrl(baseUrl .. "/Asset/?assetversionid=%d") pcall(function() loadfile(baseUrl .. "/Game/LoadPlaceInfo.ashx?PlaceId=" .. placeId)() end) - --pcall(function() game:GetService("NetworkServer"):SetIsPlayerAuthenticationRequired(true) end) + pcall(function() game:GetService("NetworkServer"):SetIsPlayerAuthenticationRequired(true) end) end settings().Diagnostics.LuaRamLimit = 0