forked from mtcontrib/factions
Add new cmd change_def_rank
This commit is contained in:
parent
e2f9cdb9f2
commit
4a15fb3646
@ -816,6 +816,23 @@ factions.register_command("delrank", {
|
||||
end
|
||||
},false)
|
||||
|
||||
factions.register_command("change_def_rank", {
|
||||
description = "Change the default rank given to new players and also replace rankless players in this faction.",
|
||||
format = {"string"},
|
||||
faction_permissions = {"ranks"},
|
||||
global_privileges = def_global_privileges,
|
||||
on_success = function(player, faction, pos, parcelpos, args)
|
||||
local rank = args.strings[1]
|
||||
if not faction.ranks[rank] then
|
||||
send_error(player, "This rank does not exist.")
|
||||
return false
|
||||
end
|
||||
faction:change_def_rank(rank)
|
||||
faction.rankless = false
|
||||
return true
|
||||
end
|
||||
},false)
|
||||
|
||||
factions.register_command("setspawn", {
|
||||
description = "Set the faction's spawn",
|
||||
faction_permissions = {"spawn"},
|
||||
|
22
factions.lua
22
factions.lua
@ -418,6 +418,8 @@ function factions.Faction.has_permission(self, player, permission)
|
||||
return true
|
||||
end
|
||||
end
|
||||
else
|
||||
self.rankless = true
|
||||
end
|
||||
return false
|
||||
end
|
||||
@ -523,6 +525,17 @@ function factions.Faction.add_rank(self, rank, perms)
|
||||
factions.save()
|
||||
end
|
||||
|
||||
function factions.Faction.change_def_rank(self, rank)
|
||||
for player, r in pairs(self.players) do
|
||||
if r == rank or r == nil or not self.ranks[r] then
|
||||
self.players[player] = rank
|
||||
end
|
||||
end
|
||||
self.default_rank = rank
|
||||
self:on_change_def_rank(rank, rank)
|
||||
factions.save()
|
||||
end
|
||||
|
||||
--! @brief delete a rank and replace it
|
||||
--! @param rank the name of the rank to be deleted
|
||||
--! @param newrank the rank given to players who were previously "rank"
|
||||
@ -709,6 +722,10 @@ function factions.Faction.on_delete_rank(self, rank, newrank)
|
||||
self:broadcast("The rank "..rank.." has been deleted and replaced by "..newrank)
|
||||
end
|
||||
|
||||
function factions.Faction.on_change_def_rank(self, rank)
|
||||
self:broadcast("The default rank given to new players has been changed to "..rank)
|
||||
end
|
||||
|
||||
function factions.Faction.on_promote(self, member)
|
||||
minetest.chat_send_player(member, "You have been promoted to "..self.players[member])
|
||||
end
|
||||
@ -1034,6 +1051,11 @@ function(player)
|
||||
if faction:has_permission(name, "diplomacy") then
|
||||
for _ in pairs(faction.request_inbox) do minetest.chat_send_player(name,"You have diplomatic requests in the inbox.") break end
|
||||
end
|
||||
if faction:has_permission(name, "ranks") then
|
||||
if faction.rankless then
|
||||
minetest.chat_send_player(name,"You need to reset the default rank because there are rankless players in this faction. type /f change_def_rank")
|
||||
end
|
||||
end
|
||||
if faction.message_of_the_day and (faction.message_of_the_day ~= "" or faction.message_of_the_day ~= " ") then
|
||||
minetest.chat_send_player(name,faction.message_of_the_day)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user