Bug: join command will not delete your old team
This commit is contained in:
parent
c65bde260e
commit
accba69a15
|
@ -210,13 +210,15 @@ factions.register_command ("claim", {
|
||||||
description = "Claim the plot of land you're on.",
|
description = "Claim the plot of land you're on.",
|
||||||
global_privileges = def_global_privileges,
|
global_privileges = def_global_privileges,
|
||||||
on_success = function(player, faction, pos, parcelpos, args)
|
on_success = function(player, faction, pos, parcelpos, args)
|
||||||
local can_claim = faction:can_claim_parcel(parcelpos)
|
local p = parcelpos
|
||||||
|
local can_claim = faction:can_claim_parcel(p)
|
||||||
|
|
||||||
if can_claim then
|
if can_claim then
|
||||||
minetest.chat_send_player(player, "Claming parcel "..parcelpos)
|
minetest.chat_send_player(player, "Claming parcel " .. p)
|
||||||
faction:claim_parcel(parcelpos)
|
faction:claim_parcel(p)
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
local parcel_faction = factions.get_parcel_faction(parcelpos)
|
local parcel_faction = factions.get_parcel_faction(p)
|
||||||
if parcel_faction and parcel_faction.name == faction.name then
|
if parcel_faction and parcel_faction.name == faction.name then
|
||||||
send_error(player, "This parcel already belongs to your faction.")
|
send_error(player, "This parcel already belongs to your faction.")
|
||||||
return false
|
return false
|
||||||
|
@ -278,6 +280,7 @@ factions.register_command("list", {
|
||||||
--show factions mod version
|
--show factions mod version
|
||||||
factions.register_command("version", {
|
factions.register_command("version", {
|
||||||
description = "Displays mod version.",
|
description = "Displays mod version.",
|
||||||
|
infaction = false,
|
||||||
on_success = function(player, faction, pos, parcelpos, args)
|
on_success = function(player, faction, pos, parcelpos, args)
|
||||||
minetest.chat_send_player(player, "factions: version " .. misc_mod_data.data.factions_version , false)
|
minetest.chat_send_player(player, "factions: version " .. misc_mod_data.data.factions_version , false)
|
||||||
end
|
end
|
||||||
|
@ -287,6 +290,7 @@ factions.register_command("version", {
|
||||||
factions.register_command("info", {
|
factions.register_command("info", {
|
||||||
format = {"faction"},
|
format = {"faction"},
|
||||||
description = "Shows a faction's description.",
|
description = "Shows a faction's description.",
|
||||||
|
infaction = false,
|
||||||
global_privileges = def_global_privileges,
|
global_privileges = def_global_privileges,
|
||||||
on_success = function(player, faction, pos, parcelpos, args)
|
on_success = function(player, faction, pos, parcelpos, args)
|
||||||
minetest.chat_send_player(player,
|
minetest.chat_send_player(player,
|
||||||
|
@ -356,15 +360,19 @@ factions.register_command("join", {
|
||||||
infaction = false,
|
infaction = false,
|
||||||
global_privileges = def_global_privileges,
|
global_privileges = def_global_privileges,
|
||||||
on_success = function(player, faction, pos, parcelpos, args)
|
on_success = function(player, faction, pos, parcelpos, args)
|
||||||
local new_faction = args.factions[1]
|
if faction ~= nil or faction then
|
||||||
if new_faction:can_join(player) then
|
send_error(player, "You need to leave your current faction in order to join this one.")
|
||||||
if faction then -- leave old faction
|
return false
|
||||||
faction:remove_player(player)
|
end
|
||||||
end
|
local new_faction = args.factions[1]
|
||||||
|
if new_faction and new_faction:can_join(player) then
|
||||||
new_faction:add_player(player)
|
new_faction:add_player(player)
|
||||||
else
|
elseif new_faction then
|
||||||
send_error(player, "You cannot join this faction.")
|
send_error(player, "You cannot join this faction.")
|
||||||
return false
|
return false
|
||||||
|
else
|
||||||
|
send_error(player, "Enter the right faction name.")
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -437,7 +445,9 @@ factions.register_command("invite", {
|
||||||
description = "Invite a player to your faction.",
|
description = "Invite a player to your faction.",
|
||||||
global_privileges = def_global_privileges,
|
global_privileges = def_global_privileges,
|
||||||
on_success = function(player, faction, pos, parcelpos, args)
|
on_success = function(player, faction, pos, parcelpos, args)
|
||||||
faction:invite_player(args.players[1]:get_player_name())
|
if args.players and args.players[1] then
|
||||||
|
faction:invite_player(args.players[1]:get_player_name())
|
||||||
|
end
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
},false)
|
},false)
|
||||||
|
@ -478,6 +488,7 @@ factions.register_command("ranks", {
|
||||||
factions.register_command("rank_privileges", {
|
factions.register_command("rank_privileges", {
|
||||||
description = "List available rank privileges.",
|
description = "List available rank privileges.",
|
||||||
global_privileges = def_global_privileges,
|
global_privileges = def_global_privileges,
|
||||||
|
infaction = false,
|
||||||
on_success = function(player, faction, pos, parcelpos, args)
|
on_success = function(player, faction, pos, parcelpos, args)
|
||||||
minetest.chat_send_player(player, "Privileges available:\n")
|
minetest.chat_send_player(player, "Privileges available:\n")
|
||||||
for i, k in pairs(factions.permissions) do
|
for i, k in pairs(factions.permissions) do
|
||||||
|
@ -765,6 +776,7 @@ local parcel_size_center = factions_config.parcel_size / 2
|
||||||
factions.register_command("show_parcel", {
|
factions.register_command("show_parcel", {
|
||||||
description = "Shows parcel for six seconds.",
|
description = "Shows parcel for six seconds.",
|
||||||
global_privileges = def_global_privileges,
|
global_privileges = def_global_privileges,
|
||||||
|
infaction = false,
|
||||||
on_success = function(player, faction, pos, parcelpos, args)
|
on_success = function(player, faction, pos, parcelpos, args)
|
||||||
local parcel_faction = factions.get_parcel_faction(parcelpos)
|
local parcel_faction = factions.get_parcel_faction(parcelpos)
|
||||||
if not parcel_faction then
|
if not parcel_faction then
|
||||||
|
@ -1050,22 +1062,38 @@ factions.register_command("del_spawn", {
|
||||||
},false)
|
},false)
|
||||||
|
|
||||||
if factions_config.spawn_teleport == true then
|
if factions_config.spawn_teleport == true then
|
||||||
|
|
||||||
|
local tip = {}
|
||||||
|
|
||||||
factions.register_command("tp_spawn", {
|
factions.register_command("tp_spawn", {
|
||||||
description = "Teleport to the faction's spawn",
|
description = "Teleport to the faction's spawn",
|
||||||
faction_permissions = {"spawn"},
|
faction_permissions = {"spawn"},
|
||||||
global_privileges = def_global_privileges,
|
global_privileges = def_global_privileges,
|
||||||
on_success = function(player, faction, pos, parcelpos, args)
|
on_success = function(player, faction, pos, parcelpos, args)
|
||||||
if player then
|
if player then
|
||||||
|
if tip[player] then
|
||||||
|
minetest.chat_send_player(player, "Your already being teleported!")
|
||||||
|
return false
|
||||||
|
end
|
||||||
minetest.chat_send_player(player, "Teleporting in five seconds.")
|
minetest.chat_send_player(player, "Teleporting in five seconds.")
|
||||||
minetest.after(5,
|
minetest.after(5,
|
||||||
function(faction,player)
|
function(faction,player)
|
||||||
faction:tp_spawn(player)
|
faction:tp_spawn(player)
|
||||||
end,faction,player)
|
tip[player] = nil
|
||||||
|
end, faction, player)
|
||||||
|
tip[player] = true
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
},false)
|
},false)
|
||||||
|
|
||||||
|
minetest.register_on_leaveplayer(
|
||||||
|
function(player)
|
||||||
|
local name = player:get_player_name()
|
||||||
|
tip[name] = nil
|
||||||
|
end
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
factions.register_command("where", {
|
factions.register_command("where", {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user