diff --git a/processed/join.lua b/processed/join.lua index 4820153..ad5c2dc 100644 --- a/processed/join.lua +++ b/processed/join.lua @@ -1,18 +1,8 @@ --- functions -------------------------- -function onPlayerAdded(player) - -- override -end - -- MultiplayerSharedScript.lua inserted here ------ Prepended to Join.lua -- - pcall(function() - game:SetPlaceID(_PLACE_ID, false) + return game:SetPlaceID(_PLACE_ID, false) 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 - settings()["Game Options"].CollisionSoundEnabled = true pcall(function() settings().Rendering.EnableFRM = true @@ -26,273 +16,225 @@ end) pcall(function() settings().Physics.PhysicsEnvironmentalThrottle = Enum.EnviromentalPhysicsThrottle.DefaultAuto end) - --- arguments --------------------------------------- local threadSleepTime = ... - if threadSleepTime == nil then threadSleepTime = 15 end - 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("ContentProvider"):SetThreadPool(16) -game:GetService("InsertService"):SetBaseSetsUrl "http://www.roblox.com/Game/Tools/InsertAsset.ashx?nsets=10&type=base" -game:GetService("InsertService") - :SetUserSetsUrl "http://www.roblox.com/Game/Tools/InsertAsset.ashx?nsets=20&type=user&userid=%d" -game:GetService("InsertService"):SetCollectionUrl "http://www.roblox.com/Game/Tools/InsertAsset.ashx?sid=%d" -game:GetService("InsertService"):SetAssetUrl "http://banland.xyz/Asset/?id=%d" -game:GetService("InsertService"):SetAssetVersionUrl "http://www.roblox.com/Asset/?assetversionid=%d" - +do + local _with_0 = game:GetService("InsertService") + _with_0:SetBaseSetsUrl("http://www.roblox.com/Game/Tools/InsertAsset.ashx?nsets=10&type=base") + _with_0:SetUserSetsUrl("http://www.roblox.com/Game/Tools/InsertAsset.ashx?nsets=20&type=user&userid=%d") + _with_0:SetCollectionUrl("http://www.roblox.com/Game/Tools/InsertAsset.ashx?sid=%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() - game:GetService("SocialService") - :SetFriendUrl "http://banland.xyz/Game/LuaWebService/HandleSocialRequest.ashx?method=IsFriendsWith&playerid=%d&userid=%d" + return _with_0: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) pcall(function() - game:GetService("SocialService") - :SetBestFriendUrl "http://banland.xyz/Game/LuaWebService/HandleSocialRequest.ashx?method=IsBestFriendsWith&playerid=%d&userid=%d" + return game:GetService("MarketplaceService"):SetProductInfoUrl("https://banland.xyz/marketplace/productinfo?assetId=%d") end) pcall(function() - game:GetService("SocialService") - :SetGroupUrl "http://banland.xyz/Game/LuaWebService/HandleSocialRequest.ashx?method=IsInGroup&playerid=%d&groupid=%d" + return game:GetService("MarketplaceService"):SetPlayerOwnsAssetUrl("https://banland.xyz/ownership/hasasset?userId=%d&assetId=%d") end) pcall(function() - game:GetService("SocialService") - :SetGroupRankUrl "http://banland.xyz/Game/LuaWebService/HandleSocialRequest.ashx?method=GetGroupRank&playerid=%d&groupid=%d" + return game:SetCreatorID(_CREATOR_ID, Enum.CreatorType.User) end) pcall(function() - game:GetService("SocialService") - :SetGroupRoleUrl "http://banland.xyz/Game/LuaWebService/HandleSocialRequest.ashx?method=GetGroupRole&playerid=%d&groupid=%d" + return game:GetService("Players"):SetChatStyle(Enum.ChatStyle.ClassicAndBubble) 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 pcall(function() if settings().Network.MtuOverride == 0 then settings().Network.MtuOverride = 1400 end end) - --- globals ----------------------------------------- - -client = game:GetService "NetworkClient" -visit = game:GetService "Visit" - --- functions --------------------------------------- -function setMessage(message) - -- todo: animated "..." - if not false then - game:SetMessage(message) - else - -- hack, good enought for now - game:SetMessage "Teleporting ..." - end +local client = game:GetService("NetworkClient") +local visit = game:GetService("Visit") +local setMessage +setMessage = function(message) + return game:SetMessage((function() + if not false then + return message + else + return "Teleporting ..." + end + end)()) end - -function showErrorWindow(message, errorType, errorCategory) - game:SetMessage(message) +local showErrorWindow +showErrorWindow = function(message, _, _) + return game:SetMessage(message) end - -function reportError(err, message) - print("***ERROR*** " .. err) +local reportError +reportError = function(err, message) + print("***ERROR*** " .. tostring(err)) if not test then - visit:SetUploadUrl "" + visit:SetUploadUrl("") end - client:Disconnect() + client:disconnect() wait(4) - showErrorWindow("Error: " .. err, message, "Other") + return showErrorWindow("Error: " .. tostring(err), message, "Other") end - --- called when the client connection closes -function onDisconnection(peer, lostConnection) +local onDisconnection +onDisconnection = function(_, lostConnection) 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 - showErrorWindow("This game has shut down", "Kick", "Kick") + return showErrorWindow("This game has shut down", "Kick", "Kick") end end - -function requestCharacter(replicator) - -- prepare code for when the Character appears +local requestCharacter +requestCharacter = function(replicator) local connection connection = player.Changed:connect(function(property) if property == "Character" then game:ClearMessage() waitingForCharacter = false - connection:disconnect() + return connection:disconnect() end end) - - setMessage "Requesting character" - - local success, err = pcall(function() + setMessage("Requesting character") + local success, err + success, err = pcall(function() replicator:RequestCharacter() - setMessage "Waiting for character" + setMessage("Waiting for character") waitingForCharacter = true end) - if not success then reportError(err, "W4C") return end end - --- called when the client connection is established -function onConnectionAccepted(url, replicator) - connectResolved = true - +local onConnectionAccepted +onConnectionAccepted = function(url, replicator) + local connectResolved = true local waitingForMarker = true - - local success, err = pcall(function() + local success, err + success, err = pcall(function() if not test then visit:SetPing("_PING_URL", 30) end - if not false then game:SetMessageBrickCount() else - setMessage "Teleporting ..." + setMessage("Teleporting ...") end - replicator.Disconnection:connect(onDisconnection) - - -- Wait for a marker to return before creating the Player local marker = replicator:SendMarker() - - marker.Received:connect(function() + return marker.Received:connect(function() waitingForMarker = false - requestCharacter(replicator) + return requestCharacter(replicator) end) end) - if not success then reportError(err, "ConnectionAccepted") return end - - -- TODO: report marker progress - while waitingForMarker do workspace:ZoomToExtents() wait(0.5) end end - --- called when the client connection fails -function onConnectionFailed(_, error) - showErrorWindow("Failed to connect to the Game. (ID=" .. error .. ")", "ID" .. error, "Other") +local onConnectionFailed +onConnectionFailed = function(_, err) + return showErrorWindow("Failed to connect to the Game. (ID=" .. tostring(err) .. ")", "ID" .. tostring(err), "Other") end - --- called when the client connection is rejected -function onConnectionRejected() +local onConnectionRejected +onConnectionRejected = function() 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 - -idled = false -function onPlayerIdled(time) +local idled = false +local onPlayerIdled +onPlayerIdled = function(time) if time > 20 * 60 then showErrorWindow(string.format("You were disconnected for being idle %d minutes", time / 60), "Idle", "Idle") - client:Disconnect() + client:disconnect() if not idled then idled = true end end end - --- main ------------------------------------------------------------ - pcall(function() - settings().Diagnostics:LegacyScriptMode() + return settings().Diagnostics:LegacyScriptMode() end) local success, err = pcall(function() game:SetRemoteBuildMode(true) - - setMessage "Connecting to Server" + setMessage("Connecting to Server") client.ConnectionAccepted:connect(onConnectionAccepted) client.ConnectionRejected:connect(onConnectionRejected) connectionFailed = client.ConnectionFailed:connect(onConnectionFailed) client.Ticket = "" - playerConnectSucces, player = pcall(function() return client:PlayerConnect(_USER_ID, "_SERVER_ADDRESS", _SERVER_PORT, 0, threadSleepTime) end) if not playerConnectSucces then - --Old player connection scheme player = game:GetService("Players"):CreateLocalPlayer(_USER_ID) client:Connect("_SERVER_ADDRESS", _SERVER_PORT, 0, threadSleepTime) end - - -- negotiate an auth token if not test then delay(300, function() while false do - pcall(function() - game:HttpPost("https://banland.xyz/auth/renew", "renew") +pcall(function() + return game:HttpPost("https://banland.xyz/auth/renew", "renew") end) wait(300) end end) end - - player:SetSuperSafeChat(false) - pcall(function() - player:SetUnder13(false) - end) - pcall(function() - player:SetMembershipType(Enum.MembershipType._MEMBERSHIP_TYPE) - end) - pcall(function() - player:SetAccountAge(1) - end) + do + local _with_0 = player + _with_0:SetSuperSafeChat(false) +pcall(function() + return _with_0:SetUnder13(false) + end) +pcall(function() + return _with_0:SetMembershipType(Enum.MembershipType._MEMBERSHIP_TYPE) + end) +pcall(function() + return _with_0:SetAccountAge(1) + end) + end player.Idled:connect(onPlayerIdled) - - -- Overriden - onPlayerAdded(player) - - pcall(function() +pcall(function() player.Name = [========[_USER_NAME]========] end) player.CharacterAppearance = "_CHAR_APPEARANCE" if not test then - visit:SetUploadUrl "" + return visit:SetUploadUrl("") end end) - if not success then reportError(err, "CreatePlayer") end - if not test then - -- TODO: Async get? - loadfile ""("", -1, 0) + loadfile(("")("", -1, 0)) end - pcall(function() - game:SetScreenshotInfo "" + return game:SetScreenshotInfo("") end) -pcall(function() - game:SetVideoInfo 'GamesROBLOX, video, free game, online virtual world' +return pcall(function() + return game:SetVideoInfo('GamesROBLOX, video, free game, online virtual world') end) --- use single quotes here because the video info string may have unescaped double quotes diff --git a/yue/join.yue b/yue/join.yue new file mode 100644 index 0000000..79964e4 --- /dev/null +++ b/yue/join.yue @@ -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 'GamesROBLOX, video, free game, online virtual world' + +-- use single quotes here because the video info string may have unescaped double quotes diff --git a/yue/macros.yue b/yue/macros.yue index 4fc84c7..f842e51 100644 --- a/yue/macros.yue +++ b/yue/macros.yue @@ -1,2 +1,4 @@ export macro load = (file) -> "print \"[Mercury]: Loaded corescript #{file\sub 8, -6}\"" + +export macro lua = (code) -> :code, type: "lua"