-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(resources-metadata): Set servername convar as global #3008
base: master
Are you sure you want to change the base?
Conversation
Maybe just do a method that returns the game name instead of allowing ConVar reads inside the meta data loader? |
That's good too, but ConVar reads let us filter files dynamically per server, like |
But it's true that in reality we only need two variables. And I don't see the use of other variables. |
Yes, then add the server name and game name as two methods and then it should be fine. Don't really see the need allowing to read any existing ConVar here. |
If To illustrate the use case, imagine a resource with an export API and some UI. If the UI is optional, you could use a ConVar to avoid loading all the UI-related files. |
I would not recommend to build any logic in fxmanifest.lua. At some point we plan to move to declarative fxmanifest and it means that you won't be able to execute code there. |
And it's not possible to have this pr until you release the v3 of the fxmanifest? |
For sure it's possible. But probably it's possible to satisfy your need in more declarative way. For example you can add optional argument to server_script function and pass game name to it or something like this. In that case this feature can be transferred to the next fxmanifest version So it will look like
|
Wouldn't it be better to split it to two resources at that point? One for rdr and one for gta. |
Unfortunately, this isn't a solution for us, splitting the code would force us to maintain the same code twice. To illustrate, here's a breakdown of the line count for our single resource. And excluding GTA5, we still have 160,643 lines of code:
But the idea from Prikolium also seems like a good one, especially if it seems more coherent for the next version |
I'm big time against needing to execute lua to get the resource metadata, which might be fine for fxserver, but any other codebase (such as txAdmin or Cfx backends) that wants to read it properly will then need to evaluate lua code. But the need for game-specific definitions is valid. In monitor/txAdmin, I also want to be able to have different manifest directives depending on the game name. |
Goal of this PR
This PR serves more as a proof of concept than ready-to-merge code. It introduces functionality to dynamically load files based on a defined ConVar.
For context, our base is compatible with both RDR3 and GTA5, as well as multiple servers. To separate files, we currently use file headers with return conditions (example screenshot).
With this functionality, we can, for instance, load only the files in the
gta5
folder when thegamename
variable is set togta5
.Here is an example of a resource that takes advantage of this new functionality:
fxmanifest:
How is this PR achieving the goal
This PR achieves its goal by adding a GetConvar function in the fxmanifest. The function takes two parameters:
Using this function allows conditional logic to determine which files are loaded. This approach simplifies the management of multiple game environments and servers.
This PR applies to the following area(s)
Server on the resources load
Successfully tested on
Custom server build
Game builds: tested on 3095 but should work on any
Platforms: Windows
Checklist
Fixes issues
not related to any issues
NOTE: I am fully open to making changes as needed. I am also ready to update the documentation.