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)
|
||||||
|
|
|
@ -356,6 +356,7 @@ 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)
|
||||||
|
if not self.is_admin then
|
||||||
for i,v in pairs(factions.factions) do
|
for i,v in pairs(factions.factions) do
|
||||||
if v.name ~= self.name then
|
if v.name ~= self.name then
|
||||||
if v.enemies[self.name] then
|
if v.enemies[self.name] then
|
||||||
|
@ -384,6 +385,7 @@ function factions.Faction.disband(self, reason)
|
||||||
factions.factions[self.name] = nil
|
factions.factions[self.name] = nil
|
||||||
factions.save()
|
factions.save()
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--! @brief change the faction leader
|
--! @brief change the faction leader
|
||||||
function factions.Faction.set_leader(self, player)
|
function factions.Faction.set_leader(self, player)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user