Port host script to Yuescript
This commit is contained in:
parent
73c8c3fc7f
commit
1e9af98175
|
|
@ -1,20 +1,11 @@
|
||||||
print "[Mercury]: Loaded Host corescript"
|
print("[Mercury]: Loaded Host corescript")
|
||||||
-- Start Game Script Arguments
|
local placeId, sleeptime, access, url, killID, deathID, timeout, injectScriptAssetID, servicesUrl, libraryRegistrationScriptAssetID
|
||||||
local placeId, sleeptime, access, url, killID, deathID, timeout, injectScriptAssetID, servicesUrl, libraryRegistrationScriptAssetID =
|
|
||||||
...
|
|
||||||
|
|
||||||
-- StartGame --
|
|
||||||
pcall(function()
|
pcall(function()
|
||||||
game:GetService("ScriptContext"):AddStarterScript(injectScriptAssetID)
|
return game:GetService("ScriptContext"):AddStarterScript(injectScriptAssetID)
|
||||||
end)
|
end)
|
||||||
game:GetService("RunService"):Run()
|
game:GetService("RunService"):Run()
|
||||||
|
local waitForChild
|
||||||
-- REQUIRES: StartGanmeSharedArgs.txt
|
waitForChild = function(parent, childName)
|
||||||
-- REQUIRES: MonitorGameStatus.txt
|
|
||||||
|
|
||||||
------------------- UTILITY FUNCTIONS --------------------------
|
|
||||||
|
|
||||||
function waitForChild(parent, childName)
|
|
||||||
while true do
|
while true do
|
||||||
local child = parent:findFirstChild(childName)
|
local child = parent:findFirstChild(childName)
|
||||||
if child then
|
if child then
|
||||||
|
|
@ -23,224 +14,146 @@ function waitForChild(parent, childName)
|
||||||
parent.ChildAdded:wait()
|
parent.ChildAdded:wait()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
local getKillerOfHumanoidIfStillInGame
|
||||||
-- returns the player object that killed this humanoid
|
getKillerOfHumanoidIfStillInGame = function(humanoid)
|
||||||
-- returns nil if the killer is no longer in the game
|
local tag = humanoid:findFirstChild("creator")
|
||||||
function getKillerOfHumanoidIfStillInGame(humanoid)
|
|
||||||
-- check for kill tag on humanoid - may be more than one - todo: deal with this
|
|
||||||
local tag = humanoid:findFirstChild "creator"
|
|
||||||
|
|
||||||
-- find player with name on tag
|
|
||||||
if tag then
|
if tag then
|
||||||
local killer = tag.Value
|
local killer = tag.Value
|
||||||
if killer.Parent then -- killer still in game
|
if killer.Parent then
|
||||||
return killer
|
return killer
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
|
||||||
end
|
end
|
||||||
|
local onDied
|
||||||
-- send kill and death stats when a player dies
|
onDied = function(victim, humanoid)
|
||||||
function onDied(victim, humanoid)
|
|
||||||
local killer = getKillerOfHumanoidIfStillInGame(humanoid)
|
local killer = getKillerOfHumanoidIfStillInGame(humanoid)
|
||||||
local victorId = 0
|
local victorId = 0
|
||||||
if killer then
|
if killer then
|
||||||
victorId = killer.userId
|
victorId = killer.userId
|
||||||
print("STAT: kill by " .. victorId .. " of " .. victim.userId)
|
print("STAT: kill by " .. tostring(victorId) .. " of " .. tostring(victim.userId))
|
||||||
game:HttpGet(url .. "/Game/Knockouts.ashx?UserID=" .. victorId .. "&" .. access)
|
game:HttpGet(tostring(url) .. "/Game/Knockouts.ashx?UserID=" .. tostring(victorId) .. "&" .. tostring(access))
|
||||||
end
|
end
|
||||||
print("STAT: death of " .. victim.userId .. " by " .. victorId)
|
print("STAT: death of " .. tostring(victim.userId) .. " by " .. tostring(victorId))
|
||||||
game:HttpGet(url .. "/Game/Wipeouts.ashx?UserID=" .. victim.userId .. "&" .. access)
|
return game:HttpGet(tostring(url) .. "/Game/Wipeouts.ashx?UserID=" .. tostring(victim.userId) .. "&" .. tostring(access))
|
||||||
end
|
end
|
||||||
|
|
||||||
-----------------------------------END UTILITY FUNCTIONS -------------------------
|
|
||||||
|
|
||||||
-----------------------------------"CUSTOM" SHARED CODE----------------------------------
|
|
||||||
|
|
||||||
pcall(function()
|
pcall(function()
|
||||||
settings().Network.UseInstancePacketCache = true
|
settings().Network.UseInstancePacketCache = true
|
||||||
end)
|
end)
|
||||||
pcall(function()
|
pcall(function()
|
||||||
settings().Network.UsePhysicsPacketCache = true
|
settings().Network.UsePhysicsPacketCache = true
|
||||||
end)
|
end)
|
||||||
--pcall(function() settings()["Task Scheduler"].PriorityMethod = Enum.PriorityMethod.FIFO end)
|
|
||||||
pcall(function()
|
pcall(function()
|
||||||
settings()["Task Scheduler"].PriorityMethod = Enum.PriorityMethod.AccumulatedError
|
settings()["Task Scheduler"].PriorityMethod = Enum.PriorityMethod.AccumulatedError
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--settings().Network.PhysicsSend = 1 -- 1==RoundRobin
|
|
||||||
settings().Network.PhysicsSend = Enum.PhysicsSendMethod.ErrorComputation2
|
settings().Network.PhysicsSend = Enum.PhysicsSendMethod.ErrorComputation2
|
||||||
settings().Network.ExperimentalPhysicsEnabled = true
|
settings().Network.ExperimentalPhysicsEnabled = true
|
||||||
settings().Network.WaitingForCharacterLogRate = 100
|
settings().Network.WaitingForCharacterLogRate = 100
|
||||||
pcall(function()
|
pcall(function()
|
||||||
settings().Diagnostics:LegacyScriptMode()
|
return settings().Diagnostics:LegacyScriptMode()
|
||||||
end)
|
end)
|
||||||
|
url = "_BASE_URL"
|
||||||
-----------------------------------START GAME SHARED SCRIPT------------------------------
|
local scriptContext = game:GetService("ScriptContext")
|
||||||
|
|
||||||
local url = "_BASE_URL"
|
|
||||||
-- local assetId = placeId -- might be able to remove this now
|
|
||||||
|
|
||||||
local scriptContext = game:GetService "ScriptContext"
|
|
||||||
pcall(function()
|
pcall(function()
|
||||||
scriptContext:AddStarterScript(libraryRegistrationScriptAssetID)
|
return scriptContext:AddStarterScript(libraryRegistrationScriptAssetID)
|
||||||
end)
|
end)
|
||||||
scriptContext.ScriptsDisabled = true
|
scriptContext.ScriptsDisabled = true
|
||||||
|
|
||||||
-- game:SetPlaceID(nil, false)
|
|
||||||
game:GetService("ChangeHistoryService"):SetEnabled(false)
|
game:GetService("ChangeHistoryService"):SetEnabled(false)
|
||||||
|
local ns = game:GetService("NetworkServer")
|
||||||
-- establish this peer as the Server
|
if (url ~= nil) then
|
||||||
local ns = game:GetService "NetworkServer"
|
pcall(function()
|
||||||
|
return game:GetService("Players"):SetAbuseReportUrl(tostring(url) .. "/Report/Games.ashx")
|
||||||
if url ~= nil then
|
|
||||||
pcall(function()
|
|
||||||
game:GetService("Players"):SetAbuseReportUrl(url .. "/Report/Games.ashx")
|
|
||||||
end)
|
end)
|
||||||
pcall(function()
|
pcall(function()
|
||||||
game:GetService("ScriptInformationProvider"):SetAssetUrl(url .. "/Asset/")
|
return game:GetService("ScriptInformationProvider"):SetAssetUrl(tostring(url) .. "/Asset/")
|
||||||
end)
|
end)
|
||||||
pcall(function()
|
pcall(function()
|
||||||
game:GetService("ContentProvider"):SetBaseUrl(url .. "/")
|
return game:GetService("ContentProvider"):SetBaseUrl(tostring(url) .. "/")
|
||||||
end)
|
end)
|
||||||
-- pcall(function() game:GetService("Players"):SetChatFilterUrl(url .. "/Game/ChatFilter.ashx") end)
|
if (access ~= nil) then
|
||||||
|
do
|
||||||
-- game:GetService("BadgeService"):SetPlaceId(placeId)
|
local _with_0 = game:GetService("BadgeService")
|
||||||
if access ~= nil then
|
_with_0:SetAwardBadgeUrl(tostring(url) .. "/Game/Badge/AwardBadge.ashx?UserID=%d&BadgeID=%d&PlaceID=%d&" .. tostring(access))
|
||||||
game:GetService("BadgeService")
|
_with_0:SetHasBadgeUrl(tostring(url) .. "/Game/Badge/HasBadge.ashx?UserID=%d&BadgeID=%d&" .. tostring(access))
|
||||||
:SetAwardBadgeUrl(url .. "/Game/Badge/AwardBadge.ashx?UserID=%d&BadgeID=%d&PlaceID=%d&" .. access)
|
_with_0:SetIsBadgeDisabledUrl(tostring(url) .. "/Game/Badge/IsBadgeDisabled.ashx?BadgeID=%d&PlaceID=%d&" .. tostring(access))
|
||||||
game:GetService("BadgeService")
|
end
|
||||||
:SetHasBadgeUrl(url .. "/Game/Badge/HasBadge.ashx?UserID=%d&BadgeID=%d&" .. access)
|
do
|
||||||
game:GetService("BadgeService")
|
local _with_0 = game:GetService("FriendService")
|
||||||
:SetIsBadgeDisabledUrl(url .. "/Game/Badge/IsBadgeDisabled.ashx?BadgeID=%d&PlaceID=%d&" .. access)
|
_with_0:SetMakeFriendUrl(tostring(servicesUrl) .. "/Friend/CreateFriend?firstUserId=%d&secondUserId=%d&" .. tostring(access))
|
||||||
|
_with_0:SetBreakFriendUrl(tostring(servicesUrl) .. "/Friend/BreakFriend?firstUserId=%d&secondUserId=%d&" .. tostring(access))
|
||||||
game:GetService("FriendService")
|
_with_0:SetGetFriendsUrl(tostring(servicesUrl) .. "/Friend/AreFriends?userId=%d&" .. tostring(access))
|
||||||
:SetMakeFriendUrl(servicesUrl .. "/Friend/CreateFriend?firstUserId=%d&secondUserId=%d&" .. access)
|
end
|
||||||
game:GetService("FriendService")
|
|
||||||
:SetBreakFriendUrl(servicesUrl .. "/Friend/BreakFriend?firstUserId=%d&secondUserId=%d&" .. access)
|
|
||||||
game:GetService("FriendService"):SetGetFriendsUrl(servicesUrl .. "/Friend/AreFriends?userId=%d&" .. access)
|
|
||||||
end
|
end
|
||||||
game:GetService("BadgeService"):SetIsBadgeLegalUrl ""
|
game:GetService("BadgeService"):SetIsBadgeLegalUrl("")
|
||||||
game:GetService("InsertService"):SetBaseSetsUrl(url .. "/Game/Tools/InsertAsset.ashx?nsets=10&type=base")
|
do
|
||||||
game:GetService("InsertService"):SetUserSetsUrl(url .. "/Game/Tools/InsertAsset.ashx?nsets=20&type=user&userid=%d")
|
local _with_0 = game:GetService("InsertService")
|
||||||
game:GetService("InsertService"):SetCollectionUrl(url .. "/Game/Tools/InsertAsset.ashx?sid=%d")
|
_with_0:SetBaseSetsUrl(tostring(url) .. "/Game/Tools/InsertAsset.ashx?nsets=10&type=base")
|
||||||
game:GetService("InsertService"):SetAssetUrl(url .. "/Asset/?id=%d")
|
_with_0:SetUserSetsUrl(tostring(url) .. "/Game/Tools/InsertAsset.ashx?nsets=20&type=user&userid=%d")
|
||||||
game:GetService("InsertService"):SetAssetVersionUrl(url .. "/Asset/?assetversionid=%d")
|
_with_0:SetCollectionUrl(tostring(url) .. "/Game/Tools/InsertAsset.ashx?sid=%d")
|
||||||
|
_with_0:SetAssetUrl(tostring(url) .. "/Asset/?id=%d")
|
||||||
pcall(function()
|
_with_0:SetAssetVersionUrl(tostring(url) .. "/Asset/?assetversionid=%d")
|
||||||
loadfile(url .. "/Game/LoadPlaceInfo.ashx?PlaceId=" .. placeId)()
|
end
|
||||||
|
pcall(function()
|
||||||
|
return loadfile(tostring(url) .. "/Game/LoadPlaceInfo.ashx?PlaceId=" .. tostring(placeId))()
|
||||||
end)
|
end)
|
||||||
|
pcall(function()
|
||||||
pcall(function()
|
|
||||||
if access then
|
if access then
|
||||||
loadfile(url .. "/Game/PlaceSpecificScript.ashx?PlaceId=" .. placeId .. "&" .. access)()
|
return loadfile(tostring(url) .. "/Game/PlaceSpecificScript.ashx?PlaceId=" .. tostring(placeId) .. "&" .. tostring(access))()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
pcall(function()
|
pcall(function()
|
||||||
game:GetService("NetworkServer"):SetIsPlayerAuthenticationRequired(true)
|
return game:GetService("NetworkServer"):SetIsPlayerAuthenticationRequired(true)
|
||||||
end)
|
end)
|
||||||
settings().Diagnostics.LuaRamLimit = 0
|
settings().Diagnostics.LuaRamLimit = 0
|
||||||
--settings().Network:SetThroughputSensitivity(0.08, 0.01)
|
if (placeId ~= nil) and (killID ~= nil) and (deathID ~= nil) and (url ~= nil) then
|
||||||
--settings().Network.SendRate = 35
|
local createDeathMonitor
|
||||||
--settings().Network.PhysicsSend = 0 -- 1==RoundRobin
|
createDeathMonitor = function(player)
|
||||||
|
|
||||||
--shared["__time"] = 0
|
|
||||||
--game:GetService("RunService").Stepped:connect(function (time) shared["__time"] = time end)
|
|
||||||
|
|
||||||
if placeId ~= nil and killID ~= nil and deathID ~= nil and url ~= nil then
|
|
||||||
-- listen for the death of a Player
|
|
||||||
function createDeathMonitor(player)
|
|
||||||
-- we don't need to clean up old monitors or connections since the Character will be destroyed soon
|
|
||||||
if player.Character then
|
if player.Character then
|
||||||
local humanoid = waitForChild(player.Character, "Humanoid")
|
local humanoid = waitForChild(player.Character, "Humanoid")
|
||||||
humanoid.Died:connect(function()
|
return humanoid.Died:connect(function()
|
||||||
onDied(player, humanoid)
|
return onDied(player, humanoid)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- listen to all Players' Characters
|
|
||||||
game:GetService("Players").ChildAdded:connect(function(player)
|
game:GetService("Players").ChildAdded:connect(function(player)
|
||||||
createDeathMonitor(player)
|
createDeathMonitor(player)
|
||||||
player.Changed:connect(function(property)
|
return player.Changed:connect(function(property)
|
||||||
if property == "Character" then
|
if property == "Character" then
|
||||||
createDeathMonitor(player)
|
return createDeathMonitor(player)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
game:GetService("Players").PlayerAdded:connect(function(player)
|
game:GetService("Players").PlayerAdded:connect(function(player)
|
||||||
print("Player " .. player.userId .. " added")
|
print("Player " .. tostring(player.userId) .. " added")
|
||||||
|
|
||||||
if url and access and placeId and player and player.userId then
|
if url and access and placeId and player and player.userId then
|
||||||
game:HttpGet(
|
game:HttpGet(tostring(url) .. "/Game/ClientPresence.ashx?action=connect&" .. tostring(access) .. "&PlaceID=" .. tostring(placeId) .. "&UserID=" .. tostring(player.userId))
|
||||||
url
|
return game:HttpGet(tostring(url) .. "/Game/PlaceVisit.ashx?UserID=" .. tostring(player.userId) .. "&AssociatedPlaceID=" .. tostring(placeId) .. "&" .. tostring(access))
|
||||||
.. "/Game/ClientPresence.ashx?action=connect&"
|
|
||||||
.. access
|
|
||||||
.. "&PlaceID="
|
|
||||||
.. placeId
|
|
||||||
.. "&UserID="
|
|
||||||
.. player.userId
|
|
||||||
)
|
|
||||||
game:HttpGet(
|
|
||||||
url .. "/Game/PlaceVisit.ashx?UserID=" .. player.userId .. "&AssociatedPlaceID=" .. placeId .. "&" .. access
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
game:GetService("Players").PlayerRemoving:connect(function(player)
|
game:GetService("Players").PlayerRemoving:connect(function(player)
|
||||||
print("Player " .. player.userId .. " leaving")
|
print("Player " .. tostring(player.userId) .. " leaving")
|
||||||
|
|
||||||
if url and access and placeId and player and player.userId then
|
if url and access and placeId and player and player.userId then
|
||||||
game:HttpGet(
|
return game:HttpGet(tostring(url) .. "/Game/ClientPresence.ashx?action=disconnect&" .. tostring(access) .. "&PlaceID=" .. tostring(placeId) .. "&UserID=" .. tostring(player.userId))
|
||||||
url
|
|
||||||
.. "/Game/ClientPresence.ashx?action=disconnect&"
|
|
||||||
.. access
|
|
||||||
.. "&PlaceID="
|
|
||||||
.. placeId
|
|
||||||
.. "&UserID="
|
|
||||||
.. player.userId
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
if (placeId ~= nil) and (url ~= nil) then
|
||||||
if placeId ~= nil and url ~= nil then
|
|
||||||
-- yield so that file load happens in the heartbeat thread
|
|
||||||
wait()
|
wait()
|
||||||
|
game:Load(tostring(url) .. "/asset/?id=" .. tostring(placeId))
|
||||||
-- load the game
|
|
||||||
game:Load(url .. "/asset/?id=" .. placeId)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if _MAP_LOCATION_EXISTS then
|
if _MAP_LOCATION_EXISTS then
|
||||||
-- yield so that file load happens in the heartbeat thread
|
|
||||||
wait()
|
wait()
|
||||||
|
game:Load("_MAP_LOCATION")
|
||||||
-- load the game
|
|
||||||
game:Load "_MAP_LOCATION"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Now start the connection
|
|
||||||
ns:Start(_SERVER_PORT, sleeptime)
|
ns:Start(_SERVER_PORT, sleeptime)
|
||||||
|
|
||||||
game:GetService("Visit"):SetPing("_SERVER_PRESENCE_URL", 30)
|
game:GetService("Visit"):SetPing("_SERVER_PRESENCE_URL", 30)
|
||||||
|
|
||||||
if timeout then
|
if timeout then
|
||||||
scriptContext:SetTimeout(timeout)
|
scriptContext:SetTimeout(timeout)
|
||||||
end
|
end
|
||||||
scriptContext.ScriptsDisabled = false
|
scriptContext.ScriptsDisabled = false
|
||||||
|
|
||||||
--delay(1, function()
|
|
||||||
-- loadfile(url .. "/analytics/GamePerfMonitor.ashx")(game.JobId, placeId)
|
|
||||||
--end)
|
|
||||||
|
|
||||||
local reset = ";mc"
|
local reset = ";mc"
|
||||||
game.Players.PlayerAdded:connect(function(player)
|
return game.Players.PlayerAdded:connect(function(player)
|
||||||
player.Chatted:connect(function(msg)
|
return player.Chatted:connect(function(msg)
|
||||||
if msg == reset then
|
if msg == reset then
|
||||||
if player.Character then
|
if player.Character then
|
||||||
player.Character.Humanoid.Health = 0
|
player.Character.Humanoid.Health = 0
|
||||||
|
|
@ -248,5 +161,3 @@ game.Players.PlayerAdded:connect(function(player)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
------------------------------END START GAME SHARED SCRIPT--------------------------
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,223 @@
|
||||||
|
print "[Mercury]: Loaded Host corescript"
|
||||||
|
-- Start Game Script Arguments
|
||||||
|
local placeId, sleeptime, access, url, killID, deathID, timeout, injectScriptAssetID, servicesUrl, libraryRegistrationScriptAssetID
|
||||||
|
|
||||||
|
-- StartGame --
|
||||||
|
try
|
||||||
|
game\GetService"ScriptContext"\AddStarterScript injectScriptAssetID
|
||||||
|
|
||||||
|
game\GetService"RunService"\Run!
|
||||||
|
|
||||||
|
-- REQUIRES: StartGanmeSharedArgs.txt
|
||||||
|
-- REQUIRES: MonitorGameStatus.txt
|
||||||
|
|
||||||
|
------------------- UTILITY FUNCTIONS --------------------------
|
||||||
|
|
||||||
|
waitForChild = (parent, childName) ->
|
||||||
|
while true
|
||||||
|
child = parent\findFirstChild childName
|
||||||
|
if child
|
||||||
|
return child
|
||||||
|
|
||||||
|
parent.ChildAdded\wait!
|
||||||
|
|
||||||
|
|
||||||
|
-- returns the player object that killed this humanoid
|
||||||
|
-- returns nil if the killer is no longer in the game
|
||||||
|
getKillerOfHumanoidIfStillInGame = (humanoid) ->
|
||||||
|
-- check for kill tag on humanoid - may be more than one - todo: deal with this
|
||||||
|
tag = humanoid\findFirstChild "creator"
|
||||||
|
|
||||||
|
-- find player with name on tag
|
||||||
|
if tag
|
||||||
|
killer = tag.Value
|
||||||
|
if killer.Parent -- killer still in game
|
||||||
|
return killer
|
||||||
|
|
||||||
|
|
||||||
|
-- send kill and death stats when a player dies
|
||||||
|
onDied = (victim, humanoid) ->
|
||||||
|
killer = getKillerOfHumanoidIfStillInGame humanoid
|
||||||
|
victorId = 0
|
||||||
|
if killer
|
||||||
|
victorId = killer.userId
|
||||||
|
print "STAT: kill by #{victorId} of #{victim.userId}"
|
||||||
|
game\HttpGet "#{url}/Game/Knockouts.ashx?UserID=#{victorId}&#{access}"
|
||||||
|
|
||||||
|
print "STAT: death of #{victim.userId} by #{victorId}"
|
||||||
|
game\HttpGet "#{url}/Game/Wipeouts.ashx?UserID=#{victim.userId}&#{access}"
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------END UTILITY FUNCTIONS -------------------------
|
||||||
|
|
||||||
|
-----------------------------------"CUSTOM" SHARED CODE----------------------------------
|
||||||
|
|
||||||
|
try
|
||||||
|
settings!.Network.UseInstancePacketCache = true
|
||||||
|
|
||||||
|
try
|
||||||
|
settings!.Network.UsePhysicsPacketCache = true
|
||||||
|
|
||||||
|
--try settings!["Task Scheduler"].PriorityMethod = Enum.PriorityMethod.FIFO end)
|
||||||
|
try
|
||||||
|
settings!["Task Scheduler"].PriorityMethod = Enum.PriorityMethod.AccumulatedError
|
||||||
|
|
||||||
|
|
||||||
|
--settings!.Network.PhysicsSend = 1 -- 1==RoundRobin
|
||||||
|
settings!.Network.PhysicsSend = Enum.PhysicsSendMethod.ErrorComputation2
|
||||||
|
settings!.Network.ExperimentalPhysicsEnabled = true
|
||||||
|
settings!.Network.WaitingForCharacterLogRate = 100
|
||||||
|
try
|
||||||
|
settings!.Diagnostics\LegacyScriptMode!
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------START GAME SHARED SCRIPT------------------------------
|
||||||
|
|
||||||
|
url = "_BASE_URL"
|
||||||
|
-- assetId = placeId -- might be able to remove this now
|
||||||
|
|
||||||
|
scriptContext = game\GetService "ScriptContext"
|
||||||
|
try
|
||||||
|
scriptContext\AddStarterScript libraryRegistrationScriptAssetID
|
||||||
|
|
||||||
|
scriptContext.ScriptsDisabled = true
|
||||||
|
|
||||||
|
-- game\SetPlaceID(nil, false)
|
||||||
|
game\GetService"ChangeHistoryService"\SetEnabled false
|
||||||
|
|
||||||
|
-- establish this peer as the Server
|
||||||
|
ns = game\GetService "NetworkServer"
|
||||||
|
|
||||||
|
if url?
|
||||||
|
try
|
||||||
|
game\GetService"Players"\SetAbuseReportUrl "#{url}/Report/Games.ashx"
|
||||||
|
|
||||||
|
try
|
||||||
|
game\GetService"ScriptInformationProvider"\SetAssetUrl "#{url}/Asset/"
|
||||||
|
|
||||||
|
try
|
||||||
|
game\GetService"ContentProvider"\SetBaseUrl "#{url}/"
|
||||||
|
|
||||||
|
-- try
|
||||||
|
-- game\GetService"Players"\SetChatFilterUrl(url .. "/Game/ChatFilter.ashx")
|
||||||
|
|
||||||
|
-- game\GetService"BadgeService"\SetPlaceId(placeId)
|
||||||
|
if access?
|
||||||
|
with game\GetService "BadgeService"
|
||||||
|
\SetAwardBadgeUrl "#{url}/Game/Badge/AwardBadge.ashx?UserID=%d&BadgeID=%d&PlaceID=%d&#{access}"
|
||||||
|
\SetHasBadgeUrl "#{url}/Game/Badge/HasBadge.ashx?UserID=%d&BadgeID=%d&#{access}"
|
||||||
|
\SetIsBadgeDisabledUrl "#{url}/Game/Badge/IsBadgeDisabled.ashx?BadgeID=%d&PlaceID=%d&#{access}"
|
||||||
|
|
||||||
|
with game\GetService "FriendService"
|
||||||
|
\SetMakeFriendUrl "#{servicesUrl}/Friend/CreateFriend?firstUserId=%d&secondUserId=%d&#{access}"
|
||||||
|
\SetBreakFriendUrl "#{servicesUrl}/Friend/BreakFriend?firstUserId=%d&secondUserId=%d&#{access}"
|
||||||
|
\SetGetFriendsUrl "#{servicesUrl}/Friend/AreFriends?userId=%d&#{access}"
|
||||||
|
|
||||||
|
game\GetService"BadgeService"\SetIsBadgeLegalUrl ""
|
||||||
|
|
||||||
|
with game\GetService "InsertService"
|
||||||
|
\SetBaseSetsUrl "#{url}/Game/Tools/InsertAsset.ashx?nsets=10&type=base"
|
||||||
|
\SetUserSetsUrl "#{url}/Game/Tools/InsertAsset.ashx?nsets=20&type=user&userid=%d"
|
||||||
|
\SetCollectionUrl "#{url}/Game/Tools/InsertAsset.ashx?sid=%d"
|
||||||
|
\SetAssetUrl "#{url}/Asset/?id=%d"
|
||||||
|
\SetAssetVersionUrl "#{url}/Asset/?assetversionid=%d"
|
||||||
|
|
||||||
|
try
|
||||||
|
loadfile"#{url}/Game/LoadPlaceInfo.ashx?PlaceId=#{placeId}"!
|
||||||
|
|
||||||
|
try
|
||||||
|
if access
|
||||||
|
loadfile"#{url}/Game/PlaceSpecificScript.ashx?PlaceId=#{placeId}&#{access}"!
|
||||||
|
|
||||||
|
|
||||||
|
try
|
||||||
|
game\GetService"NetworkServer"\SetIsPlayerAuthenticationRequired true
|
||||||
|
|
||||||
|
settings!.Diagnostics.LuaRamLimit = 0
|
||||||
|
--settings!.Network\SetThroughputSensitivity(0.08, 0.01)
|
||||||
|
--settings!.Network.SendRate = 35
|
||||||
|
--settings!.Network.PhysicsSend = 0 -- 1==RoundRobin
|
||||||
|
|
||||||
|
--shared["__time"] = 0
|
||||||
|
--game\GetService"RunService".Stepped\connect(function (time) shared["__time"] = time end)
|
||||||
|
|
||||||
|
if placeId? and killID? and deathID? and url?
|
||||||
|
-- listen for the death of a Player
|
||||||
|
createDeathMonitor = (player) ->
|
||||||
|
-- we don't need to clean up old monitors or connections since the Character will be destroyed soon
|
||||||
|
if player.Character
|
||||||
|
humanoid = waitForChild player.Character, "Humanoid"
|
||||||
|
humanoid.Died\connect ->
|
||||||
|
onDied player, humanoid
|
||||||
|
|
||||||
|
|
||||||
|
-- listen to all Players' Characters
|
||||||
|
game\GetService"Players".ChildAdded\connect (player) ->
|
||||||
|
createDeathMonitor player
|
||||||
|
player.Changed\connect (property) ->
|
||||||
|
if property == "Character"
|
||||||
|
createDeathMonitor player
|
||||||
|
|
||||||
|
|
||||||
|
game\GetService"Players".PlayerAdded\connect (player) ->
|
||||||
|
print "Player #{player.userId} added"
|
||||||
|
|
||||||
|
if url and access and placeId and player and player.userId
|
||||||
|
game\HttpGet(
|
||||||
|
"#{url}/Game/ClientPresence.ashx?action=connect&#{access}" ..
|
||||||
|
"&PlaceID=#{placeId}" ..
|
||||||
|
"&UserID=#{player.userId}"
|
||||||
|
)
|
||||||
|
game\HttpGet "#{url}/Game/PlaceVisit.ashx?UserID=#{player.userId}&AssociatedPlaceID=#{placeId}&#{access}"
|
||||||
|
|
||||||
|
|
||||||
|
game\GetService"Players".PlayerRemoving\connect (player) ->
|
||||||
|
print "Player #{player.userId} leaving"
|
||||||
|
|
||||||
|
if url and access and placeId and player and player.userId
|
||||||
|
game\HttpGet(
|
||||||
|
"#{url}/Game/ClientPresence.ashx?action=disconnect&" ..
|
||||||
|
"#{access}&PlaceID=#{placeId}"..
|
||||||
|
"&UserID=#{player.userId}"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
if placeId? and url?
|
||||||
|
-- yield so that file load happens in the heartbeat thread
|
||||||
|
wait!
|
||||||
|
|
||||||
|
-- load the game
|
||||||
|
game\Load "#{url}/asset/?id=#{placeId}"
|
||||||
|
|
||||||
|
|
||||||
|
if _MAP_LOCATION_EXISTS
|
||||||
|
-- yield so that file load happens in the heartbeat thread
|
||||||
|
wait!
|
||||||
|
|
||||||
|
-- load the game
|
||||||
|
game\Load "_MAP_LOCATION"
|
||||||
|
|
||||||
|
|
||||||
|
-- Now start the connection
|
||||||
|
ns\Start _SERVER_PORT, sleeptime
|
||||||
|
|
||||||
|
game\GetService"Visit"\SetPing "_SERVER_PRESENCE_URL", 30
|
||||||
|
|
||||||
|
if timeout
|
||||||
|
scriptContext\SetTimeout timeout
|
||||||
|
|
||||||
|
scriptContext.ScriptsDisabled = false
|
||||||
|
|
||||||
|
--delay(1, function!
|
||||||
|
-- loadfile(url .. "/analytics/GamePerfMonitor.ashx")(game.JobId, placeId)
|
||||||
|
--end)
|
||||||
|
|
||||||
|
reset = ";mc"
|
||||||
|
game.Players.PlayerAdded\connect (player) ->
|
||||||
|
player.Chatted\connect (msg) ->
|
||||||
|
if msg == reset
|
||||||
|
if player.Character
|
||||||
|
player.Character.Humanoid.Health = 0
|
||||||
|
|
||||||
|
|
||||||
|
------------------------------END START GAME SHARED SCRIPT--------------------------
|
||||||
Loading…
Reference in New Issue