mirror of
https://github.com/mt-mods/playerfactions.git
synced 2024-11-28 18:23:52 +01:00
changed command outcomes in chat message to return string
This commit is contained in:
parent
83a63c1335
commit
0c0e7548c1
182
init.lua
182
init.lua
@ -189,24 +189,23 @@ local function handle_command(name, param)
|
|||||||
table.insert(params, p)
|
table.insert(params, p)
|
||||||
end
|
end
|
||||||
if params == nil then
|
if params == nil then
|
||||||
minetest.chat_send_player(name, S("Unknown subcommand. Run '/help factions' for help."))
|
return false, S("Unknown subcommand. Run '/help factions' for help.")
|
||||||
end
|
end
|
||||||
local action = params[1]
|
local action = params[1]
|
||||||
if action == "create" then
|
if action == "create" then
|
||||||
local faction_name = params[2]
|
local faction_name = params[2]
|
||||||
local password = params[3]
|
local password = params[3]
|
||||||
if factions.mode_unique_faction and factions.get_player_faction(name) ~= nil then
|
if factions.mode_unique_faction and factions.get_player_faction(name) ~= nil then
|
||||||
minetest.chat_send_player(name, S("You are already in a faction."))
|
return false, S("You are already in a faction.")
|
||||||
elseif faction_name == nil then
|
elseif faction_name == nil then
|
||||||
minetest.chat_send_player(name, S("Missing faction name."))
|
return false, S("Missing faction name.")
|
||||||
elseif password == nil then
|
elseif password == nil then
|
||||||
minetest.chat_send_player(name, S("Missing password."))
|
return false, S("Missing password.")
|
||||||
elseif facts[faction_name] ~= nil then
|
elseif facts[faction_name] ~= nil then
|
||||||
minetest.chat_send_player(name, S("That faction already exists."))
|
return false, S("That faction already exists.")
|
||||||
else
|
else
|
||||||
factions.register_faction(faction_name, name, password)
|
factions.register_faction(faction_name, name, password)
|
||||||
minetest.chat_send_player(name, S("Registered @1.", faction_name))
|
return true, S("Registered @1.", faction_name)
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
elseif action == "disband" then
|
elseif action == "disband" then
|
||||||
local password = nil
|
local password = nil
|
||||||
@ -214,11 +213,9 @@ local function handle_command(name, param)
|
|||||||
local own_factions = factions.get_administered_factions(name)
|
local own_factions = factions.get_administered_factions(name)
|
||||||
local number_factions = #own_factions
|
local number_factions = #own_factions
|
||||||
if number_factions == 0 then
|
if number_factions == 0 then
|
||||||
minetest.chat_send_player(name, S("You are the owner of no faction."))
|
return false, S("You are the owner of no faction.")
|
||||||
return false
|
|
||||||
elseif #params == 1 then
|
elseif #params == 1 then
|
||||||
minetest.chat_send_player(name, S("Missing password."))
|
return false, S("Missing password.")
|
||||||
return false
|
|
||||||
elseif #params == 2 and number_factions == 1 then
|
elseif #params == 2 and number_factions == 1 then
|
||||||
password = params[2]
|
password = params[2]
|
||||||
faction_name = own_factions[1]
|
faction_name = own_factions[1]
|
||||||
@ -227,19 +224,18 @@ local function handle_command(name, param)
|
|||||||
password = params[2]
|
password = params[2]
|
||||||
end
|
end
|
||||||
if password == nil then
|
if password == nil then
|
||||||
minetest.chat_send_player(name, S("Missing password."))
|
return false, S("Missing password.")
|
||||||
elseif faction_name == nil then
|
elseif faction_name == nil then
|
||||||
minetest.chat_send_player(name, S("You are the owner of many factions, you have to choose one of them: @1.", table.concat(own_factions, ", ")))
|
return false, S("You are the owner of many factions, you have to choose one of them: @1.", table.concat(own_factions, ", "))
|
||||||
elseif not facts[faction_name] then
|
elseif not facts[faction_name] then
|
||||||
minetest.chat_send_player(name, S("This faction doesn't exists."))
|
return false, S("This faction doesn't exists.")
|
||||||
elseif name ~= factions.get_owner(faction_name) and not minetest.get_player_privs(name).playerfactions_admin then
|
elseif name ~= factions.get_owner(faction_name) and not minetest.get_player_privs(name).playerfactions_admin then
|
||||||
minetest.chat_send_player(name, S("Permission denied: You are not the owner of this faction, and don't have the playerfactions_admin privilege."))
|
return false, S("Permission denied: You are not the owner of this faction, and don't have the playerfactions_admin privilege.")
|
||||||
elseif password ~= factions.get_password(faction_name) then
|
elseif password ~= factions.get_password(faction_name) then
|
||||||
minetest.chat_send_player(name, S("Permission denied: Wrong password."))
|
return false, S("Permission denied: Wrong password.")
|
||||||
else
|
else
|
||||||
factions.disband_faction(faction_name)
|
factions.disband_faction(faction_name)
|
||||||
minetest.chat_send_player(name, S("Disbanded @1.", faction_name))
|
return true, S("Disbanded @1.", faction_name)
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
elseif action == "list" then
|
elseif action == "list" then
|
||||||
local faction_list = {}
|
local faction_list = {}
|
||||||
@ -247,26 +243,23 @@ local function handle_command(name, param)
|
|||||||
table.insert(faction_list, k)
|
table.insert(faction_list, k)
|
||||||
end
|
end
|
||||||
if #faction_list ~= 0 then
|
if #faction_list ~= 0 then
|
||||||
minetest.chat_send_player(name, S("Factions (@1): @2.", #faction_list, table.concat(faction_list, ", ")))
|
return true, S("Factions (@1): @2.", #faction_list, table.concat(faction_list, ", "))
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(name, S("There are no factions yet."))
|
return true, S("There are no factions yet.")
|
||||||
end
|
end
|
||||||
return true
|
|
||||||
elseif action == "info" then
|
elseif action == "info" then
|
||||||
local faction_name = params[2]
|
local faction_name = params[2]
|
||||||
if faction_name == nil then
|
if faction_name == nil then
|
||||||
local player_factions = factions.get_player_factions(name)
|
local player_factions = factions.get_player_factions(name)
|
||||||
if not player_factions then
|
if not player_factions then
|
||||||
minetest.chat_send_player(name, S("no faction found"))
|
return true, S("no faction found")
|
||||||
return false
|
|
||||||
elseif #player_factions == 1 then
|
elseif #player_factions == 1 then
|
||||||
faction_name = player_factions[1]
|
faction_name = player_factions[1]
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(name, S("You are in many factions, you have to choose one of them: @1.", table.concat(player_factions, ", ")))
|
return false, S("You are in many factions, you have to choose one of them: @1.", table.concat(player_factions, ", "))
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
elseif facts[faction_name] == nil then
|
elseif facts[faction_name] == nil then
|
||||||
minetest.chat_send_player(name, S("This faction doesn't exists."))
|
return false, S("This faction doesn't exists.")
|
||||||
else
|
else
|
||||||
local fmembers = ""
|
local fmembers = ""
|
||||||
if table.getn(facts[faction_name].members) > factions.max_members_list then
|
if table.getn(facts[faction_name].members) > factions.max_members_list then
|
||||||
@ -280,21 +273,20 @@ local function handle_command(name, param)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
minetest.chat_send_player(name, S("Name: @1\nOwner: @2\nMembers: @3", faction_name, factions.get_owner(faction_name), fmembers))
|
local summary = S("Name: @1\nOwner: @2\nMembers: @3", faction_name, factions.get_owner(faction_name), fmembers)
|
||||||
if factions.get_owner(faction_name) == name or minetest.get_player_privs(name).playerfactions_admin then
|
if factions.get_owner(faction_name) == name or minetest.get_player_privs(name).playerfactions_admin then
|
||||||
minetest.chat_send_player(name, S("Password: @1", factions.get_password(faction_name)))
|
summary = summary .. "\n" .. S("Password: @1", factions.get_password(faction_name))
|
||||||
end
|
end
|
||||||
|
return true, summary
|
||||||
end
|
end
|
||||||
elseif action == "player_info" then
|
elseif action == "player_info" then
|
||||||
local player_name = params[2]
|
local player_name = params[2]
|
||||||
if not player_name then
|
if not player_name then
|
||||||
minetest.chat_send_player(name, S("The player name is nil or empty."))
|
return false, S("The player name is nil or empty.")
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
local player_factions = factions.get_player_factions(player_name)
|
local player_factions = factions.get_player_factions(player_name)
|
||||||
if not player_factions then
|
if not player_factions then
|
||||||
minetest.chat_send_player(name, S("This player doesn't exists or is in no faction"))
|
return false, S("This player doesn't exists or is in no faction")
|
||||||
return false
|
|
||||||
else
|
else
|
||||||
local str_owner = ""
|
local str_owner = ""
|
||||||
local str_member = ""
|
local str_member = ""
|
||||||
@ -305,10 +297,10 @@ local function handle_command(name, param)
|
|||||||
str_member = str_member..", "..v
|
str_member = str_member..", "..v
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
minetest.chat_send_player(name, S("@1 is in the following factions: @2.", player_name, str_member))
|
local summary = S("@1 is in the following factions: @2.", player_name, str_member)
|
||||||
local owned_factions = factions.get_owned_factions(player_name)
|
local owned_factions = factions.get_owned_factions(player_name)
|
||||||
if not owned_factions then
|
if not owned_factions then
|
||||||
minetest.chat_send_player(name, S("This player is the owner of no faction."))
|
summary = summary.. "\n" .. S("This player is the owner of no faction.")
|
||||||
else
|
else
|
||||||
for _,v in ipairs(owned_factions) do
|
for _,v in ipairs(owned_factions) do
|
||||||
if str_owner == "" then
|
if str_owner == "" then
|
||||||
@ -317,30 +309,29 @@ local function handle_command(name, param)
|
|||||||
str_owner = str_owner..", "..v
|
str_owner = str_owner..", "..v
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
minetest.chat_send_player(name, S("This player is the owner of the following factions: @1.", str_owner))
|
summary = summary .. "\n" .. S("This player is the owner of the following factions: @1.", str_owner)
|
||||||
end
|
end
|
||||||
if minetest.get_player_privs(player_name).playerfactions_admin then
|
if minetest.get_player_privs(player_name).playerfactions_admin then
|
||||||
minetest.chat_send_player(name, S("@1 has the playerfactions_admin privilege so they can admin every faction.", player_name))
|
summary = summary .. "\n" .. S("@1 has the playerfactions_admin privilege so they can admin every faction.", player_name)
|
||||||
end
|
end
|
||||||
|
return true, summary
|
||||||
end
|
end
|
||||||
elseif action == "join" then
|
elseif action == "join" then
|
||||||
local faction_name = params[2]
|
local faction_name = params[2]
|
||||||
local password = params[3]
|
local password = params[3]
|
||||||
if factions.get_player_faction(name) ~= nil and factions.mode_unique_faction then
|
if factions.get_player_faction(name) ~= nil and factions.mode_unique_faction then
|
||||||
minetest.chat_send_player(name, S("You are already in a faction."))
|
return false, S("You are already in a faction.")
|
||||||
elseif not faction_name then
|
elseif not faction_name then
|
||||||
minetest.chat_send_player(name, S("Missing faction name."))
|
return false, S("Missing faction name.")
|
||||||
elseif facts[faction_name] == nil then
|
elseif facts[faction_name] == nil then
|
||||||
minetest.chat_send_player(name, S("The faction @1 doesn't exist.", faction_name))
|
return false, S("The faction @1 doesn't exist.", faction_name)
|
||||||
elseif factions.get_password(faction_name) ~= password then
|
elseif factions.get_password(faction_name) ~= password then
|
||||||
minetest.chat_send_player(name, S("Permission denied: Wrong password."))
|
return false, S("Permission denied: Wrong password.")
|
||||||
else
|
else
|
||||||
if factions.join_faction(faction_name, name) then
|
if factions.join_faction(faction_name, name) then
|
||||||
minetest.chat_send_player(name, S("Joined @1.", faction_name))
|
return true, S("Joined @1.", faction_name)
|
||||||
return true
|
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(name, S("Error on joining."))
|
return false, S("Error on joining.")
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif action == "leave" then
|
elseif action == "leave" then
|
||||||
@ -348,29 +339,25 @@ local function handle_command(name, param)
|
|||||||
local number_factions = table.getn(player_factions)
|
local number_factions = table.getn(player_factions)
|
||||||
local faction_name = nil
|
local faction_name = nil
|
||||||
if number_factions == 0 then
|
if number_factions == 0 then
|
||||||
minetest.chat_send_player(name, S("You are not in a faction."))
|
return false, S("You are not in a faction.")
|
||||||
return false
|
|
||||||
elseif #params == 1 then
|
elseif #params == 1 then
|
||||||
if number_factions == 1 then
|
if number_factions == 1 then
|
||||||
faction_name = player_factions[1]
|
faction_name = player_factions[1]
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(name, S("You are in many factions, you have to choose one of them: @1.", table.concat(player_factions, ", ")))
|
return false, S("You are in many factions, you have to choose one of them: @1.", table.concat(player_factions, ", "))
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
elseif #params >= 1 and facts[params[2]] ~= nil then
|
elseif #params >= 1 and facts[params[2]] ~= nil then
|
||||||
faction_name = params[2]
|
faction_name = params[2]
|
||||||
end
|
end
|
||||||
if faction_name == nil then
|
if faction_name == nil then
|
||||||
minetest.chat_send_player(name, S("The given faction doesn't exists."))
|
return false, S("The given faction doesn't exists.")
|
||||||
elseif factions.get_owner(faction_name) == name then
|
elseif factions.get_owner(faction_name) == name then
|
||||||
minetest.chat_send_player(name, S("You cannot leave your own faction, change owner or disband it."))
|
return false, S("You cannot leave your own faction, change owner or disband it.")
|
||||||
else
|
else
|
||||||
if factions.leave_faction(faction_name, name) then
|
if factions.leave_faction(faction_name, name) then
|
||||||
minetest.chat_send_player(name, S("Left @1.", faction_name))
|
return true, S("Left @1.", faction_name)
|
||||||
return true
|
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(name, S("Error on leaving faction."))
|
return false, S("Error on leaving faction.")
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif action == "kick" then
|
elseif action == "kick" then
|
||||||
@ -379,8 +366,7 @@ local function handle_command(name, param)
|
|||||||
local own_factions = factions.get_administered_factions(name)
|
local own_factions = factions.get_administered_factions(name)
|
||||||
local number_factions = table.getn(own_factions)
|
local number_factions = table.getn(own_factions)
|
||||||
if number_factions == 0 then
|
if number_factions == 0 then
|
||||||
minetest.chat_send_player(name, S("You are the owner of no faction, you can't use this command."))
|
return false, S("You are the owner of no faction, you can't use this command.")
|
||||||
return false
|
|
||||||
elseif #params == 2 and number_factions == 1 then
|
elseif #params == 2 and number_factions == 1 then
|
||||||
target = params[2]
|
target = params[2]
|
||||||
faction_name = own_factions[1]
|
faction_name = own_factions[1]
|
||||||
@ -389,22 +375,20 @@ local function handle_command(name, param)
|
|||||||
target = params[2]
|
target = params[2]
|
||||||
end
|
end
|
||||||
if faction_name == nil then
|
if faction_name == nil then
|
||||||
minetest.chat_send_player(name, S("You are the owner of many factions, you have to choose one of them: @1.", table.concat(own_factions, ", ")))
|
return false, S("You are the owner of many factions, you have to choose one of them: @1.", table.concat(own_factions, ", "))
|
||||||
elseif target == nil then
|
elseif target == nil then
|
||||||
minetest.chat_send_player(name, S("Missing player name."))
|
return false, S("Missing player name.")
|
||||||
elseif factions.get_owner(faction_name) ~= name and not minetest.get_player_privs(name).playerfactions_admin then
|
elseif factions.get_owner(faction_name) ~= name and not minetest.get_player_privs(name).playerfactions_admin then
|
||||||
minetest.chat_send_player(name, S("Permission denied: You are not the owner of this faction, and don't have the playerfactions_admin privilege."))
|
return false, S("Permission denied: You are not the owner of this faction, and don't have the playerfactions_admin privilege.")
|
||||||
elseif not facts[faction_name].members[target] then
|
elseif not facts[faction_name].members[target] then
|
||||||
minetest.chat_send_player(name, S("This player is not in the specified faction."))
|
return false, S("This player is not in the specified faction.")
|
||||||
elseif target == factions.get_owner(faction_name) then
|
elseif target == factions.get_owner(faction_name) then
|
||||||
minetest.chat_send_player(name, S("You cannot kick the owner of a faction, use '/factions chown <player> [faction]' to change the ownership."))
|
return false, S("You cannot kick the owner of a faction, use '/factions chown <player> [faction]' to change the ownership.")
|
||||||
else
|
else
|
||||||
if factions.leave_faction(faction_name, target) then
|
if factions.leave_faction(faction_name, target) then
|
||||||
minetest.chat_send_player(name, S("Kicked @1 from faction.", target))
|
return true, S("Kicked @1 from faction.", target)
|
||||||
return true
|
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(name, S("Error kicking @1 from faction.", target))
|
return false, S("Error kicking @1 from faction.", target)
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif action == "passwd" then
|
elseif action == "passwd" then
|
||||||
@ -413,11 +397,9 @@ local function handle_command(name, param)
|
|||||||
local own_factions = factions.get_administered_factions(name)
|
local own_factions = factions.get_administered_factions(name)
|
||||||
local number_factions = table.getn(own_factions)
|
local number_factions = table.getn(own_factions)
|
||||||
if #params == 1 then
|
if #params == 1 then
|
||||||
minetest.chat_send_player(name, S("Missing password."))
|
return false, S("Missing password.")
|
||||||
return false
|
|
||||||
elseif number_factions == 0 then
|
elseif number_factions == 0 then
|
||||||
minetest.chat_send_player(name, S("You are the owner of no faction, you can't use this command."))
|
return false, S("You are the owner of no faction, you can't use this command.")
|
||||||
return false
|
|
||||||
elseif #params == 2 and number_factions == 1 then
|
elseif #params == 2 and number_factions == 1 then
|
||||||
password = params[2]
|
password = params[2]
|
||||||
faction_name = own_factions[1]
|
faction_name = own_factions[1]
|
||||||
@ -426,18 +408,16 @@ local function handle_command(name, param)
|
|||||||
password = params[2]
|
password = params[2]
|
||||||
end
|
end
|
||||||
if faction_name == nil then
|
if faction_name == nil then
|
||||||
minetest.chat_send_player(name, S("You are the owner of many factions, you have to choose one of them: @1.", table.concat(own_factions, ", ")))
|
return false, S("You are the owner of many factions, you have to choose one of them: @1.", table.concat(own_factions, ", "))
|
||||||
elseif password == nil then
|
elseif password == nil then
|
||||||
minetest.chat_send_player(name, S("Missing password."))
|
return false, S("Missing password.")
|
||||||
elseif factions.get_owner(faction_name) ~= name and not minetest.get_player_privs(name).playerfactions_admin then
|
elseif factions.get_owner(faction_name) ~= name and not minetest.get_player_privs(name).playerfactions_admin then
|
||||||
minetest.chat_send_player(name, S("Permission denied: You are not the owner of this faction, and don't have the playerfactions_admin privilege."))
|
return false, S("Permission denied: You are not the owner of this faction, and don't have the playerfactions_admin privilege.")
|
||||||
else
|
else
|
||||||
if factions.set_password(faction_name, password) then
|
if factions.set_password(faction_name, password) then
|
||||||
minetest.chat_send_player(name, S("Password has been updated."))
|
return true, S("Password has been updated.")
|
||||||
return true
|
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(name, S("Failed to change password."))
|
return false, S("Failed to change password.")
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif action == "chown" then
|
elseif action == "chown" then
|
||||||
@ -448,15 +428,12 @@ local function handle_command(name, param)
|
|||||||
local password = nil
|
local password = nil
|
||||||
if #params < 3 then
|
if #params < 3 then
|
||||||
if params[2] ~= nil and minetest.player_exists(params[2]) then
|
if params[2] ~= nil and minetest.player_exists(params[2]) then
|
||||||
minetest.chat_send_player(name, S("Missing password."))
|
return false, S("Missing password.")
|
||||||
return false
|
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(name, S("Missing player name."))
|
return false, S("Missing player name.")
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
elseif number_factions == 0 then
|
elseif number_factions == 0 then
|
||||||
minetest.chat_send_player(name, S("You are the owner of no faction, you can't use this command."))
|
return false, S("You are the owner of no faction, you can't use this command.")
|
||||||
return false
|
|
||||||
elseif number_factions == 1 and #params == 3 then
|
elseif number_factions == 1 and #params == 3 then
|
||||||
faction_name = own_factions[1]
|
faction_name = own_factions[1]
|
||||||
target = params[2]
|
target = params[2]
|
||||||
@ -467,56 +444,51 @@ local function handle_command(name, param)
|
|||||||
password = params[3]
|
password = params[3]
|
||||||
end
|
end
|
||||||
if faction_name == nil then
|
if faction_name == nil then
|
||||||
minetest.chat_send_player(name, S("You are the owner of many factions, you have to choose one of them: @1.", table.concat(own_factions, ", ")))
|
return false, S("You are the owner of many factions, you have to choose one of them: @1.", table.concat(own_factions, ", "))
|
||||||
elseif target == nil then
|
elseif target == nil then
|
||||||
minetest.chat_send_player(name, S("Missing player name."))
|
return false, S("Missing player name.")
|
||||||
elseif password == nil then
|
elseif password == nil then
|
||||||
minetest.chat_send_player(name, S("Missing password."))
|
return false, S("Missing password.")
|
||||||
elseif name ~= factions.get_owner(faction_name) and not minetest.get_player_privs(name).playerfactions_admin then
|
elseif name ~= factions.get_owner(faction_name) and not minetest.get_player_privs(name).playerfactions_admin then
|
||||||
minetest.chat_send_player(name, S("Permission denied: You are not the owner of this faction, and don't have the playerfactions_admin privilege."))
|
return false, S("Permission denied: You are not the owner of this faction, and don't have the playerfactions_admin privilege.")
|
||||||
elseif not facts[faction_name].members[target] then
|
elseif not facts[faction_name].members[target] then
|
||||||
minetest.chat_send_player(name, S("@1 isn't in your faction.", target))
|
return false, S("@1 isn't in your faction.", target)
|
||||||
elseif password ~= factions.get_password(faction_name) then
|
elseif password ~= factions.get_password(faction_name) then
|
||||||
minetest.chat_send_player(name, S("Permission denied: Wrong password."))
|
return false, S("Permission denied: Wrong password.")
|
||||||
else
|
else
|
||||||
if factions.chown(faction_name, target) then
|
if factions.chown(faction_name, target) then
|
||||||
minetest.chat_send_player(name, S("Ownership has been transferred to @1.", target))
|
return true, S("Ownership has been transferred to @1.", target)
|
||||||
return true
|
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(name, S("Failed to transfer ownership."))
|
return false, S("Failed to transfer ownership.")
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif action == "invite" then
|
elseif action == "invite" then
|
||||||
if not minetest.get_player_privs(name).playerfactions_admin then
|
if not minetest.get_player_privs(name).playerfactions_admin then
|
||||||
minetest.chat_send_player(name, S("Permission denied: You can't use this command, playerfactions_admin priv is needed."))
|
return false, S("Permission denied: You can't use this command, playerfactions_admin priv is needed.")
|
||||||
else
|
else
|
||||||
local target = params[2]
|
local target = params[2]
|
||||||
local faction_name = params[3]
|
local faction_name = params[3]
|
||||||
if not target then
|
if not target then
|
||||||
minetest.chat_send_player(name, S("Missing target."))
|
return false, S("Missing target.")
|
||||||
elseif not faction_name then
|
elseif not faction_name then
|
||||||
minetest.chat_send_player(name, S("Missing faction name."))
|
return false, S("Missing faction name.")
|
||||||
elseif facts[faction_name] == nil then
|
elseif facts[faction_name] == nil then
|
||||||
minetest.chat_send_player(name, S("The faction @1 doesn't exist.", faction_name))
|
return false, S("The faction @1 doesn't exist.", faction_name)
|
||||||
elseif not minetest.player_exists(target) then
|
elseif not minetest.player_exists(target) then
|
||||||
minetest.chat_send_player(name, S("The player doesn't exist."))
|
return false, S("The player doesn't exist.")
|
||||||
elseif factions.mode_unique_faction and factions.get_player_faction(target) ~= nil then
|
elseif factions.mode_unique_faction and factions.get_player_faction(target) ~= nil then
|
||||||
minetest.chat_send_player(name, S("The player is already in the faction \"@1\".",factions.get_player_faction(target)))
|
return false, S("The player is already in the faction \"@1\".",factions.get_player_faction(target))
|
||||||
else
|
else
|
||||||
if factions.join_faction(faction_name, target) then
|
if factions.join_faction(faction_name, target) then
|
||||||
minetest.chat_send_player(name, S("@1 is now a member of the faction @2.", target, faction_name))
|
return true, S("@1 is now a member of the faction @2.", target, faction_name)
|
||||||
return true
|
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(name, S("Error on adding @1 into @2.", target, faction_name))
|
return false, S("Error on adding @1 into @2.", target, faction_name)
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(name, S("Unknown subcommand. Run '/help factions' for help."))
|
return false, S("Unknown subcommand. Run '/help factions' for help.")
|
||||||
end
|
end
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_chatcommand("factions", {
|
minetest.register_chatcommand("factions", {
|
||||||
|
Loading…
Reference in New Issue
Block a user