Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function inventory:client_updateSlot(i,id,amt)
- --print("sending")
- Event:FireClient(self.plyr,"UPDATESLOT",i,id,amt)
- end
- function inventory:client_updateSize(size)
- end
- function inventory:client_getContents()
- return self.slots
- end
- function inventory.new(plyr)
- local i = {}
- setmetatable(i,inventory)
- i.plyr = plyr
- i.slots = {}
- i.size = 10 -- number of slots
- return i
- end
- -- way to interact with all player inventories for all server
- inventoryHandler = {}
- -- inventory handler data
- inventoryHandler.PlayerInventories = {}
- -- inventory handler functions
- function inventoryHandler:GetInventory(plyr)
- return self.PlayerInventories[plyr] or warn("Could not find inventory for player upon server request")
- end
- function inventoryHandler:GiveClientContents(plyr)
- local inventory = self:GetInventory(plyr)
- if inventory then
- return inventory.slots
- end
- end
- function inventoryHandler:GiveClientInfo(plyr)
- local inventory = self:GetInventory(plyr)
- if inventory then
- return inventory.slots,inventory.size
- end
- end
- function inventoryHandler:NewPlayer(plyr)
- local i = inventory.new(plyr)
- self.PlayerInventories[plyr] = i
- return i
- end
- function inventoryHandler:RemovePlayer(plyr)
- self.PlayerInventories[plyr] = nil
- end
- function inventoryHandler.FunctionInvoke(plyr,req)
- print("invoked")
- if req == "REQCONTENT" then
- return inventoryHandler:GiveClientContents(plyr)
- elseif req == "REQINFO" then
- return inventoryHandler:GiveClientInfo(plyr)
- end
- end
- function inventoryHandler:RemoteInit()
- Function.OnServerInvoke = self.FunctionInvoke
- end
- return inventoryHandler
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement