Expiration Date/Item Degradation

so I want to add a item degradation function, problem is I don’t have any ideas on how to go about introducing a new date variable for every specific item in an optimized way.

lets say the player buys 2 breads day 1 and 3 breads day 2
how do I store the data in such a way that I can differentiate between the two and expire the first bunch.

You could store the Epoch ms or something when he gets the item and have a cronjob run at every minute or something to check if current epoch > item.epoch + x

ye the issue is if I were to set a date for every item he receives, the database would soon get so heavy that it might cause issues for the server, I want an optimized way.
lets say 100 players all buy 10 breads a day, thats 1000 different database entries just for the item bread in 1 day.

How would it get “so full”? Do you have 1 million+ players a day or something? Also don’t store date, do it with epoch ms.

I think the new Ox Inventory, currently in development, will have this sort of feature. Check it out. You’ll need to do some serious work on your ESX server, however. There are a few dependencies and some editing to do before you can use the new inventory system.

1 Like

the reason NoPixel added item degradation in the first place was because their items database was getting huge. IG a way to fix this (it also has some drawbacks, but this is what I do) is by not making a new database entry for each item, but instead just make one for each inventory. The problem with this is though, the logic will be more complicated, you are kinda doing what relational databases were made to fix, and there will also be more room for error for accidently making duplication glitches if you don’t write clean code with good logic and sanity checks

1 Like