Blumlaut / EasyAdmin

Admin Menu for FiveM and RedM
https://easyadmin.readthedocs.io/
GNU Affero General Public License v3.0
170 stars 157 forks source link

Feature Request: Allow plugins to be separate resources #831

Open sn8to opened 7 months ago

sn8to commented 7 months ago

Is your feature request related to a problem? Please describe. EasyAdmin has a pretty good plugin system that allows easily adding custom functionality, however these plugins have to be included within the EasyAdmin resource plugins folder. This prevents plugin authors from creating escrowed plugins, or implementing external dependencies within the plugin without modifying EasyAdmin's fxmanifest.lua

Describe the solution you'd like Allow plugins to be registered and called from other resources. I think this is as simple as adding addPlugin to exports, but FiveM might throw a fit about passing functions around like that.

Describe alternatives you've considered

Blumlaut commented 7 months ago

I think this is as simple as adding addPlugin to exports

passing functions between resources does not work, as resources are contained and funcrefs from resource A dont exist on resource B, without either passing sourcecode around (ew!) or using a mess of events (also ew, plus timing problems!) i dont think this can really be implemented.

  • Don't create escrowed resources

is the only "real" solution for now

sn8to commented 7 months ago

This is a pretty bad idea, I don't like it much, but I guess it would work? Maybe??

Provide an export to register an external plugin, EasyAdmin can use exports from the resource to register the plugin's functions. This would allow functions from other resources to be called, without using events and introducing timing/latency problems.

Something like this?

exports('registerPlugin', function(resourceName)
    -- init the plugin using export[resourceName]:mainMenu(), etc.
end)

But I have a feeling similar issues come up when trying to pcall an exported function... Lua is fun

Blumlaut commented 5 months ago

IIRC i was experimenting with exports before but as always there are timing and/or scope problems, you cant easily pass the scope around so all of it is kinda yucky and introduces fun race conditions..