forked from mtcontrib/factions
Fix: crash in diplomacy cmds
This commit is contained in:
parent
c8f3528a43
commit
0008628566
@ -735,6 +735,11 @@ if factions_config.faction_diplomacy == true then
|
||||
local target_name = args.strings[1]
|
||||
local target_faction = factions.factions.get(target_name)
|
||||
|
||||
if not target_faction then
|
||||
send_error(player, target_name .. " Is not a faction.")
|
||||
return false
|
||||
end
|
||||
|
||||
if faction.request_inbox[target_name] then
|
||||
if target_name == faction.name then
|
||||
send_error(player, "You can not accept an request from own faction")
|
||||
@ -771,6 +776,11 @@ if factions_config.faction_diplomacy == true then
|
||||
local target_name = args.strings[1]
|
||||
local target_faction = factions.factions.get(target_name)
|
||||
|
||||
if not target_faction then
|
||||
send_error(player, target_name .. " Is not a faction.")
|
||||
return false
|
||||
end
|
||||
|
||||
if faction.request_inbox[target_name] then
|
||||
if target_name == faction.name then
|
||||
send_error(player, "You can not refuse an request from your own faction")
|
||||
@ -798,6 +808,11 @@ if factions_config.faction_diplomacy == true then
|
||||
local target_name = args.strings[1]
|
||||
local target_faction = factions.factions.get(target_name)
|
||||
|
||||
if not target_faction then
|
||||
send_error(player, target_name .. " Is not a faction.")
|
||||
return false
|
||||
end
|
||||
|
||||
if not faction.enemies[target_name] then
|
||||
if target_name == faction.name then
|
||||
send_error(player, "You can not declare war on your own faction")
|
||||
@ -833,6 +848,11 @@ if factions_config.faction_diplomacy == true then
|
||||
local target_name = args.strings[1]
|
||||
local target_faction = factions.factions.get(target_name)
|
||||
|
||||
if not target_faction then
|
||||
send_error(player, target_name .. " Is not a faction.")
|
||||
return false
|
||||
end
|
||||
|
||||
if faction.allies[target_name] then
|
||||
if target_name == faction.name then
|
||||
send_error(player, "You can not break an alliance from your own faction")
|
||||
@ -1343,13 +1363,16 @@ factions.register_command("promote", {
|
||||
|
||||
local promoter_faction, promoter_facname = factions.get_player_faction(player)
|
||||
|
||||
if player_faction and promoter_facname == facname then
|
||||
if player_faction and promoter_facname == facname and player ~= name then
|
||||
factions.promote(faction.name, name, rank)
|
||||
minetest.chat_send_player(player, "Promoted " .. name .. " to " .. rank .. "!")
|
||||
return true
|
||||
elseif not player_faction or promoter_facname ~= facname then
|
||||
send_error(player, name .. " is not in your faction")
|
||||
return false
|
||||
elseif player == name then
|
||||
send_error(player, "You can not promote yourself!")
|
||||
return false
|
||||
else
|
||||
send_error(player, name .. " cannot be promoted from your faction")
|
||||
return false
|
||||
@ -1651,6 +1674,7 @@ local premade_help_admin = ""
|
||||
|
||||
local a_z = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
|
||||
|
||||
minetest.register_on_mods_loaded(function()
|
||||
for l, j in pairs(a_z) do
|
||||
for k, v in pairs(factions.commands) do
|
||||
if k:sub(1, 1) == j then
|
||||
@ -1663,8 +1687,8 @@ for l, j in pairs(a_z) do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
a_z = nil
|
||||
end)
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
-- name: show_help(playername, parameter)
|
||||
|
Loading…
Reference in New Issue
Block a user