Disabling chat?

Post Reply
Legoracer
New member
Posts: 3
Joined: Tue Oct 08, 2019 21:59
GitHub: Legoracer
In-game: Legoracer

Disabling chat?

by Legoracer » Post

(I'm new to these forums, so I apologize if I posted in wrong category)

Hello,
I've been looking at the documentation for the past hour and can't seem to find anything that could be used to disable or edit the chat/command/console ("/" key).

Is this possible or is it currently past the possibilities of the engine?
Thanks!

User avatar
Krock
Developer
Posts: 4571
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: Disabling chat?

by Krock » Post

Restrict all server commands to server admins only:

Code: Select all

local priv_required = "server

for cmd, def in pairs(minetest.registered_chatcommands) do
	def.privs[priv_required] = true
end
Disable chatting ("/me" inclusive) entirely -> same as /revoke <player> shout

Code: Select all

minetest.register_on_joinplayer(function(player)
	local auth = minetest.get_auth_handler()
	local player_name = player:get_player_name()
	local player_auth = auth.get_auth(player_name)

	player_auth.privileges.shout = nil

	auth.set_privileges(player_name, player_auth.privileges)
end)
Untested code.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

micheal65536
Member
Posts: 167
Joined: Mon May 22, 2017 20:27

Re: Disabling chat?

by micheal65536 » Post

Krock wrote:Restrict all server commands to server admins only:

Code: Select all

local priv_required = "server

for cmd, def in pairs(minetest.registered_chatcommands) do
	def.privs[priv_required] = true
end
You're missing a quote at the end of the first line so this will fail with a syntax error. Also you'd need to make sure that this code runs after all the commands have been registered, so ideally after all other mods have loaded (minetest really still needs a way to do this elegantly...). Not to mention that you should probably be using minetest.override_chatcommand.

The other snippets looks good to me though (although I'm not familiar with the authentication API so I might be missing something).

User avatar
Linuxdirk
Member
Posts: 2666
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

Re: Disabling chat?

by Linuxdirk » Post

Why was the topic created two times?

viewtopic.php?t=23461

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests