Compare commits

..

23 Commits

Author SHA1 Message Date
cirroskais 5f716e8243 Add LICENSE 2023-11-19 15:38:10 -05:00
I-Have-An-Issue 82599e3df8
KILL JACKD 2023-03-19 16:40:22 -04:00
I-Have-An-Issue d4cb7eebb1
ec 2023-03-04 20:39:30 -05:00
I-Have-An-Issue 87ecc1faba
GameJobs JobId should be their PlaceId 2023-03-03 21:56:12 -05:00
I-Have-An-Issue fbd6c7a3f7
Remove error logger 2023-03-03 21:41:15 -05:00
I-Have-An-Issue f4e6b4a0fb
Enable ClientTicket 2023-03-03 21:39:51 -05:00
I-Have-An-Issue 1d01d17b0c
?? 2023-02-20 16:25:48 -05:00
I-Have-An-Issue 32a2748d17
Better game management 2023-02-20 05:39:42 -05:00
I-Have-An-Issue 88135b551b
W 2023-02-20 05:17:27 -05:00
I-Have-An-Issue fa3025faab
Merge branch 'master' into crapblox 2023-02-17 23:45:23 -05:00
I-Have-An-Issue ab761f5801
Merge branch 'master' into crapblox 2023-02-17 21:13:16 -05:00
I-Have-An-Issue bcf4b16da9
Rotate job ids on job 2023-02-17 21:13:08 -05:00
I-Have-An-Issue 9542096bc6
Merge branch 'master' into crapblox 2023-02-17 21:05:56 -05:00
I-Have-An-Issue 6a2130f17e
Merge branch 'master' into crapblox 2023-02-17 20:55:54 -05:00
I-Have-An-Issue 154318b0bb
Fix render sizes 2023-02-16 22:09:09 -05:00
I-Have-An-Issue 4ce7c14604
More stuff 2023-02-16 22:07:52 -05:00
I-Have-An-Issue 5e897f89c9
Merge branch 'master' into crapblox 2023-02-16 22:00:16 -05:00
I-Have-An-Issue 4d056e9f81
Merge branch 'master' into crapblox 2023-02-13 20:16:56 -05:00
I-Have-An-Issue d835487616
abc 2023-02-12 23:42:17 -05:00
I-Have-An-Issue 4298f85632
Merge branch 'master' into crapblox 2023-02-12 22:26:48 -05:00
I-Have-An-Issue 75eacef99f
Idk 2023-02-12 21:53:23 -05:00
I-Have-An-Issue 3204aede8a
Merge branch 'master' into crapblox 2023-02-12 20:28:03 -05:00
I-Have-An-Issue 63990cb43b
Fix endpoints 2023-02-12 19:07:06 -05:00
10 changed files with 130 additions and 29 deletions

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2023 cirroskais
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

View File

@ -1,16 +1,16 @@
PORT=
RCCSERVICE=
BASE_URL=https://sitetest.unexp.xyz
BASE_URL=https://crapblox.cf
ARBITER_TOKEN=
ARBITER_KEY=
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

View File

@ -12,7 +12,12 @@ 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
this.id = id
const started = await this.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}`)
const port = await randport.udp()
this.OpenJobEx({
name: this.id,
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_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()
})
}

View File

@ -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)

View File

@ -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()

View File

@ -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)
@ -9,6 +10,39 @@ function waitForChild(parent, childName)
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 -------------------------
-----------------------------------"CUSTOM" SHARED CODE----------------------------------
@ -24,16 +58,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)
@ -54,23 +91,68 @@ end
settings().Diagnostics.LuaRamLimit = 0
game:GetService("Players").PlayerAdded:connect(function(player)
keepAlive()
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)
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 -------------------------------
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)
scriptContext:SetTimeout(10)
scriptContext.ScriptsDisabled = false
------------------------------END START GAME SHARED SCRIPT--------------------------
game:GetService("RunService"):Run()

View File

@ -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()

View File

@ -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

View File

@ -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
return result

View File

@ -11,7 +11,7 @@ app.post("/:id", 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 })
})