mirror of
https://github.com/minetest-mods/teleport-request.git
synced 2025-01-06 13:07:33 +01:00
Senders can deny their own requests (#32)
This commit is contained in:
parent
b418b67920
commit
ccd6044b19
@ -188,11 +188,14 @@ function tp.tpr_send(sender, receiver)
|
|||||||
|
|
||||||
-- Write name values to list and clear old values.
|
-- Write name values to list and clear old values.
|
||||||
tp.tpr_list[receiver] = sender
|
tp.tpr_list[receiver] = sender
|
||||||
|
tp.tpn_list[sender] = receiver
|
||||||
|
|
||||||
-- Teleport timeout delay
|
-- Teleport timeout delay
|
||||||
minetest.after(tp.timeout_delay, function(name)
|
minetest.after(tp.timeout_delay, function(name)
|
||||||
if tp.tpr_list[name] then
|
if tp.tpr_list[name] and tp.tpn_list[sender] then
|
||||||
tp.tpr_list[name] = nil
|
tp.tpr_list[name] = nil
|
||||||
|
tp.tpn_list[sender] = nil
|
||||||
|
|
||||||
minetest.chat_send_player(sender, S("Request timed-out."))
|
minetest.chat_send_player(sender, S("Request timed-out."))
|
||||||
minetest.chat_send_player(receiver, S("Request timed-out."))
|
minetest.chat_send_player(receiver, S("Request timed-out."))
|
||||||
|
|
||||||
@ -288,11 +291,14 @@ function tp.tphr_send(sender, receiver)
|
|||||||
|
|
||||||
-- Write name values to list and clear old values.
|
-- Write name values to list and clear old values.
|
||||||
tp.tphr_list[receiver] = sender
|
tp.tphr_list[receiver] = sender
|
||||||
|
tp.tpn_list[sender] = receiver
|
||||||
|
|
||||||
-- Teleport timeout delay
|
-- Teleport timeout delay
|
||||||
minetest.after(tp.timeout_delay, function(name)
|
minetest.after(tp.timeout_delay, function(name)
|
||||||
if tp.tphr_list[name] then
|
if tp.tphr_list[name] and tp.tpn_list[sender] then
|
||||||
tp.tphr_list[name] = nil
|
tp.tphr_list[name] = nil
|
||||||
|
tp.tpn_list[sender] = nil
|
||||||
|
|
||||||
minetest.chat_send_player(sender, S("Request timed-out."))
|
minetest.chat_send_player(sender, S("Request timed-out."))
|
||||||
minetest.chat_send_player(receiver, S("Request timed-out."))
|
minetest.chat_send_player(receiver, S("Request timed-out."))
|
||||||
|
|
||||||
@ -386,8 +392,12 @@ function tp.tpr_deny(name)
|
|||||||
chat2.send_message(minetest.get_player_by_name(name2), S("Teleport request denied."), 0xFFFFFF)
|
chat2.send_message(minetest.get_player_by_name(name2), S("Teleport request denied."), 0xFFFFFF)
|
||||||
chat2.send_message(minetest.get_player_by_name(name), S("You denied the request @1 sent you.", name2), 0xFFFFFF)
|
chat2.send_message(minetest.get_player_by_name(name), S("You denied the request @1 sent you.", name2), 0xFFFFFF)
|
||||||
end
|
end
|
||||||
|
|
||||||
tp.tpr_list[name] = nil
|
tp.tpr_list[name] = nil
|
||||||
|
|
||||||
|
-- Don't allow re-denying requests.
|
||||||
|
tp.tpn_list[name2] = nil
|
||||||
|
|
||||||
elseif tp.tphr_list[name] then
|
elseif tp.tphr_list[name] then
|
||||||
name2 = tp.tphr_list[name]
|
name2 = tp.tphr_list[name]
|
||||||
minetest.chat_send_player(name2, S("Teleport request denied."))
|
minetest.chat_send_player(name2, S("Teleport request denied."))
|
||||||
@ -396,8 +406,29 @@ function tp.tpr_deny(name)
|
|||||||
chat2.send_message(minetest.get_player_by_name(name2), S("Teleport request denied."), 0xFFFFFF)
|
chat2.send_message(minetest.get_player_by_name(name2), S("Teleport request denied."), 0xFFFFFF)
|
||||||
chat2.send_message(minetest.get_player_by_name(name), S("You denied the request @1 sent you.", name2), 0xFFFFFF)
|
chat2.send_message(minetest.get_player_by_name(name), S("You denied the request @1 sent you.", name2), 0xFFFFFF)
|
||||||
end
|
end
|
||||||
|
|
||||||
tp.tphr_list[name] = nil
|
tp.tphr_list[name] = nil
|
||||||
|
|
||||||
|
-- Don't allow re-denying requests.
|
||||||
|
tp.tpn_list[name2] = nil
|
||||||
|
|
||||||
|
elseif tp.tpn_list[name] then
|
||||||
|
name2 = tp.tpn_list[name]
|
||||||
|
minetest.chat_send_player(name, S("You denied your request sent to @1.", name2))
|
||||||
|
minetest.chat_send_player(name2, S("@1 denied their request sent to you.", name))
|
||||||
|
if minetest.get_modpath("chat2") then
|
||||||
|
chat2.send_message(minetest.get_player_by_name(name), S("You denied your request sent to @1.", name2), 0xFFFFFF)
|
||||||
|
chat2.send_message(minetest.get_player_by_name(name2), S("@1 denied their request sent to you.", name), 0xFFFFFF)
|
||||||
|
end
|
||||||
|
|
||||||
|
if tp.tpr_list[name2] then
|
||||||
|
tp.tpr_list[name2] = nil
|
||||||
|
|
||||||
|
elseif tp.tphr_list[name2] then
|
||||||
|
tp.tphr_list[name2] = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
tp.tpn_list[name] = nil
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(name, S("Usage: /tpn allows you to deny teleport requests sent to you by other players."))
|
minetest.chat_send_player(name, S("Usage: /tpn allows you to deny teleport requests sent to you by other players."))
|
||||||
if minetest.get_modpath("chat2") then
|
if minetest.get_modpath("chat2") then
|
||||||
@ -448,6 +479,12 @@ function tp.tpr_accept(name)
|
|||||||
|
|
||||||
tp.tpr_teleport_player()
|
tp.tpr_teleport_player()
|
||||||
|
|
||||||
|
-- Don't allow re-denying requests.
|
||||||
|
if tp.tpn_list[name] or tp.tpn_list[name2] then
|
||||||
|
tp.tpn_list[name] = nil
|
||||||
|
tp.tpn_list[name2] = nil
|
||||||
|
end
|
||||||
|
|
||||||
minetest.chat_send_player(name, chatmsg)
|
minetest.chat_send_player(name, chatmsg)
|
||||||
if minetest.get_modpath("chat2") then
|
if minetest.get_modpath("chat2") then
|
||||||
chat2.send_message(minetest.get_player_by_name(name), chatmsg, 0xFFFFFF)
|
chat2.send_message(minetest.get_player_by_name(name), chatmsg, 0xFFFFFF)
|
||||||
|
8
init.lua
8
init.lua
@ -33,7 +33,8 @@ local S = dofile(MP.."/intllib.lua")
|
|||||||
tp = {
|
tp = {
|
||||||
intllib = S,
|
intllib = S,
|
||||||
tpr_list = {},
|
tpr_list = {},
|
||||||
tphr_list = {}
|
tphr_list = {},
|
||||||
|
tpn_list = {}
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Clear requests when the player leaves
|
-- Clear requests when the player leaves
|
||||||
@ -47,6 +48,11 @@ minetest.register_on_leaveplayer(function(name)
|
|||||||
tp.tphr_list[name] = nil
|
tp.tphr_list[name] = nil
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if tp.tpn_list[name] then
|
||||||
|
tp.tpn_list[name] = nil
|
||||||
|
return
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
dofile(MP.."/privileges.lua")
|
dofile(MP.."/privileges.lua")
|
||||||
|
10
locale/es.po
10
locale/es.po
@ -1,7 +1,7 @@
|
|||||||
# Spanish translation for Teleport Request.
|
# Spanish translation for Teleport Request.
|
||||||
# Copyright (C) 2014-2020 ChaosWormz and contributors.
|
# Copyright (C) 2014-2020 ChaosWormz and contributors.
|
||||||
# This file is distributed under under the same license as the Teleport Request package.
|
# This file is distributed under under the same license as the Teleport Request package.
|
||||||
# David Leal <halfpacho@gmail.com>, 2019.
|
# David Leal <halfpacho@gmail.com>, 2019-2020.
|
||||||
|
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@ -100,6 +100,14 @@ msgstr "Solicitud denegada."
|
|||||||
msgid "You denied the request @1 sent you."
|
msgid "You denied the request @1 sent you."
|
||||||
msgstr "Tú denegaste la solicitud de teletransporte que @1 te mando."
|
msgstr "Tú denegaste la solicitud de teletransporte que @1 te mando."
|
||||||
|
|
||||||
|
#: init.lua
|
||||||
|
msgid "You denied your request sent to @1."
|
||||||
|
msgstr "Tú denegaste la solicitud de teletransporte enviada a @1."
|
||||||
|
|
||||||
|
#: init.lua
|
||||||
|
msgid "@1 denied their request sent to you."
|
||||||
|
msgstr "@1 denego su solicitud de teletransporte enviada a usted."
|
||||||
|
|
||||||
#: init.lua
|
#: init.lua
|
||||||
msgid "Usage: /tpn allows you to deny teleport requests sent to you by other players."
|
msgid "Usage: /tpn allows you to deny teleport requests sent to you by other players."
|
||||||
msgstr "Uso: /tpn te permite denegar solicitudes enviadas para ti de otros jugadores."
|
msgstr "Uso: /tpn te permite denegar solicitudes enviadas para ti de otros jugadores."
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# Template translation for Teleport Request.
|
# Template translation for Teleport Request.
|
||||||
# Copyright (C) 2014-2020 ChaosWormz and contributors.
|
# Copyright (C) 2014-2020 ChaosWormz and contributors.
|
||||||
# This file is distributed under under the same license as the Teleport Request package.
|
# This file is distributed under under the same license as the Teleport Request package.
|
||||||
# David Leal <halfpacho@gmail.com>, 2019.
|
# David Leal <halfpacho@gmail.com>, 2019-2020.
|
||||||
|
|
||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@ -100,6 +100,14 @@ msgstr ""
|
|||||||
msgid "You denied the request @1 sent you."
|
msgid "You denied the request @1 sent you."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: init.lua
|
||||||
|
msgid "You denied your request sent to @1."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: init.lua
|
||||||
|
msgid "@1 denied their request sent to you."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: init.lua
|
#: init.lua
|
||||||
msgid "Usage: /tpn allows you to deny teleport requests sent to you by other players."
|
msgid "Usage: /tpn allows you to deny teleport requests sent to you by other players."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
Loading…
Reference in New Issue
Block a user