multitheftauto / mtasa-blue

Multi Theft Auto is a game engine that incorporates an extendable network play element into a proprietary commercial single-player game.
https://multitheftauto.com
GNU General Public License v3.0
1.38k stars 424 forks source link

AddCommandHandler problem #418

Open CrosRoad95 opened 6 years ago

CrosRoad95 commented 6 years ago

Describe the bug If you trying to add command example for showmemstat command, addCommandHandler returning true even command isn't added.

To Reproduce clientside

created = addCommandHandler("showmemstat", function()
  outputChatBox( "showmemstat working?") -- will never displayed
end)
outputChatBox( tostring(created) ) -- true

if you execute command showmemstat, only mem stat window appear.

Expected behavior Should return false for some exeptions

Screenshots

MTA Client (please complete the following information): Multi Theft Auto v1.5.5-release-13968

MTA Server (please complete the following information): MTA:SA Server v1.5.5-release-11751

Additional context

qaisjp commented 6 years ago

Low priority but returning false seems reasonable.

Can you give an example of why this might be useful? Most people don't check the return value of addCommandHandler but I agree it should not return true if it wasn't a success.

qaisjp commented 6 years ago

This is also not implementable server-side as the server doesn't know what client commands there are.

CrosRoad95 commented 6 years ago

the server doesn't know what client commands there are. know, you can make blacklist for client and server with showmemstat and other functions

qaisjp commented 6 years ago

that's not really a clean solution imo

znvjder commented 6 years ago

servers shouldn't apply. It's enough for client to prepare a table with commands available to client and omit them (return false). Its my solution.