Added /f setleader

This commit is contained in:
shamoanjac 2016-08-27 22:34:09 +02:00
parent 80be027f88
commit 3ffc31f8f2
2 changed files with 21 additions and 0 deletions

View File

@ -574,6 +574,24 @@ factions.register_command("which", {
end
})
factions.register_command("setleader", {
description = "Set a player as a faction's leader",
infaction = false,
global_privileges = {"faction_admin"},
format = {"faction", "player"},
on_success = function(player, faction, pos, parcelpos, args)
local playername = args.players[1]:get_player_name()
local playerfaction = factions.get_player_faction(playername)
local targetfaction = args.factions[1]
if playerfaction.name ~= targetfaction.name then
send_error(player, "Player "..playername.." is not in faction "..targetfaction.name..".")
return false
end
targetfaction:set_leader(playername)
return true
end
})
-------------------------------------------------------------------------------
-- name: cmdhandler(playername,parameter)
--

View File

@ -248,6 +248,9 @@ end
--! @brief change the faction leader
function factions.Faction.set_leader(self, player)
if self.leader then
self.players[self.leader] = self.default_rank
end
self.leader = player
self.players[player] = self.default_leader_rank
self:on_new_leader()