Just a few things from a brief look at the new code:Note that I have implemented a block so that if an item has a custom 'owner' attribute, it cannot be moved to the ground or the trash. Items inside a backpack with the custom 'owner' attribute also cannot be moved along with the backpack. If the backpack contains normal items without the custom 'ownerGuid' attribute, it can be moved normally. Additionally, I have added a check to prevent these items from being moved to the depot. This should resolve all the issues.
View attachment 84992
See another quick GIF: one item was rented and is using the custom attribute 'ownerGuid', and another item is normal and not using the custom attribute 'ownerGuid'.
View attachment 84993
Check when the client player logs out and stays offline for some time. The item should be able to return to the owner
View attachment 85020
When both the player client and the owner are offline, the system should be able to verify and return the original item to the owner's depot. This is working correctly
View attachment 85021
I've already updated the file there. Just download and review the script. If someone can look at it and correct any optimizations needed, let me know, and I'll try to fix it. I would appreciate any help as I'm still learning TFS 1.x. xD.
I tested with the player client dying multiple times, and the item returned to the owner normally. I also set up the database to store the rental item and handle real-time expiration, removing the item directly from the database both offline and online normally.
1) Move containsCustomOwner outside of the callback, there is no need to re-define this function everytime the event callback is executed.
2) This recursion now happens everytime someone moves any item in the game. As I suggested earlier, it's better to only execute this whole callback for players that have rented an item. On login (if an active rental is assigned via the new rental db table), or when an item is rented, register an event to the player, and check if this event is present in the onMoveItem. This will minimise the amount of recursion checks being made.
I'll check it out more in detail tomorrow (it's very late here right now)