Give is_admin purpose.

If a faction is set as an admin faction it will never be disbanded.
This commit is contained in:
Coder12a 2018-10-27 23:14:52 -05:00
parent 615c9464cc
commit f902419d25
2 changed files with 50 additions and 25 deletions

View File

@ -975,13 +975,36 @@ factions.register_command("setleader", {
end
},false)
factions.register_command("setadmin", {
factions.register_command("set_admin", {
description = "Make a faction an admin faction",
infaction = false,
global_privileges = {"faction_admin"},
format = {"faction"},
on_success = function(player, faction, pos, parcelpos, args)
if not args.factions[1].is_admin then
minetest.chat_send_player(player,"faction " .. args.factions[1].name .. " is now an admin faction it can not be disband.")
else
minetest.chat_send_player(player,"faction " .. args.factions[1].name .. " is already an admin faction.")
end
args.factions[1].is_admin = true
factions.save()
return true
end
},false)
factions.register_command("remove_admin", {
description = "Make a faction not an admin faction",
infaction = false,
global_privileges = {"faction_admin"},
format = {"faction"},
on_success = function(player, faction, pos, parcelpos, args)
if args.factions[1].is_admin then
minetest.chat_send_player(player,"faction " .. args.factions[1].name .. " is not an admin faction any more.")
else
minetest.chat_send_player(player,"faction " .. args.factions[1].name .. " is not an admin faction to begin with.")
end
args.factions[1].is_admin = false
factions.save()
return true
end
},false)

View File

@ -356,33 +356,35 @@ end
--! @brief disband faction, updates global players and parcels table
function factions.Faction.disband(self, reason)
for i,v in pairs(factions.factions) do
if v.name ~= self.name then
if v.enemies[self.name] then
v:end_enemy(self.name)
end
if v.allies[self.name] then
v:end_alliance(self.name)
end
if v.neutral[self.name] then
v:end_neutral(self.name)
if not self.is_admin then
for i,v in pairs(factions.factions) do
if v.name ~= self.name then
if v.enemies[self.name] then
v:end_enemy(self.name)
end
if v.allies[self.name] then
v:end_alliance(self.name)
end
if v.neutral[self.name] then
v:end_neutral(self.name)
end
end
end
for k, _ in pairs(self.players) do -- remove players affiliation
factions.players[k] = nil
end
for k, v in pairs(self.land) do -- remove parcel claims
factions.parcels[k] = nil
end
self:on_disband(reason)
local playerslist = self.onlineplayers
for i,l in pairs(playerslist) do
removeHud(i,"factionName")
removeHud(i,"powerWatch")
end
factions.factions[self.name] = nil
factions.save()
end
for k, _ in pairs(self.players) do -- remove players affiliation
factions.players[k] = nil
end
for k, v in pairs(self.land) do -- remove parcel claims
factions.parcels[k] = nil
end
self:on_disband(reason)
local playerslist = self.onlineplayers
for i,l in pairs(playerslist) do
removeHud(i,"factionName")
removeHud(i,"powerWatch")
end
factions.factions[self.name] = nil
factions.save()
end
--! @brief change the faction leader