Multiple servers per game.

This commit is contained in:
Graphictoria 2022-11-29 17:21:50 -05:00
parent 6ecb5441c9
commit a4e16ef24b
3 changed files with 14 additions and 2 deletions

View File

@ -122,7 +122,7 @@ if ($requesttype == "RequestGame") //start new server or join existing one
if (Game::UserAccess($gameID, $user->id))
{
$ispbs = false;//(bool)$gInfo->isPersonalServer;
$ispbs = (bool)$gInfo->isPersonalServer;
//check for open servers
$query = "SELECT * FROM open_servers WHERE gameID = :i AND (status = 0 OR status = 1) ORDER BY status DESC LIMIT 1";

View File

@ -33,6 +33,12 @@ else
//doesnt have any return data, so we set message to true
$jobClose = new RccServiceHelper($GLOBALS['gamesArbiter']);
$jobClose->CloseJob($jobid);
$q = $pdo->prepare("UPDATE open_servers SET status = 0 WHERE gameID = :pid AND jobid = :jid AND status = 1");
$q->bindParam(":pid", $placeid, PDO::PARAM_INT);
$q->bindParam(":jid", $jobid, PDO::PARAM_STR);
$q->execute();
$message = true;
}

View File

@ -178,4 +178,10 @@ game:GetService("RunService"):Run()
game:HttpGet(baseurl .. "/Game/RegisterServer?jobId=" .. game.JobId)
-- Remove server OnClose --
game.OnClose = function() sendKillJobSignal() end -- register game as closed when datamodel shutdowns
game:GetService('Players').PlayerAdded:wait()
while wait(1) do
if(game:GetService('Players').NumPlayers == 0) then
sendKillJobSignal()
end
end
--game.OnClose = function() sendKillJobSignal() end -- register game as closed when datamodel shutdowns