Skip to content

feat/fix: addon permissions/updating outdated function#610

Open
RickyB505 wants to merge 3 commits intoTomGrobbe:developmentfrom
RickyB505:development
Open

feat/fix: addon permissions/updating outdated function#610
RickyB505 wants to merge 3 commits intoTomGrobbe:developmentfrom
RickyB505:development

Conversation

@RickyB505
Copy link
Copy Markdown
Contributor

added individual permissions to addon vehicles/weapons/peds, and added a whitelist to regular vehicles/ped. changed (uint)GetHashKey() to Game.GenerateHashASCII() for better optimization

added individual permissions to addon vehicles/weapons/peds, and added a whitelist to regular vehicles/ped.  changed (uint)GetHashKey() to Game.GenerateHashASCII() for better optimization
{
public static class AddonPermissionsManager
{
public static List<string> Permission = new()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One issue I see that might come up is the names of these permissions. Other than that LGTM

Copy link
Copy Markdown
Contributor Author

@RickyB505 RickyB505 Apr 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't be any issue none of them collide with default permissions

Comment thread vMenuServer/MainServer.cs Outdated
}
else
{
// Setup addon permissions
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: This comment should be removed or actualy code should be added ;)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh that i forgot to remove oops

Comment thread vMenuServer/config/addons.json Outdated
Comment thread vMenuServer/MainServer.cs Outdated
#region Utilities
private void SetupAddonPerms()
{
Dictionary<string, List<string>> addons = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(LoadResourceFile(GetCurrentResourceName(), "config/addons.json") ?? "{}");
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be best if the config/addons file was only loaded once, instead of multiple times and deserialized multiple times. Somewhere above in the code it's already being loaded once. Please make a field on the class that can be reused.
Also, not sure if it matters, but maybe using Path.Combine would be preferred for Linux/Windows differences. Although I'm not sure how LoadResourceFile even deals with this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is basically the same method used through out the menu i just shortened it to 1 line from 2

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and it should only be called once on restart/startup its why i didn't make it a field but i can adjust that for you

Comment thread vMenuServer/MainServer.cs Outdated
addonPermissions.Add("add_ace builtin.everyone \"" + AddonPermissionsManager.GetAceName(permission) + "\" allow");
}

System.IO.File.WriteAllLines(GetResourcePath(GetCurrentResourceName()) + "/AddonPermissionsTemplate.cfg", addonPermissions.ToArray());
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for? And does it need to happen every time?
And maybe since we're using LoadResourceFile, this should be kept as SaveResourceFile?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're going to make a template file, I'd suggest that you also include some information at the top of the file explaining what it is, what people should do with it, and that they probably shouldn't touch the file itself because that seems to get overwritten each time. Just so we don't confuse people who attempt to edit it and then execute it or something.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i didn't use SaveResourceFile because this preformatted it into a clean file but if you want me to replace it i can, also good call i should have added a comment to the top ill change that now

Copy link
Copy Markdown
Owner

@TomGrobbe TomGrobbe Apr 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed in Discord, fine to keep like this. Only thing I'm worried about is the hardcoded /, I'd rather you use Path.Combine. Just cause servers can be on linux and windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants