Skip to content
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

improve spectator #62

Merged
merged 9 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions spectator_mode/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,17 @@ minetest.register_on_leaveplayer(function(player)
end
end)

minetest.register_on_joinplayer(function(player)
if not minetest.check_player_privs(player:get_player_name(), { spectate = true }) then
return
local function join_player(player)
local old_join_part = irc.send_join_part
if minetest.check_player_privs(player:get_player_name(), { spectate = true }) and irc.send_join_part == true then
hide_player(player)
irc.send_join_part = false
olliy1or marked this conversation as resolved.
Show resolved Hide resolved

minetest.after(0, function() irc.send_join_part = old_join_part end)
end
end

hide_player(player)
end)
table.insert(minetest.registered_on_joinplayers, 1, join_player)

local old_can_show = hpbar.can_show
function hpbar.can_show(player, ...)
Expand Down Expand Up @@ -161,6 +165,17 @@ function ctf_teams.allocate_player(player, on_join, ...)
end
end

local old_privs_func = minetest.registered_chatcommands["privs"].func
minetest.registered_chatcommands["privs"].func = function(player, param)
if not player then return end

if param and minetest.check_player_privs(param, {spectator = true}) and not minetest.check_player_privs(player, {ban = true}) then
minetest.chat_send_player(player, "Privileges of " .. param .. ": vote, interact, shout")
else
return old_privs_func(player, param)
end
end

-- /whereis chat-command
minetest.register_chatcommand("whereis", {
params = "<name>",
Expand Down
2 changes: 1 addition & 1 deletion spectator_mode/mod.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
name = spectator_mode
depends = hpbar, ctf_modebase, ctf_teams, ctf_core
depends = hpbar, ctf_modebase, ctf_teams, ctf_core, irc
Loading