Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Inventory Service
- -- Quoteory
- -- September 12, 2019
- --[[
- Server:
- Client:
- --]]
- local IDList
- local random = Random.new()
- local randomMin, randomMax = 100, 99999
- local InventoryService = {Client = {}}
- function InventoryService.getRandomNumber()
- return random:NextInteger(randomMin, randomMax)
- end
- function InventoryService:GetUniqueSerial(Inventory)
- local armors = Inventory["Armors"]
- local weapons = Inventory["Weapons"]
- local uniqueSerial
- local function recursion()
- uniqueSerial = self.getRandomNumber()
- if armors[uniqueSerial] or weapons[uniqueSerial] then
- recursion()
- end
- end
- recursion()
- return uniqueSerial
- end
- function InventoryService:GetOwnedItem(Inventory, Serial)
- local armors = Inventory["Armors"]
- local weapons = Inventory["Weapons"]
- local armorGet = armors[Serial]
- local weaponGet = weapons[Serial]
- if weaponGet then
- return weapons, weaponGet
- elseif armorGet then
- return armors, armorGet
- end
- end
- function InventoryService:AddItem(Inventory, ID)
- local armors = Inventory["Armors"]
- local weapons = Inventory["Weapons"]
- local item = IDList[ID]
- if not item then return end
- if item.Type == "Weapon" then
- weapons[self:GetUniqueSerial(Inventory)] = {ID = ID, Quantity = 1}
- print("Added item")
- else
- print("Not weapon type")
- end
- end
- function InventoryService:RemoveItem(Inventory, Serial)
- local itemInventory, item = self:GetOwnedItem(Inventory, Serial)
- if itemInventory and item then
- itemInventory[Serial] = nil
- print("Removed " .. Serial)
- end
- end
- function InventoryService:Start()
- end
- function InventoryService:Init()
- IDList = self.Shared.IDList
- end
- return InventoryService
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement