multitheftauto / mtasa-resources

This project maintains a list of up-to-date resources that come with Multi Theft Auto.
https://multitheftauto.com
MIT License
151 stars 149 forks source link

Remove or load admin_definitions.lua #455

Closed Dark-Dragon closed 7 months ago

Dark-Dragon commented 9 months ago

Which resource(s) have this problem? admin

Describe the bug admin_definitions.lua is not in the meta.xml and is therefore never loaded. Now currently the admin resource seems to only have minor issues without it, but having the file around but not loading it causes confusion. For instance #440 didn't properly fix #373, because it assumed the file was loaded.

It should therefore be decided whether the file can be safely removed (I think it's only essential in the admin2 resource) or implemented properly. At the very least the ADMIN_CHAT_MAXLENGTH global variable needs to be set elsewhere if the file is deemed redundant.

To Reproduce

  1. start admin
  2. see debug warning relating to ADMIN_CHAT_MAXLENGTH being nil
  3. find out it makes sense because the file which defines it is never loaded

Version Client/Server 1.6 admin 1.5.9 (latest at the time of post despite version discrepancy)

ricksterhd123 commented 9 months ago

Looking back on this, in hindsight you could remove the ADMIN_CHAT_MAXLENGTH server-side completely and keep it client-side only since it's really only relevant in the GUI, e.g.

https://github.com/multitheftauto/mtasa-resources/blob/c4bc73a2b088b98116ece27065cc7f5a1dced15b/%5Badmin%5D/admin/server/admin_server.lua#L1611-L1622

This event is triggered in two places, command handler: https://github.com/multitheftauto/mtasa-resources/blob/c4bc73a2b088b98116ece27065cc7f5a1dced15b/%5Badmin%5D/admin/server/admin_server.lua#L1624-L1630

client-side: https://github.com/multitheftauto/mtasa-resources/blob/c4bc73a2b088b98116ece27065cc7f5a1dced15b/%5Badmin%5D/admin/client/gui/admin_main.lua#L1145-L1155

I believe the chat already has an upper limit of how many characters you can input so all we need to do is set this client-side to ensure the chat editbox doesn't exceed max limit here: https://github.com/multitheftauto/mtasa-resources/blob/c4bc73a2b088b98116ece27065cc7f5a1dced15b/%5Badmin%5D/admin/client/gui/admin_main.lua#L331

Dark-Dragon commented 9 months ago

It should be all good for chat, but console input is a maximum of 255, which with a prior 'aAdminChat ' would still allow for 244 characters. So it unfortunately still surpasses the limit of 225 brought up in #440.

jlillis commented 9 months ago

I have a fix for this in mind and will try to get it out this coming weekend.