Update PlaceLauncher.php

This commit is contained in:
Mario 2023-02-27 00:12:26 +02:00 committed by GitHub
parent 935fee821f
commit 898114647c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 118 additions and 110 deletions

View File

@ -64,7 +64,7 @@ if ($momentoftruth == 1) {
];
echo json_encode($response);
} else if ($okcheck == 0) {
$passedplacelauncher = '1';
$passedplacelauncher = '0'; // IF THIS IS 0 THEN IT MEANS PLACELAUNCHER HASN'T PASSED MAKE SURE THIS IS ONLY IN UR TESTING
$hahatroll = $con->prepare('UPDATE tokens SET passedplacelauncher = :passedplacelauncher WHERE token=:token');
$hahatroll->bindParam(':passedplacelauncher', $passedplacelauncher);
$hahatroll->bindParam(':token', $token);
@ -84,6 +84,15 @@ if ($momentoftruth == 1) {
return $p1."-".$p2."-".$p3."-".$p4."-".$p5;
}
$jobid = generateRandomJobId();
function generateRandomString($length = 25) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[random_int(0, $charactersLength - 1)];
}
return $randomString;
}
$port = rand(5000,5999);
$checkport = $con->prepare('SELECT COUNT(*) FROM tokens WHERE token=:token AND passedplacelauncher=:passed');
$checkport->bindParam(':token', $token);
@ -94,117 +103,116 @@ if ($momentoftruth == 1) {
$port = rand(5000,5999); // great heavens if this ever happens report to me
die("How did we get here?");
} else if ($okbrahh == 0) {
$RCCServiceSoap = new Roblox\Grid\Rcc\RCCServiceSoap("127.0.0.1", 64989);
$script = '
------------------- UTILITY FUNCTIONS --------------------------
$accesstoken = generateRandomString(500);
echo $accesstoken;
$okaccesstoken = $con->prepare('INSERT INTO accesstokens (ip, accesstoken, placeid) VALUES (:ip, :accesstoken, :placeid)');
$okaccesstoken->bindParam(':ip', $AvailableGameservers[1]);
$okaccesstoken->bindParam(':accesstoken', $accesstoken);
$okaccesstoken->bindParam(':placeid', $placeid);
$okaccesstoken->execute();
$RCCServiceSoap = new Roblox\Grid\Rcc\RCCServiceSoap("192.168.1.129", 64989);
$https = "https://";
$script = 'print("Starting a new gameserver with JobID: " .. "' . $jobid . '" .. " and PlaceID: " .. "' . $placeid . '")
function waitForChild(parent, childName)
while true do
local child = parent:findFirstChild(childName)
if child then
return child
local placeId = ' . (int)$placeid . '
local url = "'. $https . $soapcfg['url'] . '"
local accesstoken = "' . $accesstoken . '"
------------------- 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
parent.ChildAdded:wait()
end
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.FIFO 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.ExperimentalPhysicsEnabled = true
settings().Network.WaitingForCharacterLogRate = 100
pcall(function() settings().Diagnostics:LegacyScriptMode() end)
-----------------------------------START GAME SHARED SCRIPT------------------------------
local assetId = '. $placeid .' -- might be able to remove this now
local scriptContext = game:GetService("ScriptContext")
pcall(function() scriptContext:AddStarterScript(37801172) end)
scriptContext.ScriptsDisabled = true
game:SetPlaceID(assetId, false)
game:GetService("ChangeHistoryService"):SetEnabled(false)
-- establish this peer as the Server
local ns = game:GetService("NetworkServer")
if url~=nil then
pcall(function() game:GetService("Players"):SetAbuseReportUrl(url .. "/AbuseReport/InGameChatHandler.ashx") end)
pcall(function() game:GetService("ScriptInformationProvider"):SetAssetUrl(url .. "/Asset/") end)
pcall(function() game:GetService("ContentProvider"):SetBaseUrl(url .. "/") end)
pcall(function() game:GetService("Players"):SetChatFilterUrl(url .. "/Game/ChatFilter.ashx") end)
game:GetService("BadgeService"):SetPlaceId("1818")
game:GetService("BadgeService"):SetIsBadgeLegalUrl("")
game:GetService("InsertService"):SetBaseSetsUrl(url .. "/Game/Tools/InsertAsset.ashx?nsets=10&type=base")
game:GetService("InsertService"):SetUserSetsUrl(url .. "/Game/Tools/InsertAsset.ashx?nsets=20&type=user&userid=%d")
game:GetService("InsertService"):SetCollectionUrl(url .. "/Game/Tools/InsertAsset.ashx?sid=%d")
game:GetService("InsertService"):SetAssetUrl(url .. "/Asset/?id=%d")
game:GetService("InsertService"):SetAssetVersionUrl(url .. "/Asset/?assetversionid=%d")
pcall(function() loadfile(url .. "/Game/LoadPlaceInfo.ashx?PlaceId=" .. placeId)() end)
-- pcall(function()
-- if access then
-- loadfile(url .. "/Game/PlaceSpecificScript.ashx?PlaceId=" .. placeId .. "&" .. access)()
-- end
-- end)
end
--pcall(function() game:GetService("NetworkServer"):SetIsPlayerAuthenticationRequired(true) end)
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)
print("Player " .. player.userId .. " added")
end)
game:GetService("Players").PlayerRemoving:connect(function(player)
print("Player " .. player.userId .. " leaving")
end)
if placeId~=nil and url~=nil then
-- yield so that file load happens in the heartbeat thread
wait()
-- load the game
game:Load(url .. "/asset/?id=" .. placeId)
end
-- Now start the connection
ns:Start('. $port .')
scriptContext:SetTimeout(10)
scriptContext.ScriptsDisabled = false
------------------------------END START GAME SHARED SCRIPT--------------------------
-- StartGame --
game:GetService("RunService"):Run()
';
$job = new Roblox\Grid\Rcc\Job($jobid, 9999999999); // pls only set to this amount WHEN ur hosting a gameserver when ur rendering do like 10 minutes
$funny = new Roblox\Grid\Rcc\ScriptExecution("Script", $script);
$result = $RCCServiceSoap->BatchJob($job, $funny);
-----------------------------------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.FIFO 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.ExperimentalPhysicsEnabled = true
settings().Network.WaitingForCharacterLogRate = 100
pcall(function() settings().Diagnostics:LegacyScriptMode() end)
-----------------------------------START GAME SHARED SCRIPT------------------------------
local assetId = placeId -- might be able to remove this now
local scriptContext = game:GetService("ScriptContext")
pcall(function() scriptContext:AddStarterScript(37801172) end)
scriptContext.ScriptsDisabled = true
game:SetPlaceID(assetId, false)
game:GetService("ChangeHistoryService"):SetEnabled(false)
-- establish this peer as the Server
local ns = game:GetService("NetworkServer")
if url~=nil then
pcall(function() game:GetService("Players"):SetAbuseReportUrl(url .. "/AbuseReport/InGameChatHandler.ashx") end)
pcall(function() game:GetService("ScriptInformationProvider"):SetAssetUrl(url .. "/Asset/") end)
pcall(function() game:GetService("ContentProvider"):SetBaseUrl(url .. "/") end)
--pcall(function() game:GetService("Players"):SetChatFilterUrl(url .. "/Game/ChatFilter.ashx") end)
game:GetService("BadgeService"):SetPlaceId(placeId)
game:GetService("BadgeService"):SetIsBadgeLegalUrl("")
game:GetService("InsertService"):SetBaseSetsUrl(url .. "/Game/Tools/InsertAsset.ashx?nsets=10&type=base")
game:GetService("InsertService"):SetUserSetsUrl(url .. "/Game/Tools/InsertAsset.ashx?nsets=20&type=user&userid=%d")
game:GetService("InsertService"):SetCollectionUrl(url .. "/Game/Tools/InsertAsset.ashx?sid=%d")
game:GetService("InsertService"):SetAssetUrl(url .. "/Asset/?id=%d")
game:GetService("InsertService"):SetAssetVersionUrl(url .. "/Asset/?assetversionid=%d")
pcall(function() loadfile(url .. "/Game/LoadPlaceInfo.ashx?PlaceId=" .. placeId)() end)
-- pcall(function()
-- if access then
-- loadfile(url .. "/Game/PlaceSpecificScript.ashx?PlaceId=" .. placeId .. "&" .. access)()
-- end
-- end)
end
pcall(function() game:GetService("NetworkServer"):SetIsPlayerAuthenticationRequired(true) end)
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)
// if game.Players.NumPlayers ~= 0 then
// print(game:HttpGet("'. $https . $soapcfg['url'] . '/api/UpdatePlayerCount?accesstoken=" .. accesstoken .. "&playercount=" .. game.Players.NumPlayers))
// print("Successfully Updated Player count for JobID: " . "' . $jobid . '")
// else
// print(game:HttpGet("'. $https . $soapcfg['url'] . '/api/CloseJob?accesstoken=" .. accesstoken))
// print("Job ID: " .. "' . $jobid . '" .. " is closing due to no active players.")
// end
print("Player " .. player.userId .. " added")
end)
game:GetService("Players").PlayerRemoving:connect(function(player)
// if game.Players.NumPlayers ~= 0 then
// print(game:HttpGet("'. $https . $soapcfg['url'] . '/api/UpdatePlayerCount?accesstoken=" .. accesstoken .. "&playercount=" .. game.Players.NumPlayers))
// print("Successfully Updated Player count for JobID: " . "' . $jobid . '")
// else
// print(game:HttpGet("'. $https . $soapcfg['url'] . '/api/CloseJob?accesstoken=" .. accesstoken))
// print("Job ID: " .. "' . $jobid . '" .. " is closing due to no active players.")
// end
print("Player " .. player.userId .. " leaving")
end)
if placeId~=nil and url~=nil then
-- yield so that file load happens in the heartbeat thread
wait()
-- load the game
game:Load(url .. "/asset/?id=" .. placeId .. "?accesstoken=" .. accesstoken)
end
-- Now start the connection
ns:Start(' . $port . ')
scriptContext:SetTimeout(10)
scriptContext.ScriptsDisabled = false
------------------------------END START GAME SHARED SCRIPT--------------------------
-- StartGame --
game:GetService("RunService"):Run()
';
$job = new Roblox\Grid\Rcc\Job($jobid, 99999999999); // pls only set to this amount WHEN ur hosting a gameserver when ur rendering do like 10 minutes
$funny = new Roblox\Grid\Rcc\ScriptExecution("Script".rand(1,getrandmax()), $script);
$result = $RCCServiceSoap->OpenJob($job, $funny);
$sendthatjob = $con->prepare('INSERT INTO jobs (jobid, placeid, port, ip) VALUES (:jobid, :placeid, :port, :ip)');
$sendthatjob->bindParam(':jobid', $jobid);
$sendthatjob->bindParam(':placeid', $placeid); // another temporary thing since we don't have random token generator thing and token table