-
-
Notifications
You must be signed in to change notification settings - Fork 438
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
Add new mtaserver.conf rules for server browser/list #3761
base: master
Are you sure you want to change the base?
Add new mtaserver.conf rules for server browser/list #3761
Conversation
As I showed on Discord, example output of a server's ASE using https://github.com/opengsq/opengsq-python that @botder suggested : opengsq ase --host 127.0.0.1 --port 22126 {"game_name": "mta", "game_port": 22003, "hostname": "Default MTA Server", "game_type": "play", "map": "None", "version": "1.6", "password": false, "num_players": 0, "max_players": 32, "rules": {"languages": "en", "tags": "roleplay,rp,serious", "logo_url": "https://www.example.com/logo.png"}, "players": []} We can set any key-value pair information, and work with this. |
Add social media?
url should be a resource on this server only, therefore you put If possible, add size of potentially downloaded files. |
Social media links are a great addition! I don't think that in a first version, we will have servers serving the media files themselves. This is plenty of work imo 😅 External urls is an alright solution, and it could accept only upload.mtasa.com for now |
The number of resources and names are displayed in the FiveM server list. I wouldn't consider this useful for MTA players, but it could be used for statistics and for example resource authors could see how often their resources are used. |
I absolutely agree with showing the download size of the resources. I imagine it's a value that's already calculated by the server, it would be a matter of announcing it to the server browser |
Resource display would have to to be filtered by resource type though. FFS got over 20k map resources. This will be an issue if you try to display them all :mreow: |
Are all those 20k resources with state "loaded"? 😳 |
loaded, not running. |
The server probably should only make a list of the resources that are running, for such a feature that would show them in the server browser. |
I think if you want to have this with the number of resources and names you should do it separately. I guess for the server browser it has no real relevance but only for statistical purposes. |
Added social urls, removed icon/banner image URLs for now. This is not a necessery feature yet |
Is Facebook really still relevant today? |
Haha who cares, the Facebook comment in "e.g." is just a suggestion. I added 3 social URLs that can be filled with any URLs that servers desire, MTA server browser could allow only certain domains (e.g. discord, youtube, twitch, vk.com, etc). My idea is to draw these Social URLs in a panel that displays server info when the server is selected. |
Reminder that setRuleValue gives servers the freedom of setting any values for any keys, without any validation. It can remain like that. The server browser UI will be responsible for the sanitization of data, and choosing what to display in the client. |
Perhaps it should be documented how many characters may be used for each rule. I think this would be particularly relevant for " |
The current implementation in c++ (setRuleValue) limits key/value strings to 200 characters:
I have documented this limit in the wiki now |
I made the server load the rules defined in mtaserver.conf into the ASE, applying the same method that Lua function setRuleValue uses. Result successful: opengsq ase --host 127.0.0.1 --port 22126 {"game_name": "mta", "game_port": 22003, "hostname": "Default MTA Server", "game_type": "play", "map": "None", "version": "1.6n", "password": false, "num_players": 0, "max_players": 32, "rules": {"description": "This is my awesome test server", "languages": "pt-br,en", "social1_url": "https://discord.gg/mtasa", "tags": "roleplay,serious,textrp", "website_url": "https://example.com"}, "players": []} The rules applied are returned in the 22126 udp result |
Accepting reviews, as I've written c++ code to make the rules load into the ASE on startup, concluding this feature IMO |
All ok |
Review requested once again as I've edited |
if (tempNode->GetTagName() == templateNodeTagName) | ||
{ | ||
bool bAttributesMatch = true; | ||
CXMLAttributes& attributes = tempNode->GetAttributes(); | ||
for (auto it3 = templateAttributes.ListBegin(); it3 != templateAttributes.ListEnd(); ++it3) | ||
{ | ||
CXMLAttribute* templateAttribute = *it3; | ||
const SString& strKey = templateAttribute->GetName(); | ||
const SString& strValue = templateAttribute->GetValue(); | ||
CXMLAttribute* foundAttribute = attributes.Find(strKey); | ||
if (!foundAttribute || foundAttribute->GetValue() != strValue) | ||
{ | ||
bAttributesMatch = false; | ||
break; | ||
} | ||
} | ||
if (bAttributesMatch) | ||
{ | ||
foundNode = tempNode; | ||
break; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use early continue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no early continue practice. Leave previous variant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no early continue practice. Leave previous variant.
Yes there is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes there is.
Prove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's
early-returns
and notearly continue
My friend, look below that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's your own rule, lol (added 3 weeks ago)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's your own rule, lol
Its been merged nonetheless. If you have any issues, please post them at mtasa-docs repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It changes almost nothing in terms of readability tbh. But ye it was approved
In this pull request you just extending what ase is returning, visual aspects in main menu to display it will be in another pull request? |
I don't even extend what ase is returning. This pr just adds a feature to mtaserver.conf for setting "rules" on startup (like using setRuleValue) which are settings for the server browser (old feature unused). Visual edits to the server browser to start using these "rules" will be made later. |
In preparation of #759, #998 and #2104
MTA servers use ASE protocol to respond with server information (name, player count, max players, server rules, etc).
In particular, server rules are key-value pairs that can be set using setRuleValue. These are already provided in servers' ASE responses.
https://int64.org/docs/gamestat-protocols/ase.html
My idea was to allow definition of key-value rule pairs in the mtaserver.conf file.
<rule>
entries:Then the server browser should read these values and act accordingly, thanks to a UI revamp (FUTURE - Another PR).
Pros of this method: