AMP icon indicating copy to clipboard operation
AMP copied to clipboard

FR: Ability to set Upper and Lower limits for number-based settings within instance

Open southnode opened this issue 2 years ago • 20 comments

This is not for requesting support for new games/applications

To do this you should go to https://github.com/CubeCoders/AMPTemplates and first attempt to build a configuration yourself - otherwise you can request a template from this repo.

Feature Request

Ability to set Upper and Lower limits for number-based settings

Feature Information:

Utilising Squad as an example.

App.MaxUsers is the setting within GenericModule.kvp that specifies (and allows a user to change) the MAXPLAYERS setting within the server. The game is hard coded to allow 1-100 player slots in the config. Currently a user may set above 100 player slots. This obviously doesn't work, but from a UI perspective is flawed. There should be the ability to set an upper and lower limit to any setting that contains a number.

In addition, these upper and lower limits should be able to be referenced via a provisioning flag. ie. App.MaxUsersUpper and App.MaxUsersLower or however it's set. I believe in Squad it is set in the manifest as opposed to the kvp.

I confirm:

  • [x] that I have searched for an existing feature request matching the description.

southnode avatar Dec 25 '22 16:12 southnode

Chatting about this in discord, minValue and maxValue being an attribute of a setting is a thing, however given these are in the manifests and not in the kvp itself, you cannot set it via a provisioning flag.

southnode avatar Dec 25 '22 17:12 southnode

What we almost need is like

App.MaxUsers App.MaxUsers.maxValue App.MaxUsers.minValue

For example for Squad:

App.MaxUsers=20 App.MaxUsers.maxValue=100 App.MaxUsers.minValue=1

Would also require user feedback on the UI if this was exceeded.

southnode avatar Dec 25 '22 17:12 southnode

If it's a hardcoded limit for Squad, don't you just simply update the generic template for that server to specify MinValue and MaxValue for the users setting? The template would have been created before those were a thing in Generic. Newer templates have them as relevant (assuming the template creator has bothered to include them).

Submit a PR.

Greelan avatar Dec 26 '22 01:12 Greelan

We discussed in Discord that the lower limit is handled by MinValue but the max is the issue. You can't set a limit on deployment templates or limit your customers from going over a player count limit while still allowing them to edit it lower than that.

IceOfWraith avatar Dec 26 '22 02:12 IceOfWraith

MaxValue in configmanifest.json will achieve exactly what is needed for Squad. If the GitHub template is updated to include it, then it will apply to all instances, no need for any provisioning flag.

Greelan avatar Dec 26 '22 11:12 Greelan

That's fine for setting it static-ly, however it is unable to be set with a provisioning flag for enterprise customers who sell upper slot limits, like myself.

southnode avatar Dec 26 '22 11:12 southnode

I was commenting specifically on the Squad issue as described, not other use cases.

Greelan avatar Dec 26 '22 11:12 Greelan

Just a note, so it doesn't get overlooked... This applies to every instance type, not just generic.

IceOfWraith avatar Dec 28 '22 14:12 IceOfWraith

Setting up a UI to specify this might be hella tricky, because I'd actually do something like:

Module.Setting.Name::[Range:0,20] //A permission denoting an acceptable range of 0-20 for a given setting.

So one of the changes I may also have to make is a 'custom nodes' option at the bottom of the permissions UI to allow things like this to be set.

PhonicUK avatar Dec 28 '22 16:12 PhonicUK

Based on the discussion I think only the upper limit needs enforced for player count based hosters. The lower limit would be handled by MinValue in generic at least.

IceOfWraith avatar Dec 28 '22 16:12 IceOfWraith

Doing it just for Player Count is not too hard at all, but has to be implemented on a per-module basis. The Minecraft module has this already as a holdover from MCMA2.

I would prefer though a more general purpose way of letting admins say "Users can set this value to between X and Y" for other reasons. You don't necessarily want users setting things like tick rates too high or too low.

PhonicUK avatar Jan 11 '23 16:01 PhonicUK

Maybe it's time to port some settings over to a UniversalSettings module. Lol

IceOfWraith avatar Jan 11 '23 17:01 IceOfWraith

@PhonicUK so long as it's accessible in the GenericModule.kvp (and thereby accessible to a WHMCS provisioning flag) that will work a treat. The main thing is here 2-fold:

  1. Admins can, at this point in time, set a variable to a number that the server will not recognise (for example, setting the player count too high, or to a negative number)
  2. Enterprise users can, at this point in time, go above the MaxPlayers/MaxUsers setting that originally gets provisioned for their instance (for example, a user can buy a package utilising the Generic Module for 50 slots, but after the fact can set their slot count to anything they want, even if its above the 50 slot maximum that they purchased)

Having the MaxPlayers exposed as a variable they can change, but the MinValue and MaxValue be in the kvp would work a treat.

southnode avatar Jan 11 '23 17:01 southnode

To clarify, the MinValue is in the config.json file for generic. And as you saw, is implemented across the board for all generics now. So only the MaxValue needs addressed as a separate limit. Then it needs to be limited by the MaxValue in the config.json AND provisioned by WHMCS.

IceOfWraith avatar Jan 11 '23 17:01 IceOfWraith

This is right @IceOfWraith which is awesome that it's in there - just at present the config.json is not provision-able by WHMCS as far as I'm aware. Hence why I suggested it be in the KVP.

southnode avatar Jan 11 '23 17:01 southnode

So I've got a prototype implementation for now, but it's a bit limited in some ways, but I suspect this will suffice for 90% of use cases?

There's two new settings - NumericValueNodeUpperLimits and NumericValueNodeLowerLimits that are part of AMPs core configuration. They're dictionaries of Node:Value - for example you could set:

Limits.NumericValueNodeUpperLimits={"GenericModule.App.MaxUsers": 10}

The reason for doing it this way is it requires no special implementation on individual modules, it'll work for any module regardless of the type of configuration used - hard coded or meta.

There's also a separate special permission to bypass these limits. The limiting factor is there's no way to say "This group has these limits, this group has these limits" - it's all or nothing.

I invite comments.

PhonicUK avatar Apr 22 '23 11:04 PhonicUK

Trying to wrap my head around this one. It sounds useful in the sense it will be setting agnostic. But how would it look for a deployment? (AKA Arc's use-case) Would he need to set it to a different value depending on the module type? I believe we have MaxUsers properly set across all generic instances, but trying to determine what's the full picture.

IceOfWraith avatar Apr 22 '23 14:04 IceOfWraith

Yes, it'd be module specific. I could also add the setting to Generic separately so people have the choice given that most apps are moving over to Generic as a rule.

What I want to do in the future (with very few exceptions such as Minecraft) is remove game specific modules altogether and have game-specific coded functions be plugins.

PhonicUK avatar Apr 23 '23 12:04 PhonicUK

The main thing Ice would be getting at with my use case is the ability to set it as a provisioning flag. Can that be done with this implementation?

southnode avatar Apr 23 '23 12:04 southnode

Yes, it's just another setting - all settings can have their value set via provisioning flags.

PhonicUK avatar Apr 24 '23 16:04 PhonicUK

This was tested as working in a WHMCS deployment.

Core.Limits.NumericValueNodeLowerLimits.$Meta.GenericModule.$MaxUsers

IceOfWraith avatar Jul 30 '24 06:07 IceOfWraith