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