Update gameserver.php

This commit is contained in:
Thomas G 2022-08-04 10:09:11 +10:00
parent 69efab264c
commit fcf98859b5
1 changed files with 41 additions and 24 deletions

View File

@ -171,36 +171,53 @@ local assetPropertyNames = {"Texture", "TextureId", "SoundId", "MeshId", "Skybox
local variations = {"http://www%.roblox%.com/asset/%?id=", "http://www%.roblox%.com/asset%?id=", "http://%.roblox%.com/asset/%?id=", "http://%.roblox%.com/asset%?id="}
function GetDescendants(o)
local allObjects = {}
function FindChildren(Object)
for _,v in pairs(Object:GetChildren()) do
table.insert(allObjects,v)
FindChildren(v)
end
end
FindChildren(o)
return allObjects
local allObjects = {}
function FindChildren(Object)
for _,v in pairs(Object:GetChildren()) do
table.insert(allObjects,v)
FindChildren(v)
end
end
FindChildren(o)
return allObjects
end
local replacedProperties = 0--Amount of properties changed
local replacedSourceCodes = 0
for i, v in pairs(GetDescendants(game)) do
for _, property in pairs(assetPropertyNames) do
pcall(function()
if v[property] and not v:FindFirstChild(property) then --Check for property, make sure we're not getting a child instead of a property
assetText = string.lower(v[property])
for _, variation in pairs(variations) do
v[property], matches = string.gsub(assetText, variation, "http://www%.morblox%.us/asset/%?id=")
if matches > 0 then
replacedProperties = replacedProperties + 1
print("Replaced " .. property .. " asset link for " .. v.Name)
break
end
end
end
end)
end
if v.ClassName == 'Script' or v.ClassName == 'LocalScript' then
local SourceCode = v.Source
if SourceCode then
for _, variation in pairs(variations) do
local String, Number = string.gsub(SourceCode, variation, "http://www%.morblox%.us/asset/%?id=")
SourceCode = String
if Number > 0 then
replacedSourceCodes = replacedSourceCodes + Number
end
end
v.Source = SourceCode
end
end
for _, property in pairs(assetPropertyNames) do
pcall(function()
if v[property] and not v:FindFirstChild(property) then --Check for property, make sure we're not getting a child instead of a property
assetText = string.lower(v[property])
for _, variation in pairs(variations) do
v[property], matches = string.gsub(assetText, variation, "http://www%.morblox%.us/asset/%?id=")
if matches > 0 then
replacedProperties = replacedProperties + 1
print("Replaced " .. property .. " asset link for " .. v.Name)
break
end
end
end
end)
end
end
print("Updated " .. replacedProperties .. " AssetIds")
print("Changed " .. replacedSourceCodes .. " lines of code")
-- other stuff
ns:Start(<?php echo $port; ?>, sleeptime)
pcall(function() game.LocalSaveEnabled = true end)