Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- params : ...
- local this = {}
- local settings = require(game.ReplicatedStorage.Settings.GameSettings)
- local Items = require(game.ReplicatedStorage.Settings.Items)
- local Series = require(game.ReplicatedStorage.Settings.Series)
- local Rarities = require(game.ReplicatedStorage.Settings.Rarities)
- local Player = require(game.ReplicatedStorage.Game.Player)
- local Util = require(game.ReplicatedStorage.Game.Util)
- local Analytics = require(game.ReplicatedStorage.Game.Analytics)
- local marketplaceService = game:GetService("MarketplaceService")
- local players = game:GetService("Players")
- local starterGui = game:GetService("StarterGui")
- local isServer = game:FindService("NetworkServer") ~= nil
- local isClient = game:FindService("NetworkClient") ~= nil
- local isPlaySolo = (not isServer and not isClient)
- local isDesktop = settings.KeyboardEnabled
- local isMobile = (not isDesktop and settings.TouchEnabled)
- local isConsole = (not isDesktop and not isMobile)
- local unfuseRobuxPrice = nil
- do
- local tryingToUnfuseItem = {}
- this.InitServer = function(self)
- end
- this.InitClient = function(self)
- end
- this.StartServer = function(self)
- script.RollSeries.OnServerInvoke = function(player, seriesName)
- assert(typeof(seriesName) == "string", "\'seriesName\' must be a string")
- do
- local file = Player:GetPlayerData(player)
- if file.DataLoaded.Value and file.PendingSpins:FindFirstChild(seriesName) then
- file.PendingSpins[seriesName].Value = file.PendingSpins[seriesName].Value - 1
- if file.PendingSpins[seriesName].Value <= 0 then
- file.PendingSpins[seriesName]:Destroy()
- end
- local item = this:RollForItem(seriesName)
- do
- local itemInstance = this:AwardItem(player, item, true, "Rolled")
- pcall(function()
- Analytics:IncrementField("capsulesopened", 1)
- Analytics:IncrementField(item.Rarity:lower() .. "Rolled", 1)
- end)
- return true, item.ItemName, itemInstance
- end
- end
- do return false end
- -- DECOMPILER ERROR: 3 unprocessed JMP targets
- end
- end
- script.SetTryingToUnfuseItem.OnServerEvent:connect(function(player, item)
- assert((typeof(item) == "Instance" and item:IsA("Folder")), "\'item\' must be a Folder")
- do
- local file = Player:GetPlayerData(player)
- if file and file.DataLoaded.Value and item.Parent and item.Parent.Parent == file then
- tryingToUnfuseItem[player] = item
- end
- -- DECOMPILER ERROR: 3 unprocessed JMP targets
- end
- end)
- script.RedeemUnfuseCredit.OnServerEvent:connect(function(player)
- this:RedeemUnfuseCredit(player)
- end)
- players.PlayerRemoving:connect(function(player)
- tryingToUnfuseItem[player] = nil
- end)
- script.MarkSeen.OnServerEvent:connect(function(player, item)
- assert((typeof(item) == "Instance" and item:IsA("Folder")), "\'item\' must be a Folder")
- if item.Parent == game.ReplicatedStorage.PlayerData[player.Name].Inventory then
- item.IsNew.Value = false
- if item.FusedItem.Value then
- item.FusedItem.Value.IsNew.Value = false
- end
- end
- -- DECOMPILER ERROR: 3 unprocessed JMP targets
- end)
- script.EquipMyItem.OnServerEvent:connect(function(player, item)
- assert((typeof(item) == "Instance" and item:IsA("Folder")), "\'item\' must be a Folder")
- do
- local file = game.ReplicatedStorage.PlayerData[player.Name]
- if item.Parent == file.Inventory then
- this:EquipItem(item)
- end
- -- DECOMPILER ERROR: 3 unprocessed JMP targets
- end
- end)
- script.UnequipMyItem.OnServerEvent:connect(function(player, item)
- assert((typeof(item) == "Instance" and item:IsA("Folder")), "\'item\' must be a Folder")
- do
- local file = game.ReplicatedStorage.PlayerData[player.Name]
- if item.Parent == file.Inventory then
- this:UnequipItem(item)
- end
- -- DECOMPILER ERROR: 3 unprocessed JMP targets
- end
- end)
- script.FuseItems.OnServerEvent:connect(function(player, a, b)
- assert((typeof(a) == "Instance" and a:IsA("Folder")), "\'a\' must be a Folder")
- assert((typeof(b) == "Instance" and b:IsA("Folder")), "\'b\' must be a Folder")
- do
- local file = game.ReplicatedStorage.PlayerData[player.Name]
- if a.Parent == file.Inventory and b.Parent == file.Inventory then
- this:FuseItems(a, b)
- end
- -- DECOMPILER ERROR: 5 unprocessed JMP targets
- end
- end)
- script.RevealMyItem.OnServerEvent:connect(function(player, item)
- assert((typeof(item) == "Instance" and item:IsA("Folder")), "\'item\' must be a Folder")
- do
- local file = game.ReplicatedStorage.PlayerData[player.Name]
- if item.Parent == file.Inventory then
- item.HideFromInventory.Value = false
- end
- -- DECOMPILER ERROR: 3 unprocessed JMP targets
- end
- end)
- local onPlayerData = function(file)
- if not file.DataLoaded.Value then
- file.DataLoaded:GetPropertyChangedSignal("Value"):wait()
- end
- if not file.ArbitraryData:FindFirstChild("GotFirstJoinCapsule") then
- local Products = require(game.ReplicatedStorage.Game.Products)
- local value = Instance.new("StringValue")
- value.Name = "GotFirstJoinCapsule"
- value.Value = "a"
- value.Parent = file.ArbitraryData
- Products:ProcessPurchase(players[file.Name], {
- AwardsSeries = {Variety = 1}
- })
- end
- end
- game.ReplicatedStorage.PlayerData.ChildAdded:connect(onPlayerData)
- for i,v in next do
- do
- Util:FastSpawn(function()
- onPlayerData(v)
- end)
- end
- end
- end
- this.StartClient = function(self)
- script.AnnounceItemAwarded.OnClientEvent:connect(function(args)
- starterGui:SetCore("ChatMakeSystemMessage", {Text = args.text, Color = args.color})
- end)
- end
- this.MarkSeen = function(self, item)
- script.MarkSeen:FireServer(item)
- end
- this.RedeemMyUnfuseCredit = function(self)
- script.RedeemUnfuseCredit:FireServer()
- end
- this.UnfuseItem = function(self, item)
- local needToRefresh = false
- if item.FusedItem.Value and item.FusedItem.Value.FusedItem.Value == item then
- if not needToRefresh then
- needToRefresh = item.FusedItem.Value.IsEquipped.Value
- end
- item.FusedItem.Value.FusedItem.Value = nil
- end
- if not needToRefresh then
- needToRefresh = item.IsEquipped.Value
- end
- item.FusedItem.Value = nil
- if needToRefresh and item.Parent.Parent.Parent == game.ReplicatedStorage.PlayerData then
- local player = players:FindFirstChild(item.Parent.Parent.Name)
- if player then
- local Knives = require(game.ReplicatedStorage.Game.Knives)
- Knives:UpdateKnifeAppearance(player)
- end
- end
- end
- this.FuseItems = function(self, a, b)
- if isClient then
- script.FuseItems:FireServer(a, b)
- return
- end
- if a.Parent == b.Parent and a.Parent.Parent.Parent == game.ReplicatedStorage.PlayerData then
- if a.FusedItem.Value then
- this:UnfuseItem(a)
- end
- if b.FusedItem.Value then
- this:UnfuseItem(b)
- end
- a.FusedItem.Value = b
- b.FusedItem.Value = a
- if a.IsEquipped.Value or b.IsEquipped.Value then
- local player = players:FindFirstChild(a.Parent.Parent.Name)
- if player then
- local Knives = require(game.ReplicatedStorage.Game.Knives)
- Knives:UpdateKnifeAppearance(player)
- end
- end
- end
- end
- this.RedeemUnfuseCredit = function(self, player)
- local file = Player:GetPlayerData(player)
- if file and file.DataLoaded.Value and tryingToUnfuseItem[player] then
- if file.UnfuseCredits.Value > 0 then
- file.UnfuseCredits.Value = file.UnfuseCredits.Value - 1
- local item = tryingToUnfuseItem[player]
- if item then
- this:UnfuseItem(item)
- end
- else
- do
- local Products = require(game.ReplicatedStorage.Game.Products)
- Products:AttemptPurchase(Products:GetProduct(102218147))
- end
- end
- end
- end
- this.SetTryingToUnfuseItem = function(self, item)
- script.SetTryingToUnfuseItem:FireServer(item)
- end
- this.MakeItemInstance = function(self, item)
- local value = game.ReplicatedStorage.Assets.DefaultItemData:Clone()
- value.Name = item.ItemName
- return value
- end
- this.AwardItem = function(self, player, item, hidden, why)
- local data = game.ReplicatedStorage.PlayerData[player.Name]
- local value = nil
- if typeof(item) == "Instance" then
- value = item
- else
- if typeof(item) == "string" then
- item = this:GetItem(item)
- end
- value = this:MakeItemInstance(item)
- end
- value.ReceivedAtTime.Value = math.floor(os.time() * 100000)
- value.IsNew.Value = true
- value.HideFromInventory.Value = hidden or false
- value.Parent = data.Inventory
- if not hidden then
- this:AnnounceItemAwarded(player, value, why)
- else
- local c = nil
- do
- c = value.HideFromInventory:GetPropertyChangedSignal("Value"):connect(function()
- c:disconnect()
- this:AnnounceItemAwarded(player, value, why)
- end)
- end
- end
- do
- return value
- end
- end
- this.AnnounceItemAwarded = function(self, player, item, why)
- local rarity = Rarities[this:GetItemInstanceRarity(item)]
- if rarity.AnnounceOnReceive then
- local class = this:GetItem(item.Name)
- if not rarity.Dots then
- script.AnnounceItemAwarded:FireAllClients({text = "%s just rolled %s %s: %s!":format(player.Name, Util:An(class.Type), class.Type, this:GetItemName(item) .. "â˜\133":rep(why ~= "Rolled" or 0)), color = rarity.Color})
- if not rarity.Dots then
- script.AnnounceItemAwarded:FireAllClients({text = "%s was awarded %s %s: %s!":format(player.Name, Util:An(class.Type), class.Type, this:GetItemName(item) .. "â˜\133":rep(why ~= "Awarded" or 0)), color = rarity.Color})
- end
- end
- end
- end
- this.RevealMyItem = function(self, item)
- item.HideFromInventory.Value = false
- script.RevealMyItem:FireServer(item)
- end
- this.GetRandomSeries = function(self)
- local list = {}
- for name in next do
- table.insert(list, name)
- end
- return list[math.random(1, #list)]
- end
- this.RollForItem = function(self, seriesName, itemType, communistMode)
- local contents = Series[seriesName].Contents
- local rarityOptions = {}
- for i,itemName in next do
- local item = Items[itemName]
- if not itemType or item.Type == itemType then
- local rarity = Rarities[item.Rarity]
- if rarityOptions[rarity] == nil then
- rarityOptions[rarity] = {}
- end
- table.insert(rarityOptions[rarity], item)
- end
- end
- local raritySum = 0
- for rarity in next do
- raritySum = raritySum + rarity.SelectionWeight
- end
- local rarityRoll = math.random() * (raritySum)
- for rarity,itemsOfRarity in next do
- rarityRoll = rarityRoll - rarity.SelectionWeight
- if rarityRoll <= 0 then
- return itemsOfRarity[math.random(1, #itemsOfRarity)]
- end
- end
- end
- this.GetRarityWeight = function(self, rarity)
- return Rarities[rarity].SelectionWeight
- end
- this.GetItem = function(self, name)
- return Items[name]
- end
- this.OverrideItemQuality = function(self, item, quality)
- if quality == nil and item:FindFirstChild("OverrideQuality") then
- item.OverrideQuality:Destroy()
- else
- if quality and Rarities[quality] ~= nil then
- if not item:FindFirstChild("OverrideQuality") then
- local value = Instance.new("StringValue")
- value.Name = "OverrideQuality"
- value.Value = quality
- value.Parent = item
- else
- do
- item.OverrideQuality.Value = quality
- end
- end
- end
- end
- end
- this.GetItemPrefix = function(self, item)
- local rarity, class = nil, nil
- if typeof(item) == "Instance" then
- local rarityName = this:GetItemInstanceRarity(item, true)
- rarity = Rarities[rarityName]
- class = this:GetItem(item.Name)
- else
- do
- rarity = Rarities[item.Rarity]
- class = item
- local prefix = ""
- if rarity and rarity.PrefixItemName then
- prefix = rarity.PrefixItemName
- end
- return prefix
- end
- end
- end
- this.GetItemName = function(self, item, suppressPrefix)
- local rarity, class = nil, nil
- if typeof(item) == "Instance" then
- if item:FindFirstChild("CustomName") then
- return "\"%s\"":format(item.CustomName.Value)
- end
- local rarityName = this:GetItemInstanceRarity(item, true)
- rarity = Rarities[rarityName]
- class = this:GetItem(item.Name)
- else
- do
- rarity = Rarities[item.Rarity]
- class = item
- local name = class.DisplayName
- if rarity and rarity.PrefixItemName and not suppressPrefix then
- name = rarity.PrefixItemName .. name
- end
- return name
- end
- end
- end
- this.GetItemInstanceRarity = function(self, item, ignoreFusions)
- if not item then
- return "Common"
- end
- local options = {}
- if item:FindFirstChild("OverrideQuality") then
- return item.OverrideQuality.Value, true
- else
- table.insert(options, this:GetItem(item.Name).Rarity)
- do
- if not ignoreFusions and item.FusedItem.Value then
- local fusedRarity = this:GetItemInstanceRarity(item.FusedItem.Value, true)
- table.insert(options, fusedRarity)
- end
- do
- local firstClassRarity = options[1]
- table.sort(options, function(a, b)
- do return Rarities[b].SortValue < Rarities[a].SortValue end
- -- DECOMPILER ERROR: 1 unprocessed JMP targets
- end)
- do return options[1], options[1] == firstClassRarity end
- -- DECOMPILER ERROR: 2 unprocessed JMP targets
- end
- end
- end
- end
- this.DoRoll = function(self, seriesName)
- return script.RollSeries:InvokeServer(seriesName)
- end
- this.GetFusedItem = function(self, item)
- do return (typeof(item) == "Instance" and item.FusedItem.Value) end
- -- DECOMPILER ERROR: 2 unprocessed JMP targets
- end
- this.GetFusedItemClass = function(self, item)
- local fusedItem = this:GetFusedItem(item)
- return fusedItem and this:GetItem(fusedItem.Name) or nil
- end
- this.GetItemClass = function(self, item)
- return typeof(item) == "Instance" and Items[item.Name] or item
- end
- this.GetUnfuseRobuxPrice = function(self)
- return unfuseRobuxPrice
- end
- this.EquipMyItem = function(self, item)
- script.EquipMyItem:FireServer(item)
- end
- this.UnequipMyItem = function(self, item)
- script.UnequipMyItem:FireServer(item)
- end
- this.EquipItem = function(self, item)
- local class = this:GetItem(item.Name)
- for i,other in next do
- if other ~= item and other.IsEquipped.Value and this:GetItem(other.Name).Type == class.Type then
- this:UnequipItem(other)
- end
- end
- item.IsEquipped.Value = true
- local player = game.Players:FindFirstChild(item.Parent.Parent.Name)
- if player then
- local Knives = require(game.ReplicatedStorage.Game.Knives)
- Knives:UpdateKnifeAppearance(player)
- end
- end
- this.UnequipItem = function(self, item)
- item.IsEquipped.Value = false
- local player = game.Players:FindFirstChild(item.Parent.Parent.Name)
- if player then
- local Knives = require(game.ReplicatedStorage.Game.Knives)
- Knives:UpdateKnifeAppearance(player)
- end
- end
- this.GetItemSellValue = function(self, item)
- if typeof(item) == "Instance" then
- local rarity = Rarities[this:GetItemInstanceRarity(item)]
- return (item.FusedItem.Value == nil and not rarity.BlockSales), rarity.SellValue
- else
- local rarity = Rarities[item.Rarity]
- return not rarity.BlockSales, Rarities[item.Rarity].SellValue
- end
- -- DECOMPILER ERROR: 4 unprocessed JMP targets
- end
- this.PlayerOwnsA = function(self, player, itemName)
- local file = game.ReplicatedStorage.PlayerData:FindFirstChild(player.Name)
- if file.Inventory:FindFirstChild(itemName) == nil then
- do
- do return not file or not file.DataLoaded.Value end
- do return false end
- -- DECOMPILER ERROR: 2 unprocessed JMP targets
- end
- end
- end
- this.GetItems = function(self)
- return Items
- end
- do return this end
- -- DECOMPILER ERROR: 8 unprocessed JMP targets
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement