Give is_admin purpose.
If a faction is set as an admin faction it will never be disbanded.
This commit is contained in:
parent
615c9464cc
commit
f902419d25
|
@ -975,13 +975,36 @@ factions.register_command("setleader", {
|
||||||
end
|
end
|
||||||
},false)
|
},false)
|
||||||
|
|
||||||
factions.register_command("setadmin", {
|
factions.register_command("set_admin", {
|
||||||
description = "Make a faction an admin faction",
|
description = "Make a faction an admin faction",
|
||||||
infaction = false,
|
infaction = false,
|
||||||
global_privileges = {"faction_admin"},
|
global_privileges = {"faction_admin"},
|
||||||
format = {"faction"},
|
format = {"faction"},
|
||||||
on_success = function(player, faction, pos, parcelpos, args)
|
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
|
args.factions[1].is_admin = false
|
||||||
|
factions.save()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
},false)
|
},false)
|
||||||
|
|
50
factions.lua
50
factions.lua
|
@ -356,33 +356,35 @@ end
|
||||||
|
|
||||||
--! @brief disband faction, updates global players and parcels table
|
--! @brief disband faction, updates global players and parcels table
|
||||||
function factions.Faction.disband(self, reason)
|
function factions.Faction.disband(self, reason)
|
||||||
for i,v in pairs(factions.factions) do
|
if not self.is_admin then
|
||||||
if v.name ~= self.name then
|
for i,v in pairs(factions.factions) do
|
||||||
if v.enemies[self.name] then
|
if v.name ~= self.name then
|
||||||
v:end_enemy(self.name)
|
if v.enemies[self.name] then
|
||||||
end
|
v:end_enemy(self.name)
|
||||||
if v.allies[self.name] then
|
end
|
||||||
v:end_alliance(self.name)
|
if v.allies[self.name] then
|
||||||
end
|
v:end_alliance(self.name)
|
||||||
if v.neutral[self.name] then
|
end
|
||||||
v:end_neutral(self.name)
|
if v.neutral[self.name] then
|
||||||
|
v:end_neutral(self.name)
|
||||||
|
end
|
||||||
end
|
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
|
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
|
end
|
||||||
|
|
||||||
--! @brief change the faction leader
|
--! @brief change the faction leader
|
||||||
|
|
Loading…
Reference in New Issue
Block a user