forked from mtcontrib/factions
commit
468ef6c394
@ -557,6 +557,52 @@ factions.register_command("forceupdate", {
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
factions.register_command("which", {
|
||||||
|
description = "Gets a player's faction",
|
||||||
|
infaction = false,
|
||||||
|
format = {"string"},
|
||||||
|
on_success = function(player, faction, pos, parcelpos, args)
|
||||||
|
local playername = args.strings[1]
|
||||||
|
local faction = factions.get_player_faction(playername)
|
||||||
|
if not faction then
|
||||||
|
send_error(player, "Player "..playername.." does not belong to any faction")
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
minetest.chat_send_player(player, "player "..playername.." belongs to faction "..faction.name)
|
||||||
|
return true
|
||||||
|
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
|
||||||
|
})
|
||||||
|
|
||||||
|
factions.register_command("setadmin", {
|
||||||
|
description = "Make a faction an admin faction",
|
||||||
|
infaction = false,
|
||||||
|
global_privileges = {"faction_admin"},
|
||||||
|
format = {"faction"},
|
||||||
|
on_success = function(player, faction, pos, parcelpos, args)
|
||||||
|
args.factions[1].is_admin = false
|
||||||
|
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()
|
||||||
@ -392,7 +395,7 @@ function factions.Faction.is_online(self)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function factions.Faction.attack_parcel(self, parcelpos)
|
function factions.Faction.attack_parcel(self, parcelpos)
|
||||||
local attacked_faction = factions.get_parcel_faction(parcelpos)
|
--[[ local attacked_faction = factions.get_parcel_faction(parcelpos)
|
||||||
if attacked_faction then
|
if attacked_faction then
|
||||||
self.power = self.power - factions.power_per_attack
|
self.power = self.power - factions.power_per_attack
|
||||||
if attacked_faction.attacked_parcels[parcelpos] then
|
if attacked_faction.attacked_parcels[parcelpos] then
|
||||||
@ -406,6 +409,7 @@ function factions.Faction.attack_parcel(self, parcelpos)
|
|||||||
end
|
end
|
||||||
factions.save()
|
factions.save()
|
||||||
end
|
end
|
||||||
|
]]
|
||||||
end
|
end
|
||||||
|
|
||||||
function factions.Faction.stop_attack(self, parcelpos)
|
function factions.Faction.stop_attack(self, parcelpos)
|
||||||
@ -710,7 +714,7 @@ factions.faction_tick = function()
|
|||||||
if faction:is_online() then
|
if faction:is_online() then
|
||||||
faction:increase_power(factions.power_per_tick)
|
faction:increase_power(factions.power_per_tick)
|
||||||
end
|
end
|
||||||
if faction.last_logon - now > factions.maximum_faction_inactivity then
|
if now - faction.last_logon > factions.maximum_faction_inactivity then
|
||||||
faction:disband()
|
faction:disband()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user