Port host script to Yuescript
This commit is contained in:
parent
73c8c3fc7f
commit
1e9af98175
|
|
@ -1,20 +1,11 @@
|
|||
print "[Mercury]: Loaded Host corescript"
|
||||
-- Start Game Script Arguments
|
||||
local placeId, sleeptime, access, url, killID, deathID, timeout, injectScriptAssetID, servicesUrl, libraryRegistrationScriptAssetID =
|
||||
...
|
||||
|
||||
-- StartGame --
|
||||
print("[Mercury]: Loaded Host corescript")
|
||||
local placeId, sleeptime, access, url, killID, deathID, timeout, injectScriptAssetID, servicesUrl, libraryRegistrationScriptAssetID
|
||||
pcall(function()
|
||||
game:GetService("ScriptContext"):AddStarterScript(injectScriptAssetID)
|
||||
return game:GetService("ScriptContext"):AddStarterScript(injectScriptAssetID)
|
||||
end)
|
||||
game:GetService("RunService"):Run()
|
||||
|
||||
-- REQUIRES: StartGanmeSharedArgs.txt
|
||||
-- REQUIRES: MonitorGameStatus.txt
|
||||
|
||||
------------------- UTILITY FUNCTIONS --------------------------
|
||||
|
||||
function waitForChild(parent, childName)
|
||||
local waitForChild
|
||||
waitForChild = function(parent, childName)
|
||||
while true do
|
||||
local child = parent:findFirstChild(childName)
|
||||
if child then
|
||||
|
|
@ -23,224 +14,146 @@ function waitForChild(parent, childName)
|
|||
parent.ChildAdded:wait()
|
||||
end
|
||||
end
|
||||
|
||||
-- returns the player object that killed this humanoid
|
||||
-- returns nil if the killer is no longer in the game
|
||||
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
|
||||
local getKillerOfHumanoidIfStillInGame
|
||||
getKillerOfHumanoidIfStillInGame = function(humanoid)
|
||||
local tag = humanoid:findFirstChild("creator")
|
||||
if tag then
|
||||
local killer = tag.Value
|
||||
if killer.Parent then -- killer still in game
|
||||
if killer.Parent then
|
||||
return killer
|
||||
end
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
-- send kill and death stats when a player dies
|
||||
function onDied(victim, humanoid)
|
||||
local onDied
|
||||
onDied = function(victim, humanoid)
|
||||
local killer = getKillerOfHumanoidIfStillInGame(humanoid)
|
||||
local victorId = 0
|
||||
if killer then
|
||||
victorId = killer.userId
|
||||
print("STAT: kill by " .. victorId .. " of " .. victim.userId)
|
||||
game:HttpGet(url .. "/Game/Knockouts.ashx?UserID=" .. victorId .. "&" .. access)
|
||||
print("STAT: kill by " .. tostring(victorId) .. " of " .. tostring(victim.userId))
|
||||
game:HttpGet(tostring(url) .. "/Game/Knockouts.ashx?UserID=" .. tostring(victorId) .. "&" .. tostring(access))
|
||||
end
|
||||
print("STAT: death of " .. victim.userId .. " by " .. victorId)
|
||||
game:HttpGet(url .. "/Game/Wipeouts.ashx?UserID=" .. victim.userId .. "&" .. access)
|
||||
print("STAT: death of " .. tostring(victim.userId) .. " by " .. tostring(victorId))
|
||||
return game:HttpGet(tostring(url) .. "/Game/Wipeouts.ashx?UserID=" .. tostring(victim.userId) .. "&" .. tostring(access))
|
||||
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.ExperimentalPhysicsEnabled = true
|
||||
settings().Network.WaitingForCharacterLogRate = 100
|
||||
pcall(function()
|
||||
settings().Diagnostics:LegacyScriptMode()
|
||||
return settings().Diagnostics:LegacyScriptMode()
|
||||
end)
|
||||
|
||||
-----------------------------------START GAME SHARED SCRIPT------------------------------
|
||||
|
||||
local url = "_BASE_URL"
|
||||
-- local assetId = placeId -- might be able to remove this now
|
||||
|
||||
local scriptContext = game:GetService "ScriptContext"
|
||||
url = "_BASE_URL"
|
||||
local scriptContext = game:GetService("ScriptContext")
|
||||
pcall(function()
|
||||
scriptContext:AddStarterScript(libraryRegistrationScriptAssetID)
|
||||
return scriptContext:AddStarterScript(libraryRegistrationScriptAssetID)
|
||||
end)
|
||||
scriptContext.ScriptsDisabled = true
|
||||
|
||||
-- game:SetPlaceID(nil, 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 .. "/Report/Games.ashx")
|
||||
local ns = game:GetService("NetworkServer")
|
||||
if (url ~= nil) then
|
||||
pcall(function()
|
||||
return game:GetService("Players"):SetAbuseReportUrl(tostring(url) .. "/Report/Games.ashx")
|
||||
end)
|
||||
pcall(function()
|
||||
game:GetService("ScriptInformationProvider"):SetAssetUrl(url .. "/Asset/")
|
||||
pcall(function()
|
||||
return game:GetService("ScriptInformationProvider"):SetAssetUrl(tostring(url) .. "/Asset/")
|
||||
end)
|
||||
pcall(function()
|
||||
game:GetService("ContentProvider"):SetBaseUrl(url .. "/")
|
||||
pcall(function()
|
||||
return game:GetService("ContentProvider"):SetBaseUrl(tostring(url) .. "/")
|
||||
end)
|
||||
-- pcall(function() game:GetService("Players"):SetChatFilterUrl(url .. "/Game/ChatFilter.ashx") end)
|
||||
|
||||
-- game:GetService("BadgeService"):SetPlaceId(placeId)
|
||||
if access ~= nil then
|
||||
game:GetService("BadgeService")
|
||||
:SetAwardBadgeUrl(url .. "/Game/Badge/AwardBadge.ashx?UserID=%d&BadgeID=%d&PlaceID=%d&" .. access)
|
||||
game:GetService("BadgeService")
|
||||
:SetHasBadgeUrl(url .. "/Game/Badge/HasBadge.ashx?UserID=%d&BadgeID=%d&" .. access)
|
||||
game:GetService("BadgeService")
|
||||
:SetIsBadgeDisabledUrl(url .. "/Game/Badge/IsBadgeDisabled.ashx?BadgeID=%d&PlaceID=%d&" .. access)
|
||||
|
||||
game:GetService("FriendService")
|
||||
:SetMakeFriendUrl(servicesUrl .. "/Friend/CreateFriend?firstUserId=%d&secondUserId=%d&" .. access)
|
||||
game:GetService("FriendService")
|
||||
:SetBreakFriendUrl(servicesUrl .. "/Friend/BreakFriend?firstUserId=%d&secondUserId=%d&" .. access)
|
||||
game:GetService("FriendService"):SetGetFriendsUrl(servicesUrl .. "/Friend/AreFriends?userId=%d&" .. access)
|
||||
if (access ~= nil) then
|
||||
do
|
||||
local _with_0 = game:GetService("BadgeService")
|
||||
_with_0:SetAwardBadgeUrl(tostring(url) .. "/Game/Badge/AwardBadge.ashx?UserID=%d&BadgeID=%d&PlaceID=%d&" .. tostring(access))
|
||||
_with_0:SetHasBadgeUrl(tostring(url) .. "/Game/Badge/HasBadge.ashx?UserID=%d&BadgeID=%d&" .. tostring(access))
|
||||
_with_0:SetIsBadgeDisabledUrl(tostring(url) .. "/Game/Badge/IsBadgeDisabled.ashx?BadgeID=%d&PlaceID=%d&" .. tostring(access))
|
||||
end
|
||||
do
|
||||
local _with_0 = game:GetService("FriendService")
|
||||
_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))
|
||||
_with_0:SetGetFriendsUrl(tostring(servicesUrl) .. "/Friend/AreFriends?userId=%d&" .. tostring(access))
|
||||
end
|
||||
end
|
||||
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)()
|
||||
game:GetService("BadgeService"):SetIsBadgeLegalUrl("")
|
||||
do
|
||||
local _with_0 = game:GetService("InsertService")
|
||||
_with_0:SetBaseSetsUrl(tostring(url) .. "/Game/Tools/InsertAsset.ashx?nsets=10&type=base")
|
||||
_with_0:SetUserSetsUrl(tostring(url) .. "/Game/Tools/InsertAsset.ashx?nsets=20&type=user&userid=%d")
|
||||
_with_0:SetCollectionUrl(tostring(url) .. "/Game/Tools/InsertAsset.ashx?sid=%d")
|
||||
_with_0:SetAssetUrl(tostring(url) .. "/Asset/?id=%d")
|
||||
_with_0:SetAssetVersionUrl(tostring(url) .. "/Asset/?assetversionid=%d")
|
||||
end
|
||||
pcall(function()
|
||||
return loadfile(tostring(url) .. "/Game/LoadPlaceInfo.ashx?PlaceId=" .. tostring(placeId))()
|
||||
end)
|
||||
|
||||
pcall(function()
|
||||
pcall(function()
|
||||
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
|
||||
|
||||
pcall(function()
|
||||
game:GetService("NetworkServer"):SetIsPlayerAuthenticationRequired(true)
|
||||
return 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
|
||||
|
||||
--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 (placeId ~= nil) and (killID ~= nil) and (deathID ~= nil) and (url ~= nil) then
|
||||
local createDeathMonitor
|
||||
createDeathMonitor = function(player)
|
||||
if player.Character then
|
||||
local humanoid = waitForChild(player.Character, "Humanoid")
|
||||
humanoid.Died:connect(function()
|
||||
onDied(player, humanoid)
|
||||
return humanoid.Died:connect(function()
|
||||
return onDied(player, humanoid)
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
-- listen to all Players' Characters
|
||||
game:GetService("Players").ChildAdded:connect(function(player)
|
||||
createDeathMonitor(player)
|
||||
player.Changed:connect(function(property)
|
||||
return player.Changed:connect(function(property)
|
||||
if property == "Character" then
|
||||
createDeathMonitor(player)
|
||||
return createDeathMonitor(player)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
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
|
||||
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:HttpGet(tostring(url) .. "/Game/ClientPresence.ashx?action=connect&" .. tostring(access) .. "&PlaceID=" .. tostring(placeId) .. "&UserID=" .. tostring(player.userId))
|
||||
return game:HttpGet(tostring(url) .. "/Game/PlaceVisit.ashx?UserID=" .. tostring(player.userId) .. "&AssociatedPlaceID=" .. tostring(placeId) .. "&" .. tostring(access))
|
||||
end
|
||||
end)
|
||||
|
||||
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
|
||||
game:HttpGet(
|
||||
url
|
||||
.. "/Game/ClientPresence.ashx?action=disconnect&"
|
||||
.. access
|
||||
.. "&PlaceID="
|
||||
.. placeId
|
||||
.. "&UserID="
|
||||
.. player.userId
|
||||
)
|
||||
return game:HttpGet(tostring(url) .. "/Game/ClientPresence.ashx?action=disconnect&" .. tostring(access) .. "&PlaceID=" .. tostring(placeId) .. "&UserID=" .. tostring(player.userId))
|
||||
end
|
||||
end)
|
||||
|
||||
if placeId ~= nil and url ~= nil then
|
||||
-- yield so that file load happens in the heartbeat thread
|
||||
if (placeId ~= nil) and (url ~= nil) then
|
||||
wait()
|
||||
|
||||
-- load the game
|
||||
game:Load(url .. "/asset/?id=" .. placeId)
|
||||
game:Load(tostring(url) .. "/asset/?id=" .. tostring(placeId))
|
||||
end
|
||||
|
||||
if _MAP_LOCATION_EXISTS then
|
||||
-- yield so that file load happens in the heartbeat thread
|
||||
wait()
|
||||
|
||||
-- load the game
|
||||
game:Load "_MAP_LOCATION"
|
||||
game:Load("_MAP_LOCATION")
|
||||
end
|
||||
|
||||
-- Now start the connection
|
||||
ns:Start(_SERVER_PORT, sleeptime)
|
||||
|
||||
game:GetService("Visit"):SetPing("_SERVER_PRESENCE_URL", 30)
|
||||
|
||||
if timeout then
|
||||
scriptContext:SetTimeout(timeout)
|
||||
end
|
||||
scriptContext.ScriptsDisabled = false
|
||||
|
||||
--delay(1, function()
|
||||
-- loadfile(url .. "/analytics/GamePerfMonitor.ashx")(game.JobId, placeId)
|
||||
--end)
|
||||
|
||||
local reset = ";mc"
|
||||
game.Players.PlayerAdded:connect(function(player)
|
||||
player.Chatted:connect(function(msg)
|
||||
return game.Players.PlayerAdded:connect(function(player)
|
||||
return player.Chatted:connect(function(msg)
|
||||
if msg == reset then
|
||||
if player.Character then
|
||||
player.Character.Humanoid.Health = 0
|
||||
|
|
@ -248,5 +161,3 @@ game.Players.PlayerAdded:connect(function(player)
|
|||
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