Added /f setleader
This commit is contained in:
parent
80be027f88
commit
3ffc31f8f2
@ -574,6 +574,24 @@ factions.register_command("which", {
|
|||||||
end
|
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)
|
-- name: cmdhandler(playername,parameter)
|
||||||
--
|
--
|
||||||
|
@ -248,6 +248,9 @@ 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)
|
||||||
|
if self.leader then
|
||||||
|
self.players[self.leader] = self.default_rank
|
||||||
|
end
|
||||||
self.leader = player
|
self.leader = player
|
||||||
self.players[player] = self.default_leader_rank
|
self.players[player] = self.default_leader_rank
|
||||||
self:on_new_leader()
|
self:on_new_leader()
|
||||||
|
Loading…
Reference in New Issue
Block a user