qbcore-framework / qb-core

FiveM RP Framework Core :muscle:
GNU General Public License v3.0
590 stars 960 forks source link

feat: remove usable item fn after stopped resource #1109

Closed Z3rio closed 3 days ago

Z3rio commented 5 months ago

Description

This PR aims to fix an error that can be recreated by trying to use an item after the resource which said item callback from is stopped.

Recreation:

And you'll see the following error:

[      script:qb-core] SCRIPT ERROR: citizen:/scripting/lua/scheduler.lua:479: attempt to concatenate a nil value (local 'err')
[      script:qb-core] > UseItem (@qb-inventory/server/functions.lua:167)
[      script:qb-core] > handler (@qb-inventory/server/main.lua:177)
[ script:qb-inventory] SCRIPT ERROR: error object is not a string

The way it fixes the error is by saving which resource the "useable item callback" is created by. And then listening for stopped resources and removing said "useable item callback" upon said resource being stopped.

Checklist

This needs to be merged alongside: https://github.com/qbcore-framework/qb-inventory/pull/519

github-actions[bot] commented 1 month ago

This PR has had 60 days of inactivity & will close within 7 days

Z3rio commented 1 month ago

This PR has had 60 days of inactivity & will close within 7 days

no thank you