Project-Sloth / ps-housing

Advanced housing system for QBCore.
https://discord.gg/projectsloth
Other
343 stars 110 forks source link

Moving Owned Objects & Exiting Shell Cleanup (fixes) #185

Closed bruceswork closed 9 months ago

bruceswork commented 9 months ago

i don't have time to do a pull request and provide videos but i wanted to provide some solutions to these issues I came up with. (using latest build as of today)

issue 1: Moving Owned Objects client -> modeler.lua

if you try to move an owned item and hit 'stop placerment' youll notice it vanishes.

cause - in the UpdateFurniture method its deleting the item.entity and then trying to refrence it to set the newPos and newRot coordinates.

my fix was to set newPos and newRot from item.entity prior to deleting it

issue 2: Full cleanup when exiting property

client -> cl_property.lua - > UnloadFurnitures if you test this go into your apartment, leave then go into another players apartment you will notice some of your items remain in the players apartment.

cause - Self.UnloadFurniture is being called and cleaning up (removing items) from the self.furnitureObjs table causing the iteration over Property.UnloadFurnitures to have nil items.

my fix was to get rid of the table.remove cleanup in the self.UnloadFurniture method around lines 503

since Property.UnloadFurnitures already clears the array after its done iterating things will still be cleaned up.

hopefully this helps someone and I will do a pull request when I have more time

these changes were tested and made by me still trying to go through the framework to determine if this has cause anything to break but so far so good

MonkeyWhisper commented 9 months ago

Thank you very much, will wait for your PR if you decide to send one.