Compare commits

...

2 Commits

Author SHA1 Message Date
iliekprogrammar 08e2daefb9 Merge branch 'master' into csm-enabled 2022-12-31 05:52:22 +00:00
AFCMS 3ec2d17641
Add `mcl_player_csm` mod to check if a player have the official CSM enabled 2022-12-09 23:22:50 +01:00
2 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,37 @@
mcl_player_csm = {}
---@type table<string, boolean>
local activated = {}
---Return whatever player with specified name have official CSM enabled
---@param name string
---@return boolean? # `nil` if player not found, boolean overwise
function mcl_player_csm.is_enabled(name)
return activated[name]
end
minetest.mod_channel_join("mcl_player_csm:activate")
minetest.register_on_modchannel_message(function(channel_name, sender, message)
if channel_name == "mcl_player_csm:activate" and message == "activated" then
activated[sender] = true
end
end)
minetest.register_on_joinplayer(function(player, last_login)
activated[player:get_player_name()] = false
end)
minetest.register_on_leaveplayer(function(player, timed_out)
activated[player:get_player_name()] = nil
end)
minetest.register_chatcommand("have_csm", {
description = "Show whatever player have official CSM enabled",
params = "[<name>]",
privs = {debug = true},
func = function(name, param)
local pname = param ~= "" and param or name
return true, "Player [" .. pname .. "]: " .. tostring(activated[pname])
end
})

View File

@ -0,0 +1,5 @@
name = mcl_player_csm
description =
depends =
optional_depends =
author = AFCM