forked from mtcontrib/factions
Bug fix.
Not a bad one but it needed to be fixed.
This commit is contained in:
parent
72e1475482
commit
11b174f8e3
@ -6,7 +6,7 @@ factions_chat = {}
|
||||
|
||||
factions.commands = {}
|
||||
|
||||
factions.register_command = function(cmd_name, cmd, ignore_param_count)
|
||||
factions.register_command = function(cmd_name, cmd, ignore_param_count,or_perm)
|
||||
factions.commands[cmd_name] = { -- default command
|
||||
name = cmd_name,
|
||||
faction_permissions = {},
|
||||
@ -92,15 +92,23 @@ factions.register_command = function(cmd_name, cmd, ignore_param_count)
|
||||
minetest.chat_send_player(player, "This command is only available within a faction.")
|
||||
return false
|
||||
end
|
||||
local one_p = false
|
||||
if self.faction_permissions then
|
||||
for i in ipairs(self.faction_permissions) do
|
||||
local perm = self.faction_permissions[i]
|
||||
if not player_faction:has_permission(player, perm) then
|
||||
if not or_perm and not player_faction:has_permission(player, perm) then
|
||||
send_error(player, "You do not have the faction permission "..perm)
|
||||
return false
|
||||
elseif or_perm and player_faction:has_permission(player, perm) then
|
||||
one_p = true
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
if or_perm and one_p == false then
|
||||
send_error(player, "You do not have any of faction permissions required.")
|
||||
return false
|
||||
end
|
||||
|
||||
-- get some more data
|
||||
local pos = minetest.get_player_by_name(player):getpos()
|
||||
@ -180,6 +188,23 @@ if factions_config.faction_user_priv == true then
|
||||
def_global_privileges = {"faction_user"}
|
||||
end
|
||||
|
||||
factions.register_command ("set_name", {
|
||||
faction_permissions = {"name"},
|
||||
format = {"string"},
|
||||
description = "Change the faction's name.",
|
||||
global_privileges = def_global_privileges,
|
||||
on_success = function(player, faction, pos, parcelpos, args)
|
||||
local factionname = args.strings[1]
|
||||
if factions.can_create_faction(factionname) then
|
||||
faction:set_name(factionname)
|
||||
return true
|
||||
else
|
||||
send_error(player, "Faction cannot be renamed.")
|
||||
return false
|
||||
end
|
||||
end
|
||||
},false)
|
||||
|
||||
factions.register_command ("claim", {
|
||||
faction_permissions = {"claim"},
|
||||
description = "Claim the plot of land you're on.",
|
||||
@ -209,23 +234,6 @@ factions.register_command ("claim", {
|
||||
end
|
||||
},false)
|
||||
|
||||
factions.register_command ("set_name", {
|
||||
faction_permissions = {"name"},
|
||||
format = {"string"},
|
||||
description = "Change the faction's name.",
|
||||
global_privileges = def_global_privileges,
|
||||
on_success = function(player, faction, pos, parcelpos, args)
|
||||
local factionname = args.strings[1]
|
||||
if factions.can_create_faction(factionname) then
|
||||
faction:set_name(factionname)
|
||||
return true
|
||||
else
|
||||
send_error(player, "Faction cannot be renamed.")
|
||||
return false
|
||||
end
|
||||
end
|
||||
},false)
|
||||
|
||||
factions.register_command("unclaim", {
|
||||
faction_permissions = {"claim"},
|
||||
description = "Unclaim the plot of land you're on.",
|
||||
@ -688,7 +696,7 @@ if factions_config.faction_diplomacy == true then
|
||||
minetest.chat_send_player(player,"none:")
|
||||
end
|
||||
end
|
||||
},false)
|
||||
},false,true)
|
||||
|
||||
factions.register_command("allies", {
|
||||
description = "Shows the factions that are allied to you.",
|
||||
|
12
factions.lua
12
factions.lua
@ -1308,9 +1308,15 @@ function(player)
|
||||
if faction:has_permission(name, "accept_treaty") or faction:has_permission(name, "refuse_treaty") then
|
||||
for _ in pairs(faction.request_inbox) do minetest.chat_send_player(name,"You have diplomatic requests in the inbox.") break end
|
||||
end
|
||||
if faction:has_permission(name, "ranks") then
|
||||
if faction.rankless then
|
||||
minetest.chat_send_player(name,"You need to reset the default rank because there are rankless players in this faction. reset all the ranks back to default using /f reset_ranks (You will lose all of your custom ranks) or use /f change_def_rank")
|
||||
if faction.rankless then
|
||||
local p1 = faction:has_permission(name, "reset_ranks")
|
||||
local p2 = faction:has_permission(name, "set_def_ranks")
|
||||
if p1 and p2 then
|
||||
minetest.chat_send_player(name,"You need to reset the default rank because there are rankless players in this faction. reset all the ranks back to default using /f reset_ranks (You will lose all of your custom ranks) or use /f set_def_rank")
|
||||
elseif p1 then
|
||||
minetest.chat_send_player(name,"You need to reset the default rank because there are rankless players in this faction. reset all the ranks back to default using /f reset_ranks (You will lose all of your custom ranks)")
|
||||
elseif p2 then
|
||||
minetest.chat_send_player(name,"You need to reset the default rank because there are rankless players in this faction. reset all the ranks back to default using /f set_def_rank")
|
||||
end
|
||||
end
|
||||
if faction.message_of_the_day and (faction.message_of_the_day ~= "" or faction.message_of_the_day ~= " ") then
|
||||
|
Loading…
Reference in New Issue
Block a user