Advertisement
iiFlamez

Untitled

Oct 12th, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.21 KB | None | 0 0
  1. -- params : ...
  2.  
  3. local this = {}
  4. local settings = require(game.ReplicatedStorage.Settings.GameSettings)
  5. local Items = require(game.ReplicatedStorage.Settings.Items)
  6. local Series = require(game.ReplicatedStorage.Settings.Series)
  7. local Rarities = require(game.ReplicatedStorage.Settings.Rarities)
  8. local Player = require(game.ReplicatedStorage.Game.Player)
  9. local Util = require(game.ReplicatedStorage.Game.Util)
  10. local Analytics = require(game.ReplicatedStorage.Game.Analytics)
  11. local marketplaceService = game:GetService("MarketplaceService")
  12. local players = game:GetService("Players")
  13. local starterGui = game:GetService("StarterGui")
  14. local isServer = game:FindService("NetworkServer") ~= nil
  15. local isClient = game:FindService("NetworkClient") ~= nil
  16. local isPlaySolo = (not isServer and not isClient)
  17. local isDesktop = settings.KeyboardEnabled
  18. local isMobile = (not isDesktop and settings.TouchEnabled)
  19. local isConsole = (not isDesktop and not isMobile)
  20. local unfuseRobuxPrice = nil
  21. do
  22. local tryingToUnfuseItem = {}
  23. this.InitServer = function(self)
  24. end
  25.  
  26. this.InitClient = function(self)
  27. end
  28.  
  29. this.StartServer = function(self)
  30. script.RollSeries.OnServerInvoke = function(player, seriesName)
  31. assert(typeof(seriesName) == "string", "\'seriesName\' must be a string")
  32. do
  33. local file = Player:GetPlayerData(player)
  34. if file.DataLoaded.Value and file.PendingSpins:FindFirstChild(seriesName) then
  35. file.PendingSpins[seriesName].Value = file.PendingSpins[seriesName].Value - 1
  36. if file.PendingSpins[seriesName].Value <= 0 then
  37. file.PendingSpins[seriesName]:Destroy()
  38. end
  39. local item = this:RollForItem(seriesName)
  40. do
  41. local itemInstance = this:AwardItem(player, item, true, "Rolled")
  42. pcall(function()
  43. Analytics:IncrementField("capsulesopened", 1)
  44. Analytics:IncrementField(item.Rarity:lower() .. "Rolled", 1)
  45. end)
  46. return true, item.ItemName, itemInstance
  47. end
  48. end
  49. do return false end
  50. -- DECOMPILER ERROR: 3 unprocessed JMP targets
  51. end
  52. end
  53.  
  54. script.SetTryingToUnfuseItem.OnServerEvent:connect(function(player, item)
  55. assert((typeof(item) == "Instance" and item:IsA("Folder")), "\'item\' must be a Folder")
  56. do
  57. local file = Player:GetPlayerData(player)
  58. if file and file.DataLoaded.Value and item.Parent and item.Parent.Parent == file then
  59. tryingToUnfuseItem[player] = item
  60. end
  61. -- DECOMPILER ERROR: 3 unprocessed JMP targets
  62. end
  63. end)
  64. script.RedeemUnfuseCredit.OnServerEvent:connect(function(player)
  65. this:RedeemUnfuseCredit(player)
  66. end)
  67. players.PlayerRemoving:connect(function(player)
  68. tryingToUnfuseItem[player] = nil
  69. end)
  70. script.MarkSeen.OnServerEvent:connect(function(player, item)
  71. assert((typeof(item) == "Instance" and item:IsA("Folder")), "\'item\' must be a Folder")
  72. if item.Parent == game.ReplicatedStorage.PlayerData[player.Name].Inventory then
  73. item.IsNew.Value = false
  74. if item.FusedItem.Value then
  75. item.FusedItem.Value.IsNew.Value = false
  76. end
  77. end
  78. -- DECOMPILER ERROR: 3 unprocessed JMP targets
  79. end)
  80. script.EquipMyItem.OnServerEvent:connect(function(player, item)
  81. assert((typeof(item) == "Instance" and item:IsA("Folder")), "\'item\' must be a Folder")
  82. do
  83. local file = game.ReplicatedStorage.PlayerData[player.Name]
  84. if item.Parent == file.Inventory then
  85. this:EquipItem(item)
  86. end
  87. -- DECOMPILER ERROR: 3 unprocessed JMP targets
  88. end
  89. end)
  90. script.UnequipMyItem.OnServerEvent:connect(function(player, item)
  91. assert((typeof(item) == "Instance" and item:IsA("Folder")), "\'item\' must be a Folder")
  92. do
  93. local file = game.ReplicatedStorage.PlayerData[player.Name]
  94. if item.Parent == file.Inventory then
  95. this:UnequipItem(item)
  96. end
  97. -- DECOMPILER ERROR: 3 unprocessed JMP targets
  98. end
  99. end)
  100. script.FuseItems.OnServerEvent:connect(function(player, a, b)
  101. assert((typeof(a) == "Instance" and a:IsA("Folder")), "\'a\' must be a Folder")
  102. assert((typeof(b) == "Instance" and b:IsA("Folder")), "\'b\' must be a Folder")
  103. do
  104. local file = game.ReplicatedStorage.PlayerData[player.Name]
  105. if a.Parent == file.Inventory and b.Parent == file.Inventory then
  106. this:FuseItems(a, b)
  107. end
  108. -- DECOMPILER ERROR: 5 unprocessed JMP targets
  109. end
  110. end)
  111. script.RevealMyItem.OnServerEvent:connect(function(player, item)
  112. assert((typeof(item) == "Instance" and item:IsA("Folder")), "\'item\' must be a Folder")
  113. do
  114. local file = game.ReplicatedStorage.PlayerData[player.Name]
  115. if item.Parent == file.Inventory then
  116. item.HideFromInventory.Value = false
  117. end
  118. -- DECOMPILER ERROR: 3 unprocessed JMP targets
  119. end
  120. end)
  121. local onPlayerData = function(file)
  122. if not file.DataLoaded.Value then
  123. file.DataLoaded:GetPropertyChangedSignal("Value"):wait()
  124. end
  125. if not file.ArbitraryData:FindFirstChild("GotFirstJoinCapsule") then
  126. local Products = require(game.ReplicatedStorage.Game.Products)
  127. local value = Instance.new("StringValue")
  128. value.Name = "GotFirstJoinCapsule"
  129. value.Value = "a"
  130. value.Parent = file.ArbitraryData
  131. Products:ProcessPurchase(players[file.Name], {
  132. AwardsSeries = {Variety = 1}
  133. })
  134. end
  135. end
  136.  
  137. game.ReplicatedStorage.PlayerData.ChildAdded:connect(onPlayerData)
  138. for i,v in next do
  139. do
  140. Util:FastSpawn(function()
  141. onPlayerData(v)
  142. end)
  143. end
  144. end
  145. end
  146.  
  147. this.StartClient = function(self)
  148. script.AnnounceItemAwarded.OnClientEvent:connect(function(args)
  149. starterGui:SetCore("ChatMakeSystemMessage", {Text = args.text, Color = args.color})
  150. end)
  151. end
  152.  
  153. this.MarkSeen = function(self, item)
  154. script.MarkSeen:FireServer(item)
  155. end
  156.  
  157. this.RedeemMyUnfuseCredit = function(self)
  158. script.RedeemUnfuseCredit:FireServer()
  159. end
  160.  
  161. this.UnfuseItem = function(self, item)
  162. local needToRefresh = false
  163. if item.FusedItem.Value and item.FusedItem.Value.FusedItem.Value == item then
  164. if not needToRefresh then
  165. needToRefresh = item.FusedItem.Value.IsEquipped.Value
  166. end
  167. item.FusedItem.Value.FusedItem.Value = nil
  168. end
  169. if not needToRefresh then
  170. needToRefresh = item.IsEquipped.Value
  171. end
  172. item.FusedItem.Value = nil
  173. if needToRefresh and item.Parent.Parent.Parent == game.ReplicatedStorage.PlayerData then
  174. local player = players:FindFirstChild(item.Parent.Parent.Name)
  175. if player then
  176. local Knives = require(game.ReplicatedStorage.Game.Knives)
  177. Knives:UpdateKnifeAppearance(player)
  178. end
  179. end
  180. end
  181.  
  182. this.FuseItems = function(self, a, b)
  183. if isClient then
  184. script.FuseItems:FireServer(a, b)
  185. return
  186. end
  187. if a.Parent == b.Parent and a.Parent.Parent.Parent == game.ReplicatedStorage.PlayerData then
  188. if a.FusedItem.Value then
  189. this:UnfuseItem(a)
  190. end
  191. if b.FusedItem.Value then
  192. this:UnfuseItem(b)
  193. end
  194. a.FusedItem.Value = b
  195. b.FusedItem.Value = a
  196. if a.IsEquipped.Value or b.IsEquipped.Value then
  197. local player = players:FindFirstChild(a.Parent.Parent.Name)
  198. if player then
  199. local Knives = require(game.ReplicatedStorage.Game.Knives)
  200. Knives:UpdateKnifeAppearance(player)
  201. end
  202. end
  203. end
  204. end
  205.  
  206. this.RedeemUnfuseCredit = function(self, player)
  207. local file = Player:GetPlayerData(player)
  208. if file and file.DataLoaded.Value and tryingToUnfuseItem[player] then
  209. if file.UnfuseCredits.Value > 0 then
  210. file.UnfuseCredits.Value = file.UnfuseCredits.Value - 1
  211. local item = tryingToUnfuseItem[player]
  212. if item then
  213. this:UnfuseItem(item)
  214. end
  215. else
  216. do
  217. local Products = require(game.ReplicatedStorage.Game.Products)
  218. Products:AttemptPurchase(Products:GetProduct(102218147))
  219. end
  220. end
  221. end
  222. end
  223.  
  224. this.SetTryingToUnfuseItem = function(self, item)
  225. script.SetTryingToUnfuseItem:FireServer(item)
  226. end
  227.  
  228. this.MakeItemInstance = function(self, item)
  229. local value = game.ReplicatedStorage.Assets.DefaultItemData:Clone()
  230. value.Name = item.ItemName
  231. return value
  232. end
  233.  
  234. this.AwardItem = function(self, player, item, hidden, why)
  235. local data = game.ReplicatedStorage.PlayerData[player.Name]
  236. local value = nil
  237. if typeof(item) == "Instance" then
  238. value = item
  239. else
  240. if typeof(item) == "string" then
  241. item = this:GetItem(item)
  242. end
  243. value = this:MakeItemInstance(item)
  244. end
  245. value.ReceivedAtTime.Value = math.floor(os.time() * 100000)
  246. value.IsNew.Value = true
  247. value.HideFromInventory.Value = hidden or false
  248. value.Parent = data.Inventory
  249. if not hidden then
  250. this:AnnounceItemAwarded(player, value, why)
  251. else
  252. local c = nil
  253. do
  254. c = value.HideFromInventory:GetPropertyChangedSignal("Value"):connect(function()
  255. c:disconnect()
  256. this:AnnounceItemAwarded(player, value, why)
  257. end)
  258. end
  259. end
  260. do
  261. return value
  262. end
  263. end
  264.  
  265. this.AnnounceItemAwarded = function(self, player, item, why)
  266. local rarity = Rarities[this:GetItemInstanceRarity(item)]
  267. if rarity.AnnounceOnReceive then
  268. local class = this:GetItem(item.Name)
  269. if not rarity.Dots then
  270. 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})
  271. if not rarity.Dots then
  272. 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})
  273. end
  274. end
  275. end
  276. end
  277.  
  278. this.RevealMyItem = function(self, item)
  279. item.HideFromInventory.Value = false
  280. script.RevealMyItem:FireServer(item)
  281. end
  282.  
  283. this.GetRandomSeries = function(self)
  284. local list = {}
  285. for name in next do
  286. table.insert(list, name)
  287. end
  288. return list[math.random(1, #list)]
  289. end
  290.  
  291. this.RollForItem = function(self, seriesName, itemType, communistMode)
  292. local contents = Series[seriesName].Contents
  293. local rarityOptions = {}
  294. for i,itemName in next do
  295. local item = Items[itemName]
  296. if not itemType or item.Type == itemType then
  297. local rarity = Rarities[item.Rarity]
  298. if rarityOptions[rarity] == nil then
  299. rarityOptions[rarity] = {}
  300. end
  301. table.insert(rarityOptions[rarity], item)
  302. end
  303. end
  304. local raritySum = 0
  305. for rarity in next do
  306. raritySum = raritySum + rarity.SelectionWeight
  307. end
  308. local rarityRoll = math.random() * (raritySum)
  309. for rarity,itemsOfRarity in next do
  310. rarityRoll = rarityRoll - rarity.SelectionWeight
  311. if rarityRoll <= 0 then
  312. return itemsOfRarity[math.random(1, #itemsOfRarity)]
  313. end
  314. end
  315. end
  316.  
  317. this.GetRarityWeight = function(self, rarity)
  318. return Rarities[rarity].SelectionWeight
  319. end
  320.  
  321. this.GetItem = function(self, name)
  322. return Items[name]
  323. end
  324.  
  325. this.OverrideItemQuality = function(self, item, quality)
  326. if quality == nil and item:FindFirstChild("OverrideQuality") then
  327. item.OverrideQuality:Destroy()
  328. else
  329. if quality and Rarities[quality] ~= nil then
  330. if not item:FindFirstChild("OverrideQuality") then
  331. local value = Instance.new("StringValue")
  332. value.Name = "OverrideQuality"
  333. value.Value = quality
  334. value.Parent = item
  335. else
  336. do
  337. item.OverrideQuality.Value = quality
  338. end
  339. end
  340. end
  341. end
  342. end
  343.  
  344. this.GetItemPrefix = function(self, item)
  345. local rarity, class = nil, nil
  346. if typeof(item) == "Instance" then
  347. local rarityName = this:GetItemInstanceRarity(item, true)
  348. rarity = Rarities[rarityName]
  349. class = this:GetItem(item.Name)
  350. else
  351. do
  352. rarity = Rarities[item.Rarity]
  353. class = item
  354. local prefix = ""
  355. if rarity and rarity.PrefixItemName then
  356. prefix = rarity.PrefixItemName
  357. end
  358. return prefix
  359. end
  360. end
  361. end
  362.  
  363. this.GetItemName = function(self, item, suppressPrefix)
  364. local rarity, class = nil, nil
  365. if typeof(item) == "Instance" then
  366. if item:FindFirstChild("CustomName") then
  367. return "\"%s\"":format(item.CustomName.Value)
  368. end
  369. local rarityName = this:GetItemInstanceRarity(item, true)
  370. rarity = Rarities[rarityName]
  371. class = this:GetItem(item.Name)
  372. else
  373. do
  374. rarity = Rarities[item.Rarity]
  375. class = item
  376. local name = class.DisplayName
  377. if rarity and rarity.PrefixItemName and not suppressPrefix then
  378. name = rarity.PrefixItemName .. name
  379. end
  380. return name
  381. end
  382. end
  383. end
  384.  
  385. this.GetItemInstanceRarity = function(self, item, ignoreFusions)
  386. if not item then
  387. return "Common"
  388. end
  389. local options = {}
  390. if item:FindFirstChild("OverrideQuality") then
  391. return item.OverrideQuality.Value, true
  392. else
  393. table.insert(options, this:GetItem(item.Name).Rarity)
  394. do
  395. if not ignoreFusions and item.FusedItem.Value then
  396. local fusedRarity = this:GetItemInstanceRarity(item.FusedItem.Value, true)
  397. table.insert(options, fusedRarity)
  398. end
  399. do
  400. local firstClassRarity = options[1]
  401. table.sort(options, function(a, b)
  402. do return Rarities[b].SortValue < Rarities[a].SortValue end
  403. -- DECOMPILER ERROR: 1 unprocessed JMP targets
  404. end)
  405. do return options[1], options[1] == firstClassRarity end
  406. -- DECOMPILER ERROR: 2 unprocessed JMP targets
  407. end
  408. end
  409. end
  410. end
  411.  
  412. this.DoRoll = function(self, seriesName)
  413. return script.RollSeries:InvokeServer(seriesName)
  414. end
  415.  
  416. this.GetFusedItem = function(self, item)
  417. do return (typeof(item) == "Instance" and item.FusedItem.Value) end
  418. -- DECOMPILER ERROR: 2 unprocessed JMP targets
  419. end
  420.  
  421. this.GetFusedItemClass = function(self, item)
  422. local fusedItem = this:GetFusedItem(item)
  423. return fusedItem and this:GetItem(fusedItem.Name) or nil
  424. end
  425.  
  426. this.GetItemClass = function(self, item)
  427. return typeof(item) == "Instance" and Items[item.Name] or item
  428. end
  429.  
  430. this.GetUnfuseRobuxPrice = function(self)
  431. return unfuseRobuxPrice
  432. end
  433.  
  434. this.EquipMyItem = function(self, item)
  435. script.EquipMyItem:FireServer(item)
  436. end
  437.  
  438. this.UnequipMyItem = function(self, item)
  439. script.UnequipMyItem:FireServer(item)
  440. end
  441.  
  442. this.EquipItem = function(self, item)
  443. local class = this:GetItem(item.Name)
  444. for i,other in next do
  445. if other ~= item and other.IsEquipped.Value and this:GetItem(other.Name).Type == class.Type then
  446. this:UnequipItem(other)
  447. end
  448. end
  449. item.IsEquipped.Value = true
  450. local player = game.Players:FindFirstChild(item.Parent.Parent.Name)
  451. if player then
  452. local Knives = require(game.ReplicatedStorage.Game.Knives)
  453. Knives:UpdateKnifeAppearance(player)
  454. end
  455. end
  456.  
  457. this.UnequipItem = function(self, item)
  458. item.IsEquipped.Value = false
  459. local player = game.Players:FindFirstChild(item.Parent.Parent.Name)
  460. if player then
  461. local Knives = require(game.ReplicatedStorage.Game.Knives)
  462. Knives:UpdateKnifeAppearance(player)
  463. end
  464. end
  465.  
  466. this.GetItemSellValue = function(self, item)
  467. if typeof(item) == "Instance" then
  468. local rarity = Rarities[this:GetItemInstanceRarity(item)]
  469. return (item.FusedItem.Value == nil and not rarity.BlockSales), rarity.SellValue
  470. else
  471. local rarity = Rarities[item.Rarity]
  472. return not rarity.BlockSales, Rarities[item.Rarity].SellValue
  473. end
  474. -- DECOMPILER ERROR: 4 unprocessed JMP targets
  475. end
  476.  
  477. this.PlayerOwnsA = function(self, player, itemName)
  478. local file = game.ReplicatedStorage.PlayerData:FindFirstChild(player.Name)
  479. if file.Inventory:FindFirstChild(itemName) == nil then
  480. do
  481. do return not file or not file.DataLoaded.Value end
  482. do return false end
  483. -- DECOMPILER ERROR: 2 unprocessed JMP targets
  484. end
  485. end
  486. end
  487.  
  488. this.GetItems = function(self)
  489. return Items
  490. end
  491.  
  492. do return this end
  493. -- DECOMPILER ERROR: 8 unprocessed JMP targets
  494. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement