Port join corescript to Yuescript
This commit is contained in:
parent
1e9af98175
commit
e704d69398
|
|
@ -1,18 +1,8 @@
|
||||||
-- functions --------------------------
|
|
||||||
function onPlayerAdded(player)
|
|
||||||
-- override
|
|
||||||
end
|
|
||||||
|
|
||||||
-- MultiplayerSharedScript.lua inserted here ------ Prepended to Join.lua --
|
-- MultiplayerSharedScript.lua inserted here ------ Prepended to Join.lua --
|
||||||
|
|
||||||
pcall(function()
|
pcall(function()
|
||||||
game:SetPlaceID(_PLACE_ID, false)
|
return game:SetPlaceID(_PLACE_ID, false)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- if we are on a touch device, no blocking http calls allowed! This can cause a crash on iOS
|
|
||||||
-- In general we need a long term strategy to remove blocking http calls from all platforms
|
|
||||||
local isTouchDevice = Game:GetService("UserInputService").TouchEnabled
|
local isTouchDevice = Game:GetService("UserInputService").TouchEnabled
|
||||||
|
|
||||||
settings()["Game Options"].CollisionSoundEnabled = true
|
settings()["Game Options"].CollisionSoundEnabled = true
|
||||||
pcall(function()
|
pcall(function()
|
||||||
settings().Rendering.EnableFRM = true
|
settings().Rendering.EnableFRM = true
|
||||||
|
|
@ -26,273 +16,225 @@ end)
|
||||||
pcall(function()
|
pcall(function()
|
||||||
settings().Physics.PhysicsEnvironmentalThrottle = Enum.EnviromentalPhysicsThrottle.DefaultAuto
|
settings().Physics.PhysicsEnvironmentalThrottle = Enum.EnviromentalPhysicsThrottle.DefaultAuto
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- arguments ---------------------------------------
|
|
||||||
local threadSleepTime = ...
|
local threadSleepTime = ...
|
||||||
|
|
||||||
if threadSleepTime == nil then
|
if threadSleepTime == nil then
|
||||||
threadSleepTime = 15
|
threadSleepTime = 15
|
||||||
end
|
end
|
||||||
|
|
||||||
local test = _IS_STUDIO_JOIN
|
local test = _IS_STUDIO_JOIN
|
||||||
|
print("! Joining game '_PLACE_ID' place _PLACE_ID at _SERVER_ADDRESS")
|
||||||
print "! Joining game '_PLACE_ID' place _PLACE_ID at _SERVER_ADDRESS"
|
|
||||||
|
|
||||||
game:GetService("ChangeHistoryService"):SetEnabled(false)
|
game:GetService("ChangeHistoryService"):SetEnabled(false)
|
||||||
game:GetService("ContentProvider"):SetThreadPool(16)
|
game:GetService("ContentProvider"):SetThreadPool(16)
|
||||||
game:GetService("InsertService"):SetBaseSetsUrl "http://www.roblox.com/Game/Tools/InsertAsset.ashx?nsets=10&type=base"
|
do
|
||||||
game:GetService("InsertService")
|
local _with_0 = game:GetService("InsertService")
|
||||||
:SetUserSetsUrl "http://www.roblox.com/Game/Tools/InsertAsset.ashx?nsets=20&type=user&userid=%d"
|
_with_0:SetBaseSetsUrl("http://www.roblox.com/Game/Tools/InsertAsset.ashx?nsets=10&type=base")
|
||||||
game:GetService("InsertService"):SetCollectionUrl "http://www.roblox.com/Game/Tools/InsertAsset.ashx?sid=%d"
|
_with_0:SetUserSetsUrl("http://www.roblox.com/Game/Tools/InsertAsset.ashx?nsets=20&type=user&userid=%d")
|
||||||
game:GetService("InsertService"):SetAssetUrl "http://banland.xyz/Asset/?id=%d"
|
_with_0:SetCollectionUrl("http://www.roblox.com/Game/Tools/InsertAsset.ashx?sid=%d")
|
||||||
game:GetService("InsertService"):SetAssetVersionUrl "http://www.roblox.com/Asset/?assetversionid=%d"
|
_with_0:SetAssetUrl("http://banland.xyz/Asset/?id=%d")
|
||||||
|
_with_0:SetAssetVersionUrl("http://www.roblox.com/Asset/?assetversionid=%d")
|
||||||
|
end
|
||||||
|
do
|
||||||
|
local _with_0 = game:GetService("SocialService")
|
||||||
pcall(function()
|
pcall(function()
|
||||||
game:GetService("SocialService")
|
return _with_0:SetFriendUrl("http://banland.xyz/Game/LuaWebService/HandleSocialRequest.ashx?method=IsFriendsWith&playerid=%d&userid=%d")
|
||||||
:SetFriendUrl "http://banland.xyz/Game/LuaWebService/HandleSocialRequest.ashx?method=IsFriendsWith&playerid=%d&userid=%d"
|
end)
|
||||||
|
pcall(function()
|
||||||
|
return _with_0:SetBestFriendUrl("http://banland.xyz/Game/LuaWebService/HandleSocialRequest.ashx?method=IsBestFriendsWith&playerid=%d&userid=%d")
|
||||||
|
end)
|
||||||
|
pcall(function()
|
||||||
|
return _with_0:SetGroupUrl("http://banland.xyz/Game/LuaWebService/HandleSocialRequest.ashx?method=IsInGroup&playerid=%d&groupid=%d")
|
||||||
|
end)
|
||||||
|
pcall(function()
|
||||||
|
return _with_0:SetGroupRankUrl("http://banland.xyz/Game/LuaWebService/HandleSocialRequest.ashx?method=GetGroupRank&playerid=%d&groupid=%d")
|
||||||
|
end)
|
||||||
|
pcall(function()
|
||||||
|
return _with_0:SetGroupRoleUrl("http://banland.xyz/Game/LuaWebService/HandleSocialRequest.ashx?method=GetGroupRole&playerid=%d&groupid=%d")
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
pcall(function()
|
||||||
|
return game:GetService("GamePassService"):SetPlayerHasPassUrl("http://banland.xyz/Game/GamePass/GamePassHandler.ashx?Action=HasPass&UserID=%d&PassID=%d")
|
||||||
end)
|
end)
|
||||||
pcall(function()
|
pcall(function()
|
||||||
game:GetService("SocialService")
|
return game:GetService("MarketplaceService"):SetProductInfoUrl("https://banland.xyz/marketplace/productinfo?assetId=%d")
|
||||||
:SetBestFriendUrl "http://banland.xyz/Game/LuaWebService/HandleSocialRequest.ashx?method=IsBestFriendsWith&playerid=%d&userid=%d"
|
|
||||||
end)
|
end)
|
||||||
pcall(function()
|
pcall(function()
|
||||||
game:GetService("SocialService")
|
return game:GetService("MarketplaceService"):SetPlayerOwnsAssetUrl("https://banland.xyz/ownership/hasasset?userId=%d&assetId=%d")
|
||||||
:SetGroupUrl "http://banland.xyz/Game/LuaWebService/HandleSocialRequest.ashx?method=IsInGroup&playerid=%d&groupid=%d"
|
|
||||||
end)
|
end)
|
||||||
pcall(function()
|
pcall(function()
|
||||||
game:GetService("SocialService")
|
return game:SetCreatorID(_CREATOR_ID, Enum.CreatorType.User)
|
||||||
:SetGroupRankUrl "http://banland.xyz/Game/LuaWebService/HandleSocialRequest.ashx?method=GetGroupRank&playerid=%d&groupid=%d"
|
|
||||||
end)
|
end)
|
||||||
pcall(function()
|
pcall(function()
|
||||||
game:GetService("SocialService")
|
return game:GetService("Players"):SetChatStyle(Enum.ChatStyle.ClassicAndBubble)
|
||||||
:SetGroupRoleUrl "http://banland.xyz/Game/LuaWebService/HandleSocialRequest.ashx?method=GetGroupRole&playerid=%d&groupid=%d"
|
|
||||||
end)
|
end)
|
||||||
pcall(function()
|
|
||||||
game:GetService("GamePassService")
|
|
||||||
:SetPlayerHasPassUrl "http://banland.xyz/Game/GamePass/GamePassHandler.ashx?Action=HasPass&UserID=%d&PassID=%d"
|
|
||||||
end)
|
|
||||||
pcall(function()
|
|
||||||
game:GetService("MarketplaceService"):SetProductInfoUrl "https://banland.xyz/marketplace/productinfo?assetId=%d"
|
|
||||||
end)
|
|
||||||
pcall(function()
|
|
||||||
game:GetService("MarketplaceService")
|
|
||||||
:SetPlayerOwnsAssetUrl "https://banland.xyz/ownership/hasasset?userId=%d&assetId=%d"
|
|
||||||
end)
|
|
||||||
pcall(function()
|
|
||||||
game:SetCreatorID(_CREATOR_ID, Enum.CreatorType.User)
|
|
||||||
end)
|
|
||||||
|
|
||||||
-- Bubble chat. This is all-encapsulated to allow us to turn it off with a config setting
|
|
||||||
pcall(function()
|
|
||||||
game:GetService("Players"):SetChatStyle(Enum.ChatStyle.ClassicAndBubble)
|
|
||||||
end)
|
|
||||||
|
|
||||||
local waitingForCharacter = false
|
local waitingForCharacter = false
|
||||||
pcall(function()
|
pcall(function()
|
||||||
if settings().Network.MtuOverride == 0 then
|
if settings().Network.MtuOverride == 0 then
|
||||||
settings().Network.MtuOverride = 1400
|
settings().Network.MtuOverride = 1400
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
local client = game:GetService("NetworkClient")
|
||||||
-- globals -----------------------------------------
|
local visit = game:GetService("Visit")
|
||||||
|
local setMessage
|
||||||
client = game:GetService "NetworkClient"
|
setMessage = function(message)
|
||||||
visit = game:GetService "Visit"
|
return game:SetMessage((function()
|
||||||
|
if not false then
|
||||||
-- functions ---------------------------------------
|
return message
|
||||||
function setMessage(message)
|
else
|
||||||
-- todo: animated "..."
|
return "Teleporting ..."
|
||||||
if not false then
|
end
|
||||||
game:SetMessage(message)
|
end)())
|
||||||
else
|
|
||||||
-- hack, good enought for now
|
|
||||||
game:SetMessage "Teleporting ..."
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
local showErrorWindow
|
||||||
function showErrorWindow(message, errorType, errorCategory)
|
showErrorWindow = function(message, _, _)
|
||||||
game:SetMessage(message)
|
return game:SetMessage(message)
|
||||||
end
|
end
|
||||||
|
local reportError
|
||||||
function reportError(err, message)
|
reportError = function(err, message)
|
||||||
print("***ERROR*** " .. err)
|
print("***ERROR*** " .. tostring(err))
|
||||||
if not test then
|
if not test then
|
||||||
visit:SetUploadUrl ""
|
visit:SetUploadUrl("")
|
||||||
end
|
end
|
||||||
client:Disconnect()
|
client:disconnect()
|
||||||
wait(4)
|
wait(4)
|
||||||
showErrorWindow("Error: " .. err, message, "Other")
|
return showErrorWindow("Error: " .. tostring(err), message, "Other")
|
||||||
end
|
end
|
||||||
|
local onDisconnection
|
||||||
-- called when the client connection closes
|
onDisconnection = function(_, lostConnection)
|
||||||
function onDisconnection(peer, lostConnection)
|
|
||||||
if lostConnection then
|
if lostConnection then
|
||||||
showErrorWindow("You have lost the connection to the game", "LostConnection", "LostConnection")
|
return showErrorWindow("You have lost the connection to the game", "LostConnection", "LostConnection")
|
||||||
else
|
else
|
||||||
showErrorWindow("This game has shut down", "Kick", "Kick")
|
return showErrorWindow("This game has shut down", "Kick", "Kick")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
local requestCharacter
|
||||||
function requestCharacter(replicator)
|
requestCharacter = function(replicator)
|
||||||
-- prepare code for when the Character appears
|
|
||||||
local connection
|
local connection
|
||||||
connection = player.Changed:connect(function(property)
|
connection = player.Changed:connect(function(property)
|
||||||
if property == "Character" then
|
if property == "Character" then
|
||||||
game:ClearMessage()
|
game:ClearMessage()
|
||||||
waitingForCharacter = false
|
waitingForCharacter = false
|
||||||
connection:disconnect()
|
return connection:disconnect()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
setMessage("Requesting character")
|
||||||
setMessage "Requesting character"
|
local success, err
|
||||||
|
success, err = pcall(function()
|
||||||
local success, err = pcall(function()
|
|
||||||
replicator:RequestCharacter()
|
replicator:RequestCharacter()
|
||||||
setMessage "Waiting for character"
|
setMessage("Waiting for character")
|
||||||
waitingForCharacter = true
|
waitingForCharacter = true
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if not success then
|
if not success then
|
||||||
reportError(err, "W4C")
|
reportError(err, "W4C")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
local onConnectionAccepted
|
||||||
-- called when the client connection is established
|
onConnectionAccepted = function(url, replicator)
|
||||||
function onConnectionAccepted(url, replicator)
|
local connectResolved = true
|
||||||
connectResolved = true
|
|
||||||
|
|
||||||
local waitingForMarker = true
|
local waitingForMarker = true
|
||||||
|
local success, err
|
||||||
local success, err = pcall(function()
|
success, err = pcall(function()
|
||||||
if not test then
|
if not test then
|
||||||
visit:SetPing("_PING_URL", 30)
|
visit:SetPing("_PING_URL", 30)
|
||||||
end
|
end
|
||||||
|
|
||||||
if not false then
|
if not false then
|
||||||
game:SetMessageBrickCount()
|
game:SetMessageBrickCount()
|
||||||
else
|
else
|
||||||
setMessage "Teleporting ..."
|
setMessage("Teleporting ...")
|
||||||
end
|
end
|
||||||
|
|
||||||
replicator.Disconnection:connect(onDisconnection)
|
replicator.Disconnection:connect(onDisconnection)
|
||||||
|
|
||||||
-- Wait for a marker to return before creating the Player
|
|
||||||
local marker = replicator:SendMarker()
|
local marker = replicator:SendMarker()
|
||||||
|
return marker.Received:connect(function()
|
||||||
marker.Received:connect(function()
|
|
||||||
waitingForMarker = false
|
waitingForMarker = false
|
||||||
requestCharacter(replicator)
|
return requestCharacter(replicator)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if not success then
|
if not success then
|
||||||
reportError(err, "ConnectionAccepted")
|
reportError(err, "ConnectionAccepted")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO: report marker progress
|
|
||||||
|
|
||||||
while waitingForMarker do
|
while waitingForMarker do
|
||||||
workspace:ZoomToExtents()
|
workspace:ZoomToExtents()
|
||||||
wait(0.5)
|
wait(0.5)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
local onConnectionFailed
|
||||||
-- called when the client connection fails
|
onConnectionFailed = function(_, err)
|
||||||
function onConnectionFailed(_, error)
|
return showErrorWindow("Failed to connect to the Game. (ID=" .. tostring(err) .. ")", "ID" .. tostring(err), "Other")
|
||||||
showErrorWindow("Failed to connect to the Game. (ID=" .. error .. ")", "ID" .. error, "Other")
|
|
||||||
end
|
end
|
||||||
|
local onConnectionRejected
|
||||||
-- called when the client connection is rejected
|
onConnectionRejected = function()
|
||||||
function onConnectionRejected()
|
|
||||||
connectionFailed:disconnect()
|
connectionFailed:disconnect()
|
||||||
showErrorWindow("This game is not available. Please try another", "WrongVersion", "WrongVersion")
|
return showErrorWindow("This game is not available. Please try another", "WrongVersion", "WrongVersion")
|
||||||
end
|
end
|
||||||
|
local idled = false
|
||||||
idled = false
|
local onPlayerIdled
|
||||||
function onPlayerIdled(time)
|
onPlayerIdled = function(time)
|
||||||
if time > 20 * 60 then
|
if time > 20 * 60 then
|
||||||
showErrorWindow(string.format("You were disconnected for being idle %d minutes", time / 60), "Idle", "Idle")
|
showErrorWindow(string.format("You were disconnected for being idle %d minutes", time / 60), "Idle", "Idle")
|
||||||
client:Disconnect()
|
client:disconnect()
|
||||||
if not idled then
|
if not idled then
|
||||||
idled = true
|
idled = true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- main ------------------------------------------------------------
|
|
||||||
|
|
||||||
pcall(function()
|
pcall(function()
|
||||||
settings().Diagnostics:LegacyScriptMode()
|
return settings().Diagnostics:LegacyScriptMode()
|
||||||
end)
|
end)
|
||||||
local success, err = pcall(function()
|
local success, err = pcall(function()
|
||||||
game:SetRemoteBuildMode(true)
|
game:SetRemoteBuildMode(true)
|
||||||
|
setMessage("Connecting to Server")
|
||||||
setMessage "Connecting to Server"
|
|
||||||
client.ConnectionAccepted:connect(onConnectionAccepted)
|
client.ConnectionAccepted:connect(onConnectionAccepted)
|
||||||
client.ConnectionRejected:connect(onConnectionRejected)
|
client.ConnectionRejected:connect(onConnectionRejected)
|
||||||
connectionFailed = client.ConnectionFailed:connect(onConnectionFailed)
|
connectionFailed = client.ConnectionFailed:connect(onConnectionFailed)
|
||||||
client.Ticket = ""
|
client.Ticket = ""
|
||||||
|
|
||||||
playerConnectSucces, player = pcall(function()
|
playerConnectSucces, player = pcall(function()
|
||||||
return client:PlayerConnect(_USER_ID, "_SERVER_ADDRESS", _SERVER_PORT, 0, threadSleepTime)
|
return client:PlayerConnect(_USER_ID, "_SERVER_ADDRESS", _SERVER_PORT, 0, threadSleepTime)
|
||||||
end)
|
end)
|
||||||
if not playerConnectSucces then
|
if not playerConnectSucces then
|
||||||
--Old player connection scheme
|
|
||||||
player = game:GetService("Players"):CreateLocalPlayer(_USER_ID)
|
player = game:GetService("Players"):CreateLocalPlayer(_USER_ID)
|
||||||
client:Connect("_SERVER_ADDRESS", _SERVER_PORT, 0, threadSleepTime)
|
client:Connect("_SERVER_ADDRESS", _SERVER_PORT, 0, threadSleepTime)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- negotiate an auth token
|
|
||||||
if not test then
|
if not test then
|
||||||
delay(300, function()
|
delay(300, function()
|
||||||
while false do
|
while false do
|
||||||
pcall(function()
|
pcall(function()
|
||||||
game:HttpPost("https://banland.xyz/auth/renew", "renew")
|
return game:HttpPost("https://banland.xyz/auth/renew", "renew")
|
||||||
end)
|
end)
|
||||||
wait(300)
|
wait(300)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
do
|
||||||
player:SetSuperSafeChat(false)
|
local _with_0 = player
|
||||||
pcall(function()
|
_with_0:SetSuperSafeChat(false)
|
||||||
player:SetUnder13(false)
|
pcall(function()
|
||||||
end)
|
return _with_0:SetUnder13(false)
|
||||||
pcall(function()
|
end)
|
||||||
player:SetMembershipType(Enum.MembershipType._MEMBERSHIP_TYPE)
|
pcall(function()
|
||||||
end)
|
return _with_0:SetMembershipType(Enum.MembershipType._MEMBERSHIP_TYPE)
|
||||||
pcall(function()
|
end)
|
||||||
player:SetAccountAge(1)
|
pcall(function()
|
||||||
end)
|
return _with_0:SetAccountAge(1)
|
||||||
|
end)
|
||||||
|
end
|
||||||
player.Idled:connect(onPlayerIdled)
|
player.Idled:connect(onPlayerIdled)
|
||||||
|
pcall(function()
|
||||||
-- Overriden
|
|
||||||
onPlayerAdded(player)
|
|
||||||
|
|
||||||
pcall(function()
|
|
||||||
player.Name = [========[_USER_NAME]========]
|
player.Name = [========[_USER_NAME]========]
|
||||||
end)
|
end)
|
||||||
player.CharacterAppearance = "_CHAR_APPEARANCE"
|
player.CharacterAppearance = "_CHAR_APPEARANCE"
|
||||||
if not test then
|
if not test then
|
||||||
visit:SetUploadUrl ""
|
return visit:SetUploadUrl("")
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
if not success then
|
if not success then
|
||||||
reportError(err, "CreatePlayer")
|
reportError(err, "CreatePlayer")
|
||||||
end
|
end
|
||||||
|
|
||||||
if not test then
|
if not test then
|
||||||
-- TODO: Async get?
|
loadfile(("")("", -1, 0))
|
||||||
loadfile ""("", -1, 0)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
pcall(function()
|
pcall(function()
|
||||||
game:SetScreenshotInfo ""
|
return game:SetScreenshotInfo("")
|
||||||
end)
|
end)
|
||||||
pcall(function()
|
return pcall(function()
|
||||||
game:SetVideoInfo '<?xml version="1.0"?><entry xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xmlns:yt="http://gdata.youtube.com/schemas/2007"><media:group><media:title type="plain"><![CDATA[ROBLOX Place]]></media:title><media:description type="plain"><![CDATA[ For more games visit http://www.roblox.com]]></media:description><media:category scheme="http://gdata.youtube.com/schemas/2007/categories.cat">Games</media:category><media:keywords>ROBLOX, video, free game, online virtual world</media:keywords></media:group></entry>'
|
return game:SetVideoInfo('<?xml version="1.0"?><entry xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xmlns:yt="http://gdata.youtube.com/schemas/2007"><media:group><media:title type="plain"><![CDATA[ROBLOX Place]]></media:title><media:description type="plain"><![CDATA[ For more games visit http://www.roblox.com]]></media:description><media:category scheme="http://gdata.youtube.com/schemas/2007/categories.cat">Games</media:category><media:keywords>ROBLOX, video, free game, online virtual world</media:keywords></media:group></entry>')
|
||||||
end)
|
end)
|
||||||
-- use single quotes here because the video info string may have unescaped double quotes
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,268 @@
|
||||||
|
import "macros" as { $ }
|
||||||
|
|
||||||
|
-- functions --------------------------
|
||||||
|
-- onPlayerAdded = (player) ->
|
||||||
|
-- -- override
|
||||||
|
|
||||||
|
$lua "-- MultiplayerSharedScript.lua inserted here ------ Prepended to Join.lua --"
|
||||||
|
|
||||||
|
try
|
||||||
|
game\SetPlaceID _PLACE_ID, false
|
||||||
|
|
||||||
|
|
||||||
|
-- if we are on a touch device, no blocking http calls allowed! This can cause a crash on iOS
|
||||||
|
-- In general we need a long term strategy to remove blocking http calls from all platforms
|
||||||
|
isTouchDevice = Game\GetService"UserInputService".TouchEnabled
|
||||||
|
|
||||||
|
settings!["Game Options"].CollisionSoundEnabled = true
|
||||||
|
try
|
||||||
|
settings!.Rendering.EnableFRM = true
|
||||||
|
try
|
||||||
|
settings!.Physics.Is30FpsThrottleEnabled = false
|
||||||
|
try
|
||||||
|
settings!["Task Scheduler"].PriorityMethod = Enum.PriorityMethod.AccumulatedError
|
||||||
|
try
|
||||||
|
settings!.Physics.PhysicsEnvironmentalThrottle = Enum.EnviromentalPhysicsThrottle.DefaultAuto
|
||||||
|
|
||||||
|
|
||||||
|
-- arguments ---------------------------------------
|
||||||
|
threadSleepTime = ...
|
||||||
|
|
||||||
|
if threadSleepTime == nil
|
||||||
|
threadSleepTime = 15
|
||||||
|
|
||||||
|
|
||||||
|
test = _IS_STUDIO_JOIN
|
||||||
|
|
||||||
|
print "! Joining game '_PLACE_ID' place _PLACE_ID at _SERVER_ADDRESS"
|
||||||
|
|
||||||
|
game\GetService"ChangeHistoryService"\SetEnabled false
|
||||||
|
game\GetService"ContentProvider"\SetThreadPool 16
|
||||||
|
|
||||||
|
with game\GetService "InsertService"
|
||||||
|
\SetBaseSetsUrl "http://www.roblox.com/Game/Tools/InsertAsset.ashx?nsets=10&type=base"
|
||||||
|
\SetUserSetsUrl "http://www.roblox.com/Game/Tools/InsertAsset.ashx?nsets=20&type=user&userid=%d"
|
||||||
|
\SetCollectionUrl "http://www.roblox.com/Game/Tools/InsertAsset.ashx?sid=%d"
|
||||||
|
\SetAssetUrl "http://banland.xyz/Asset/?id=%d"
|
||||||
|
\SetAssetVersionUrl "http://www.roblox.com/Asset/?assetversionid=%d"
|
||||||
|
|
||||||
|
with game\GetService "SocialService"
|
||||||
|
try
|
||||||
|
\SetFriendUrl "http://banland.xyz/Game/LuaWebService/HandleSocialRequest.ashx?method=IsFriendsWith&playerid=%d&userid=%d"
|
||||||
|
try
|
||||||
|
\SetBestFriendUrl "http://banland.xyz/Game/LuaWebService/HandleSocialRequest.ashx?method=IsBestFriendsWith&playerid=%d&userid=%d"
|
||||||
|
try
|
||||||
|
\SetGroupUrl "http://banland.xyz/Game/LuaWebService/HandleSocialRequest.ashx?method=IsInGroup&playerid=%d&groupid=%d"
|
||||||
|
try
|
||||||
|
\SetGroupRankUrl "http://banland.xyz/Game/LuaWebService/HandleSocialRequest.ashx?method=GetGroupRank&playerid=%d&groupid=%d"
|
||||||
|
try
|
||||||
|
\SetGroupRoleUrl "http://banland.xyz/Game/LuaWebService/HandleSocialRequest.ashx?method=GetGroupRole&playerid=%d&groupid=%d"
|
||||||
|
|
||||||
|
try
|
||||||
|
game\GetService"GamePassService"\SetPlayerHasPassUrl "http://banland.xyz/Game/GamePass/GamePassHandler.ashx?Action=HasPass&UserID=%d&PassID=%d"
|
||||||
|
try
|
||||||
|
game\GetService"MarketplaceService"\SetProductInfoUrl "https://banland.xyz/marketplace/productinfo?assetId=%d"
|
||||||
|
try
|
||||||
|
game\GetService"MarketplaceService"\SetPlayerOwnsAssetUrl "https://banland.xyz/ownership/hasasset?userId=%d&assetId=%d"
|
||||||
|
try
|
||||||
|
game\SetCreatorID _CREATOR_ID, Enum.CreatorType.User
|
||||||
|
|
||||||
|
-- Bubble chat. This is all-encapsulated to allow us to turn it off with a config setting
|
||||||
|
try
|
||||||
|
game\GetService"Players"\SetChatStyle Enum.ChatStyle.ClassicAndBubble
|
||||||
|
|
||||||
|
|
||||||
|
waitingForCharacter = false
|
||||||
|
try
|
||||||
|
if settings!.Network.MtuOverride == 0
|
||||||
|
settings!.Network.MtuOverride = 1400
|
||||||
|
|
||||||
|
|
||||||
|
-- globals -----------------------------------------
|
||||||
|
|
||||||
|
client = game\GetService "NetworkClient"
|
||||||
|
visit = game\GetService "Visit"
|
||||||
|
|
||||||
|
-- functions ---------------------------------------
|
||||||
|
setMessage = (message) ->
|
||||||
|
-- todo: animated "..."
|
||||||
|
game\SetMessage if not false
|
||||||
|
message
|
||||||
|
else
|
||||||
|
-- hack, good enought for now
|
||||||
|
"Teleporting ..."
|
||||||
|
|
||||||
|
|
||||||
|
showErrorWindow = (message, _, _) ->
|
||||||
|
game\SetMessage message
|
||||||
|
|
||||||
|
|
||||||
|
reportError = (err, message) ->
|
||||||
|
print "***ERROR*** #{err}"
|
||||||
|
if not test
|
||||||
|
visit\SetUploadUrl ""
|
||||||
|
|
||||||
|
client\disconnect!
|
||||||
|
wait 4
|
||||||
|
showErrorWindow "Error: #{err}", message, "Other"
|
||||||
|
|
||||||
|
|
||||||
|
-- called when the client connection closes
|
||||||
|
onDisconnection = (_, lostConnection) ->
|
||||||
|
if lostConnection
|
||||||
|
showErrorWindow "You have lost the connection to the game", "LostConnection", "LostConnection"
|
||||||
|
else
|
||||||
|
showErrorWindow "This game has shut down", "Kick", "Kick"
|
||||||
|
|
||||||
|
|
||||||
|
requestCharacter = (replicator) ->
|
||||||
|
-- prepare code for when the Character appears
|
||||||
|
local connection
|
||||||
|
connection = player.Changed\connect (property) ->
|
||||||
|
if property == "Character"
|
||||||
|
game\ClearMessage!
|
||||||
|
waitingForCharacter = false
|
||||||
|
connection\disconnect!
|
||||||
|
|
||||||
|
|
||||||
|
setMessage "Requesting character"
|
||||||
|
|
||||||
|
local success, err = try
|
||||||
|
replicator\RequestCharacter!
|
||||||
|
setMessage "Waiting for character"
|
||||||
|
waitingForCharacter = true
|
||||||
|
|
||||||
|
|
||||||
|
if not success
|
||||||
|
reportError err, "W4C"
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
-- called when the client connection is established
|
||||||
|
onConnectionAccepted = (url, replicator) ->
|
||||||
|
connectResolved = true
|
||||||
|
|
||||||
|
waitingForMarker = true
|
||||||
|
|
||||||
|
local success, err = try
|
||||||
|
if not test
|
||||||
|
visit\SetPing "_PING_URL", 30
|
||||||
|
|
||||||
|
|
||||||
|
if not false
|
||||||
|
game\SetMessageBrickCount!
|
||||||
|
else
|
||||||
|
setMessage "Teleporting ..."
|
||||||
|
|
||||||
|
|
||||||
|
replicator.Disconnection\connect onDisconnection
|
||||||
|
|
||||||
|
-- Wait for a marker to return before creating the Player
|
||||||
|
marker = replicator\SendMarker!
|
||||||
|
|
||||||
|
marker.Received\connect ->
|
||||||
|
waitingForMarker = false
|
||||||
|
requestCharacter replicator
|
||||||
|
|
||||||
|
|
||||||
|
if not success
|
||||||
|
reportError err, "ConnectionAccepted"
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
-- TODO: report marker progress
|
||||||
|
|
||||||
|
while waitingForMarker
|
||||||
|
workspace\ZoomToExtents!
|
||||||
|
wait 0.5
|
||||||
|
|
||||||
|
|
||||||
|
-- called when the client connection fails
|
||||||
|
onConnectionFailed = (_, err) ->
|
||||||
|
showErrorWindow "Failed to connect to the Game. (ID=#{err})", "ID#{err}", "Other"
|
||||||
|
|
||||||
|
|
||||||
|
-- called when the client connection is rejected
|
||||||
|
onConnectionRejected = ->
|
||||||
|
connectionFailed\disconnect!
|
||||||
|
showErrorWindow "This game is not available. Please try another", "WrongVersion", "WrongVersion"
|
||||||
|
|
||||||
|
|
||||||
|
idled = false
|
||||||
|
onPlayerIdled = (time) ->
|
||||||
|
if time > 20 * 60
|
||||||
|
showErrorWindow string.format("You were disconnected for being idle %d minutes", time / 60), "Idle", "Idle"
|
||||||
|
client\disconnect!
|
||||||
|
if not idled
|
||||||
|
idled = true
|
||||||
|
|
||||||
|
|
||||||
|
-- main ------------------------------------------------------------
|
||||||
|
|
||||||
|
try
|
||||||
|
settings!.Diagnostics\LegacyScriptMode!
|
||||||
|
|
||||||
|
success, err = try
|
||||||
|
game\SetRemoteBuildMode true
|
||||||
|
|
||||||
|
setMessage "Connecting to Server"
|
||||||
|
client.ConnectionAccepted\connect onConnectionAccepted
|
||||||
|
client.ConnectionRejected\connect onConnectionRejected
|
||||||
|
global connectionFailed = client.ConnectionFailed\connect onConnectionFailed
|
||||||
|
client.Ticket = ""
|
||||||
|
|
||||||
|
global playerConnectSucces, player = try
|
||||||
|
client\PlayerConnect _USER_ID, "_SERVER_ADDRESS", _SERVER_PORT, 0, threadSleepTime
|
||||||
|
|
||||||
|
if not playerConnectSucces
|
||||||
|
--Old player connection scheme
|
||||||
|
player = game\GetService"Players"\CreateLocalPlayer _USER_ID
|
||||||
|
client\Connect "_SERVER_ADDRESS", _SERVER_PORT, 0, threadSleepTime
|
||||||
|
|
||||||
|
|
||||||
|
-- negotiate an auth token
|
||||||
|
if not test
|
||||||
|
delay 300, ->
|
||||||
|
while false
|
||||||
|
try
|
||||||
|
game\HttpPost "https://banland.xyz/auth/renew", "renew"
|
||||||
|
|
||||||
|
wait 300
|
||||||
|
|
||||||
|
with player
|
||||||
|
\SetSuperSafeChat false
|
||||||
|
try
|
||||||
|
\SetUnder13 false
|
||||||
|
try
|
||||||
|
\SetMembershipType Enum.MembershipType._MEMBERSHIP_TYPE
|
||||||
|
try
|
||||||
|
\SetAccountAge 1
|
||||||
|
|
||||||
|
player.Idled\connect onPlayerIdled
|
||||||
|
|
||||||
|
-- Overriden
|
||||||
|
-- onPlayerAdded player
|
||||||
|
|
||||||
|
try
|
||||||
|
player.Name = [========[_USER_NAME]========]
|
||||||
|
|
||||||
|
player.CharacterAppearance = "_CHAR_APPEARANCE"
|
||||||
|
if not test
|
||||||
|
visit\SetUploadUrl ""
|
||||||
|
|
||||||
|
|
||||||
|
if not success
|
||||||
|
reportError err, "CreatePlayer"
|
||||||
|
|
||||||
|
|
||||||
|
if not test
|
||||||
|
-- TODO: Async get?
|
||||||
|
loadfile ""("", -1, 0)
|
||||||
|
|
||||||
|
|
||||||
|
try
|
||||||
|
game\SetScreenshotInfo ""
|
||||||
|
try
|
||||||
|
game\SetVideoInfo '<?xml version="1.0"?><entry xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xmlns:yt="http://gdata.youtube.com/schemas/2007"><media:group><media:title type="plain"><![CDATA[ROBLOX Place]]></media:title><media:description type="plain"><![CDATA[ For more games visit http://www.roblox.com]]></media:description><media:category scheme="http://gdata.youtube.com/schemas/2007/categories.cat">Games</media:category><media:keywords>ROBLOX, video, free game, online virtual world</media:keywords></media:group></entry>'
|
||||||
|
|
||||||
|
-- use single quotes here because the video info string may have unescaped double quotes
|
||||||
|
|
@ -1,2 +1,4 @@
|
||||||
export macro load = (file) ->
|
export macro load = (file) ->
|
||||||
"print \"[Mercury]: Loaded corescript #{file\sub 8, -6}\""
|
"print \"[Mercury]: Loaded corescript #{file\sub 8, -6}\""
|
||||||
|
|
||||||
|
export macro lua = (code) -> :code, type: "lua"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue