Advertisement
Aquarius_Raverus

Uh ye im dying

Apr 30th, 2020
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.64 KB | None | 0 0
  1. -- Inventory Controller 1
  2.  
  3. local Storage = game:GetService("ReplicatedStorage")
  4. local Events = Storage:WaitForChild("Events")
  5. local Players = game:GetService("Players")
  6.  
  7. local Items = Storage:WaitForChild("CraftableItems")
  8. local WepItems = Storage:WaitForChild("Weapons")
  9.  
  10. local InventoryFunction = Events:WaitForChild('InventoryFunction')
  11. local Modules = Storage:WaitForChild("Modules")
  12.  
  13. local InventoryModule = require(Modules:WaitForChild('Inventory'))
  14. local Max_Item_Slots = InventoryModule['Max_Item_Slots']
  15.  
  16. Players.PlayerAdded:Connect(function(plr)
  17.     local EquippedFolder = Instance.new("Folder", plr)
  18.     EquippedFolder.Name = 'Equipped_Items'
  19. end)
  20.  
  21. InventoryFunction.OnServerInvoke = function(plr, itemChosen, specificName, Type, action)
  22.     if action == 'EquipNewItem' then
  23.    
  24.         if itemChosen then
  25.             print(itemChosen.. ' has been found from server side. '.. specificName.. " Type is: ".. Type)
  26.                
  27.             local Equipped_Items = plr:WaitForChild('Equipped_Items')
  28.            
  29.             -- Max children check.
  30.                
  31.             for num,child in pairs(plr:WaitForChild('Equipped_Items'):GetChildren()) do
  32.                 if num == Max_Item_Slots then
  33.                        
  34.                     return "Max slots."
  35.                 end
  36.             end
  37.                 --
  38.         end
  39.     end
  40.        
  41.     if action == 'EquipDefaultItem' then
  42.         if Type == 'Food' then
  43.            
  44.             local Clone = Storage:WaitForChild(itemChosen):Clone()
  45.             Clone.Parent = plr.Character
  46.                
  47.             Clone['RightHand'].Part1 = plr.Character:WaitForChild('RightHand')
  48.            
  49.             local newValue = Instance.new("BoolValue", plr:WaitForChild('Equipped_Items'))
  50.             newValue.Name = itemChosen
  51.             newValue.Value = true
  52.         end
  53.     end
  54.    
  55.     if action == 'UnEquip' then
  56.         if plr:WaitForChild('Equipped_Items'):FindFirstChild(itemChosen) then
  57.             if Type == 'Food' then
  58.            
  59.                 plr.Equipped_Items[itemChosen]:Destroy()
  60.                
  61.                 local find = plr.Character:FindFirstChild(itemChosen)
  62.                 find:Destroy()
  63.             end
  64.         end
  65.     end
  66. end
  67.  
  68. ---
  69.  
  70.  
  71. -- Inventory Controller 2
  72.  
  73. -- Crafting Core
  74. -- By Sylvern
  75. -- 4/29/2020
  76.  
  77. local Settings = require(game:GetService("ReplicatedStorage"):WaitForChild('Modules'):WaitForChild('Crafting'))
  78. local Players = game:GetService("Players")
  79.  
  80. local Storage = game:GetService("ReplicatedStorage")
  81.  
  82. local CraftableItems = Storage:WaitForChild("CraftableItems")
  83. local Events = Storage:WaitForChild("Events")
  84.  
  85. local Crafting_Event = Events:WaitForChild('CraftingEvent')
  86. local Get_Description = Events:WaitForChild('GetDescription')
  87.  
  88. local Starter_Materials = Settings['Starter_Materials']
  89. local Craftable_Items = Settings['Craftable_Items']
  90.  
  91. Players.PlayerAdded:Connect(function(plr)
  92.     local Materials = Instance.new("Folder", plr)
  93.     Materials.Name = 'Materials'
  94.    
  95.     local Inventory = Instance.new("Folder", plr)
  96.     Inventory.Name = 'Inventory'
  97.    
  98.     for name,value in pairs(Starter_Materials) do      
  99.         local newValue = Instance.new("NumberValue", Materials)
  100.         newValue.Name = name
  101.         newValue.Value = value
  102.     end
  103. end)
  104.  
  105. Crafting_Event.OnServerEvent:Connect(function(plr, action, itemName)
  106.     if action == 'CraftItem' then
  107.         local checkItem = CraftableItems:FindFirstChild(itemName)
  108.         if not checkItem then
  109.             plr:Kick('Stop exploiting.')
  110.         end
  111.        
  112.         if checkItem then
  113.             for name, value in pairs(Craftable_Items[itemName].Cost) do
  114.                 warn(itemName)
  115.                 warn(name, value)
  116.                
  117.                 if plr:WaitForChild('Materials')[name].Value < value then warn"Not enough materials" return end
  118.                
  119.                 plr.Materials[name].Value = plr.Materials[name].Value - value
  120.                 warn("Successfully crafted "..itemName)
  121.                
  122.                 local newItem = Instance.new("BoolValue", plr:WaitForChild('Inventory'))
  123.                 newItem.Name = Craftable_Items[itemName]['ItemName']
  124.                 newItem.Value = true
  125.             end
  126.         end
  127.     end
  128. end)
  129.  
  130.  
  131. Get_Description.OnServerInvoke = function(plr, action, itemName, bool)
  132.     if action == 'Desc' then
  133.         warn(itemName)
  134.        
  135.         local getItem = Craftable_Items[itemName].Description
  136.         warn(getItem)
  137.        
  138.         return getItem
  139.     end
  140.    
  141.     if action == 'GetType' then
  142.         local getItem = Settings['Items'][itemName].Type
  143.        
  144.         return getItem
  145.     end
  146.    
  147.     if action == 'CraftingReturn' then
  148.         if bool == true then
  149.             return true
  150.         elseif bool == false then
  151.             return false
  152.         end
  153.     end
  154.  
  155.     if action == 'GetStarterMats' then
  156.        
  157.         return Starter_Materials
  158.     end
  159. end
  160.  
  161. --
  162.  
  163. -- Inventory Controller 3
  164.  
  165. game:GetService("StarterGui"):SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
  166.  
  167. local Storage = game:GetService("ReplicatedStorage")
  168. local Modules = Storage:WaitForChild("Modules")
  169. local UIS = game:GetService("UserInputService")
  170.  
  171. local Inventory = require(Modules:WaitForChild('Inventory'))
  172. local Max_Backpack_Slots = Inventory['Max_Backpack_Slots']
  173.  
  174. local Events = Storage:WaitForChild("Events")
  175. local InventoryFunction = Events:WaitForChild('InventoryFunction')
  176. local GetDesc = Events:WaitForChild('GetDescription')
  177.  
  178. local Template = script:WaitForChild("Template")
  179. local ButtonTemplate = script:WaitForChild("TextButton")
  180.  
  181. local BackpackFrame = script.Parent:WaitForChild("BackpackFrame")
  182.  
  183. local Default_Items = script.Parent:WaitForChild("DefaultItems")
  184.  
  185. local ItemEquipped = ""
  186.  
  187. local Item_Slots = {
  188.  
  189.    
  190.  
  191. }
  192.  
  193.  
  194. function update()
  195.     local Children = Default_Items:GetChildren()
  196.        
  197.     for i = 1, Max_Backpack_Slots do
  198.         local Clone = Template:Clone()
  199.         Clone.Parent = BackpackFrame
  200.        
  201.         Clone.Name = i
  202.        
  203.     end
  204.    
  205.     for i = 1, #Children do
  206.         local Slot = Instance.new("NumberValue", BackpackFrame:FindFirstChild(i))
  207.        
  208.         Slot.Name = Children[i].Name
  209.         Slot.Value = Children[i].Value
  210.        
  211.         local Button = ButtonTemplate:Clone()
  212.         Button.Parent = BackpackFrame:FindFirstChild(i)
  213.        
  214.         Button.Text = Children[i].Name
  215.        
  216.    
  217.         table.insert(Item_Slots, i, {Children[i].Name, Children[i].Value, Children[i].Number.Value})
  218.     end
  219. end
  220.  
  221. wait(2)
  222.  
  223. update()
  224.  
  225. UIS.InputBegan:Connect(function(input, gpe)
  226.     if gpe then return end
  227.    
  228.     for _,v in pairs(Item_Slots) do
  229.         if input.KeyCode == Enum.KeyCode[v[3]] then
  230.             if ItemEquipped == "" then
  231.                 print(v[1])
  232.                
  233.                 ItemEquipped = tostring(v[1])
  234.                 InventoryFunction:InvokeServer(tostring(v[1]), "", GetDesc:InvokeServer('GetType', tostring(v[1])), 'EquipDefaultItem')
  235.         elseif ItemEquipped == v[1] then
  236.                 ItemEquipped = ""
  237.                
  238.                 InventoryFunction:InvokeServer(tostring(v[1]), "", GetDesc:InvokeServer('GetType', tostring(v[1])), 'UnEquip')
  239.             else
  240.                 print"You must unequip your equipped item first."
  241.             end
  242.         end
  243.     end
  244. end)
  245.  
  246. -- Inventory Controller 4
  247.  
  248. local Players = game:GetService("Players")
  249. local Player = Players.LocalPlayer
  250. local Storage = game:GetService("ReplicatedStorage")
  251. local Mouse = Player:GetMouse()
  252.  
  253. local Events = Storage:WaitForChild("Events")
  254. local Event = Events:WaitForChild('CraftingEvent')
  255. local DescEvent = Events:WaitForChild('GetDescription')
  256.  
  257. local CraftableItems = Storage:WaitForChild('CraftableItems')
  258. local UIS = game:GetService("UserInputService")
  259. local UI = script.Parent
  260.  
  261. local MainFrame = UI:WaitForChild("MainFrame")
  262.  
  263. local Open = false
  264. local ItemChosen = ""
  265.  
  266. local Debounce = false
  267.  
  268. local Items = MainFrame:WaitForChild('Items')
  269. local Template = script:WaitForChild("Template")
  270.  
  271. local ItemInfo = MainFrame:WaitForChild('ItemInfo')
  272.  
  273. local CraftItem = ItemInfo:WaitForChild('Craft')
  274. local StatsTemplate = script:WaitForChild("StatsTemplate")
  275.  
  276. function displayInfo(name, description)
  277.     ItemInfo.ItemName.Text = name
  278.     ItemInfo.Description.Text = tostring(description)
  279.    
  280.     -- Add cost, etc later.
  281. end
  282.  
  283. function updateLeaderstats()
  284.     local Starter_Materials = DescEvent:InvokeServer("GetStarterMats")
  285.     local CurrentYPos = 0.297
  286.    
  287.     for name,value in pairs(Starter_Materials) do
  288.         warn(name, value)
  289.        
  290.         local Clone = StatsTemplate:Clone()
  291.         Clone.Name = name
  292.        
  293.         Clone.Text = name.. ": "..value
  294.         Clone.Position = UDim2.new(0.021,0,CurrentYPos+0.051,0)
  295.        
  296.         CurrentYPos = CurrentYPos + 0.051
  297.        
  298.         Clone.Parent = UI:WaitForChild("Stats")
  299.     end
  300. end
  301.  
  302. function update()
  303.     ItemChosen = ""
  304.     ItemInfo.ItemName.Text = "ItemName"
  305.     ItemInfo.Description.Text = "Description of item."
  306.    
  307.     for _,v in pairs(Items:GetChildren()) do
  308.         if v:IsA("TextButton") then
  309.             v:Destroy()
  310.         else
  311.             warn"Could not destroy GridLayout."
  312.         end
  313.     end
  314.    
  315.     for _,v in pairs(CraftableItems:GetChildren()) do
  316.         local Clone = Template:Clone()
  317.         Clone.Parent = Items
  318.         Clone.Text = v.Name
  319.        
  320.         Clone.Name = v.Name
  321.        
  322.         Clone.MouseButton1Click:Connect(function()
  323.             displayInfo(Clone.Name, DescEvent:InvokeServer('Desc', Clone.Name))
  324.             ItemChosen = Clone.Name
  325.         end)
  326.     end
  327. end
  328.  
  329. CraftItem.MouseButton1Click:Connect(function()
  330.     if ItemChosen == "" then warn"You have not selected an item." return end
  331.     if Debounce then return end
  332.    
  333.     Event:FireServer('CraftItem', ItemChosen)
  334.     Debounce = true
  335.     wait(1.5)
  336.     Debounce = false
  337. end)
  338.  
  339. Event.OnClientEvent:Connect(function(action, bool)
  340.     if action == 'Check' then
  341.         DescEvent:InvokeServer('CraftingReturn', '', bool)
  342.     end
  343. end)
  344.  
  345. UIS.InputBegan:Connect(function(input, gpe)
  346.     if gpe then return end
  347.    
  348.     if input.KeyCode == Enum.KeyCode.N then
  349.         if Open == false then
  350.             Open = true
  351.             MainFrame:TweenSizeAndPosition(UDim2.new(0.363,0,0.425,0), UDim2.new(0.248,0,0.286,0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 0.5, false)
  352.             update()
  353.         elseif Open == true then
  354.             Open = false
  355.             MainFrame:TweenSizeAndPosition(UDim2.new(0,0,0,0), UDim2.new(0.5,0,0.5,0), Enum.EasingDirection.Out, Enum.EasingStyle.Sine, 0.5, false)
  356.             update()
  357.         end
  358.     end
  359. end)
  360.  
  361. updateLeaderstats()
  362.  
  363. for _,v in pairs(game.Players.LocalPlayer:WaitForChild('Materials'):GetChildren()) do
  364.     v:GetPropertyChangedSignal('Value'):Connect(function()
  365.             for i,value in pairs(UI:WaitForChild("Stats"):GetChildren()) do
  366.                 if value.Name == v.Name then
  367.                     value.Text = v.Name.. ": "..v.Value
  368.                 end
  369.             end
  370.     end)
  371. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement