Skip to content

Commit

Permalink
Improve spectator mod (#62)
Browse files Browse the repository at this point in the history
* Update mod.conf

* Update init.lua

* Update init.lua

* Update init.lua

* Update init.lua

* satisfying my ocd :)

* Update spectator_mode/init.lua

Co-authored-by: LoneWolfHT <[email protected]>

* Update init.lua

* Update init.lua

---------

Co-authored-by: LoneWolfHT <[email protected]>
  • Loading branch information
olliy1or and LoneWolfHT authored Jun 4, 2024
1 parent 2f50a3c commit d34e1b1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
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

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

0 comments on commit d34e1b1

Please sign in to comment.