Skip to content
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: allow resources to retrieve the invoking resource of commands #3012

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Mycroft-Studios
Copy link

Goal of this PR

The goal of this PR is quite simple: allow resources to see which resource, registered which command.
This goal, was mainly sparked by a suggestion in txAdmin:

In txAdmin menu, under Resources tab, It would be useful to view all the registered commands under each script in a dropdown

How is this PR achieving the goal

This PR achieves this by:

  • storing the invoking resource from REGISTER_COMMAND in the Command Object
  • Allowing that data to be accessed from the existing native: GetRegisteredCommands
  • Adds a Brand new Native: GET_RESOURCE_COMMANDS, that allows resources to retrieve the command list, from specific resources, allowing for much cleaner code.
  • All internal commands, such as convars, are marked as internal for the resource.

This PR applies to the following area(s)

FiveM, RedM, Server, Natives

Successfully tested on

Platforms: Windows

Checklist

  • Code compiles and has been tested successfully.
  • Code explains itself well and/or is documented.
  • My commit message explains what the changes do and what they are for.
  • No extra compilation warnings are added by these changes.

@github-actions github-actions bot added the RedM Issues/PRs related to RedM label Dec 17, 2024
@Mycroft-Studios Mycroft-Studios changed the title feat: allow invoking resource for commands, to be read feat: allow resources to retrieve the invoking resource of commands Dec 17, 2024
@github-actions github-actions bot added triage Needs a preliminary assessment to determine the urgency and required action invalid Requires changes before it's considered valid and can be (re)triaged and removed triage Needs a preliminary assessment to determine the urgency and required action labels Dec 17, 2024
@prikolium-cfx prikolium-cfx added enhancement Feature or other request that adds functionality or improved usability and removed invalid Requires changes before it's considered valid and can be (re)triaged RedM Issues/PRs related to RedM labels Jan 10, 2025
@github-actions github-actions bot added the invalid Requires changes before it's considered valid and can be (re)triaged label Jan 10, 2025
@prikolium-cfx
Copy link
Collaborator

Thanks. And as a last step could you please squash your commits into one

…_COMMANDS

formatting(citicore/console): spaces instead of tab

fix(citicore/console/Console.Commands.h): typo in template

formatting(citicore): fix formatting from command commits

tweak(citcore/console): improve function naming

adjusted `getResource` to `GetResourceName` and `fromResource` to `MatchResourceName`

fix(native-decls): GetRegisteredCommands showing wrong example data

fix(citcore/console/CommandHelpers): correct issues from git push

for some reason, pushing this change did some weird formatting

tweak(native-decls): Adjust GET_REGISTERED_COMMANDS to show the correct data

feat(native-decls): Add GET_RESOURCE_COMMANDS native

This native allows resources to find commands registered by a specific resource

feat(citizen-scripting-core): define resource in Command Object
@Mycroft-Studios Mycroft-Studios force-pushed the add-resource-to-commands branch from 2ad5d20 to 27acc57 Compare January 10, 2025 14:58
@github-actions github-actions bot added the RedM Issues/PRs related to RedM label Jan 10, 2025
@Mycroft-Studios
Copy link
Author

Done :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature or other request that adds functionality or improved usability invalid Requires changes before it's considered valid and can be (re)triaged RedM Issues/PRs related to RedM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants