Help coding an inventory system

The inventory system I have in mind is sort of the system TF2 uses, where you can drag items around the backpack and where you can drag it into a crafting area. In this case drag items around the derma/panel and drop it into a box.

But for now I want to learn how to code a simple, obtain an item via a function (so I can have it included into a store, or via a console command, etc.) system for my gamemode. Last resort for me is to use someone else’s inventory system, and I guess it’ll be better for me to learn how to than just copy paste.

I already got the layout of the inventory, I just need a bit of help coding the actual system, and the dragging the icon around and dropping. I know theres some limitations to LUA, but I guess I can give it a shot.

Whats best is to have the server save the inventory for each player in a file using util.TableToKeyValues and file.Write. To load the actual items is a bit tricky, and for a good inventory requires an individual file for each item. Each of the items would have to be included by the inventory system then the file calls a function to add the item defined in the file to the list in your inventory system. Then you can use concommands and usermessages to send what items each player has and if they are adding or removing and item, or using it.

I use glon to encode my table to a txt file then glon decode to get it back and send it to the client via usermessages.