Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* eslint-disable roblox-ts/no-any */
- import { ReplicatedStorage } from "@rbxts/services";
- function upper(STRING: string) {
- return STRING.upper();
- }
- type gunData = {
- rarities: {};
- };
- interface tableData {
- [key: string]: [];
- }
- const base64 = (require(ReplicatedStorage.FindFirstChild("Modules")?.FindFirstChild(
- "base64",
- ) as ModuleScript) as unknown) as { decode: Function };
- export function fixgundata(DATA: Array<string>, PLAYER: Player) {
- const GUNS = game.GetService("ReplicatedStorage").WaitForChild("Guns");
- const UNPACKED = new Array(0);
- for (const [ID, STRING] of pairs(DATA)) {
- let gunName = "",
- gunRarity = "",
- extraGundata = "";
- let i = 0;
- for (let [capture] of STRING.gmatch("([^_]+)")) {
- i++;
- if (i === 1 && GUNS.FindFirstChild(capture)) {
- gunName = capture as string;
- } else if (i === 2) {
- capture = ((capture as string).lower().gsub("^%l", upper) as unknown) as string;
- const FOUND_MODULE = ReplicatedStorage.FindFirstChild("GunData")?.FindFirstChild(
- gunName as string,
- ) as ModuleScript;
- let requiredModule: gunData;
- if (FOUND_MODULE) {
- requiredModule = require(FOUND_MODULE) as gunData;
- let rarityStored;
- for (const [RARITY] of pairs(requiredModule.rarities)) {
- if (RARITY === capture) {
- rarityStored = RARITY;
- }
- }
- if (rarityStored !== capture) {
- PLAYER.Kick("Something went wrong and the gun rarity was not found.");
- }
- gunRarity = (rarityStored as unknown) as string;
- }
- } else if (i === 3) {
- extraGundata = base64.decode(capture);
- }
- }
- const TABLEDATA: tableData = {};
- for (const [formatString] of extraGundata.gmatch("([^|]+)")) {
- const INDEX = ((formatString as string)
- .sub(0, ((formatString as string).find("=") as unknown) as number)
- .gsub("=", "") as unknown) as string;
- const VALUE = (formatString as string).sub(
- (((formatString as string).find("=") as unknown) as number) + 1,
- (formatString as string).size(),
- );
- if (VALUE.find(",")[0] !== undefined) {
- TABLEDATA[INDEX] = [];
- for (const [_, SPLIT] of pairs(VALUE.split(","))) {
- TABLEDATA[INDEX].push(SPLIT as never);
- }
- } else if (VALUE.find('"')[0] !== undefined) {
- TABLEDATA[INDEX] = [];
- } else {
- if (INDEX === "attachments") {
- TABLEDATA[INDEX] = [];
- TABLEDATA[INDEX].push(VALUE as never);
- } else {
- TABLEDATA[INDEX] = (VALUE as unknown) as [];
- }
- }
- }
- UNPACKED[ID - 1] = {
- rarity: gunRarity,
- extra: extraGundata,
- unpackedExtra: TABLEDATA,
- name: gunName,
- fullname: STRING,
- };
- }
- return UNPACKED;
- }
Add Comment
Please, Sign In to add comment