Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- RemoteHelper module
- local RemoteHelper = {}
- -- Internal: Generates the key based on the player's name and the place version
- local function generate_key()
- local player_name = game.Players.LocalPlayer.Name
- local place_version = game.PlaceVersion
- return player_name .. place_version .. "make_games_dont_cheat"
- end
- -- Internal: Removes GUID from a string
- local function remove_guid(str)
- local guid_pattern = "%x%x%x%x%x%x%x%x%-%x%x%x%x%-%x%x%x%x%-%x%x%x%x%-%x%x%x%x%x%x%x%x%x%x%x%x"
- return str:gsub(guid_pattern, "") -- Remove GUID
- end
- -- Internal: Repeats the key for XOR operation
- local function repeat_key_upvr(key, length)
- local repeated_key = ""
- while #repeated_key < length do
- repeated_key = repeated_key .. key
- end
- return repeated_key:sub(1, length)
- end
- -- Internal: Reverses the XOR operation
- local function reverse_hash(hash, key)
- local repeated_key = repeat_key_upvr(key, #hash)
- local original = ""
- for i = 1, #hash do
- original = original .. string.char(bit32.bxor(hash:sub(i, i):byte(), repeated_key:sub(i, i):byte()))
- end
- return original
- end
- -- Internal: Retrieves the target module
- local function get_cached_remotes()
- local target = game:GetService("ReplicatedFirst").Client
- local success, requiredModule = pcall(require, target)
- if not success then
- warn("Failed to require the target module.")
- return nil
- end
- return requiredModule.CachedRemotes
- end
- -- Retrieves remote names with cleaned names
- function RemoteHelper.get_remote_names()
- local cached_remotes = get_cached_remotes() -- Retrieve cached remotes
- if not cached_remotes then
- return nil
- end
- local key = generate_key() -- Generate the key
- local remote_map = {}
- for hashed, value in pairs(cached_remotes) do
- local clean_name = remove_guid(reverse_hash(hashed, key)) -- Remove GUID
- remote_map[clean_name] = value -- Add cleaned name as key and its value
- end
- return remote_map
- end
- -- Searches for a specific remote name
- function RemoteHelper.search_remote_by_name(toSearch)
- local remote_map = RemoteHelper.get_remote_names() -- Get cleaned names
- if not remote_map then
- warn("Failed to retrieve remote map.")
- return nil
- end
- for name, value in pairs(remote_map) do
- if name == toSearch then
- return value -- Return the value for the searched name
- end
- end
- return nil -- Return nil if not found
- end
- -- Searches for a specific remote value
- function RemoteHelper.search_remote_by_value(toSearchValue)
- local remote_map = RemoteHelper.get_remote_names() -- Get cleaned names
- if not remote_map then
- warn("Failed to retrieve remote map.")
- return nil
- end
- for name, value in pairs(remote_map) do
- if value == toSearchValue then
- return name -- Return the name for the searched value
- end
- end
- return nil -- Return nil if not found
- end
- return RemoteHelper
Add Comment
Please, Sign In to add comment