mirror of
https://github.com/minetest-mods/teleport-request.git
synced 2025-01-19 19:31:26 +01:00
Adjust various lines of code
This commit is contained in:
parent
2620063046
commit
6fd408f5dd
284
init.lua
284
init.lua
@ -112,21 +112,6 @@ function tp.parti2(pos)
|
||||
"tps_portal_parti.png")
|
||||
end
|
||||
|
||||
-- Teleport Request System
|
||||
function tp.clear_tpr_list(name)
|
||||
if tp.tpr_list[name] then
|
||||
tp.tpr_list[name] = nil
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
function tp.clear_tphr_list(name)
|
||||
if tp.tphr_list[name] then
|
||||
tp.tphr_list[name] = nil
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- Clear requests when the player leaves
|
||||
minetest.register_on_leaveplayer(function(name)
|
||||
if tp.tpr_list[name] then
|
||||
@ -140,6 +125,7 @@ minetest.register_on_leaveplayer(function(name)
|
||||
end
|
||||
end)
|
||||
|
||||
-- Teleport Request System
|
||||
function tp.tpr_send(sender, receiver)
|
||||
-- Compatibility with beerchat
|
||||
if minetest.get_modpath("beerchat") and not minetest.check_player_privs(sender, {tp_admin = true}) then
|
||||
@ -161,77 +147,83 @@ function tp.tpr_send(sender, receiver)
|
||||
end
|
||||
end
|
||||
|
||||
if minetest.check_player_privs(sender, {tp_admin = true}) and tp.enable_immediate_teleport then
|
||||
if receiver == "" then
|
||||
minetest.chat_send_player(sender, S("Usage: /tpr <Player name>"))
|
||||
if minetest.get_modpath("chat2") then
|
||||
chat2.send_message(minetest.get_player_by_name(sender), S("Usage: /tpr <Player name>"), 0xFFFFFF)
|
||||
end
|
||||
return
|
||||
end
|
||||
if not minetest.get_player_by_name(receiver) then
|
||||
minetest.chat_send_player(sender, S("There is no player by that name. Keep in mind this is case-sensitive, and the player must be online"))
|
||||
if minetest.get_modpath("chat2") then
|
||||
chat2.send_message(minetest.get_player_by_name(sender), S("There is no player by that name. Keep in mind this is case-sensitive, and the player must be online"), 0xFFFFFF)
|
||||
end
|
||||
return
|
||||
end
|
||||
tp.tpr_list[receiver] = sender
|
||||
tp.tpr_accept(receiver)
|
||||
if minetest.check_player_privs(sender, {tp_admin = true}) and tp.enable_immediate_teleport then
|
||||
if receiver == "" then
|
||||
minetest.chat_send_player(sender, S("Usage: /tpr <Player name>"))
|
||||
if minetest.get_modpath("chat2") then
|
||||
chat2.send_message(minetest.get_player_by_name(sender), S("Usage: /tpr <Player name>"), 0xFFFFFF)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if not minetest.get_player_by_name(receiver) then
|
||||
minetest.chat_send_player(sender, S("There is no player by that name. Keep in mind this is case-sensitive, and the player must be online"))
|
||||
if minetest.get_modpath("chat2") then
|
||||
chat2.send_message(minetest.get_player_by_name(sender), S("There is no player by that name. Keep in mind this is case-sensitive, and the player must be online"), 0xFFFFFF)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
tp.tpr_list[receiver] = sender
|
||||
tp.tpr_accept(receiver)
|
||||
minetest.chat_send_player(sender, S("You are teleporting to @1.", receiver))
|
||||
if minetest.get_modpath("chat2") then
|
||||
chat2.send_message(minetest.get_player_by_name(sender), S("You are teleporting to @1.", receiver), 0xFFFFFF)
|
||||
end
|
||||
return
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if receiver == "" then
|
||||
minetest.chat_send_player(sender, S("Usage: /tpr <Player name>"))
|
||||
if minetest.get_modpath("chat2") then
|
||||
chat2.send_message(minetest.get_player_by_name(sender), S("Usage: /tpr <Player name>"), 0xFFFFFF)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if not minetest.get_player_by_name(receiver) then
|
||||
minetest.chat_send_player(sender, S("There is no player by that name. Keep in mind this is case-sensitive, and the player must be online"))
|
||||
if minetest.get_modpath("chat2") then
|
||||
chat2.send_message(minetest.get_player_by_name(sender), S("There is no player by that name. Keep in mind this is case-sensitive, and the player must be online"), 0xFFFFFF)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if minetest.get_modpath("gamehub") then -- Compatibility with gamehub (UNTESTED)
|
||||
if gamehub.players[receiver] then
|
||||
minetest.chat_send_player(sender, S("Teleport request denied, player is in the gamehub!"))
|
||||
if receiver == "" then
|
||||
minetest.chat_send_player(sender, S("Usage: /tpr <Player name>"))
|
||||
if minetest.get_modpath("chat2") then
|
||||
chat2.send_message(minetest.get_player_by_name(sender), S("Teleport request denied, player is in the gamehub!"), 0xFFFFFF)
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if minetest.get_modpath("chat2") then
|
||||
chat2.send_message(minetest.get_player_by_name(receiver), S("@1 is requesting to teleport to you. /tpy to accept", sender), 0xFFFFFF)
|
||||
chat2.send_message(minetest.get_player_by_name(sender), S("Teleport request sent! It will timeout in @1 seconds", tp.timeout_delay), 0xFFFFFF)
|
||||
end
|
||||
minetest.chat_send_player(receiver, S("@1 is requesting to teleport to you. /tpy to accept", sender))
|
||||
minetest.chat_send_player(sender, S("Teleport request sent! It will timeout in @1 seconds", tp.timeout_delay))
|
||||
-- Write name values to list and clear old values.
|
||||
tp.tpr_list[receiver] = sender
|
||||
-- Teleport timeout delay
|
||||
minetest.after(tp.timeout_delay, function(name)
|
||||
if tp.tpr_list[name] then
|
||||
tp.tpr_list[name] = nil
|
||||
minetest.chat_send_player(sender, S("Request timed-out."))
|
||||
minetest.chat_send_player(receiver, S("Request timed-out."))
|
||||
if minetest.get_modpath("chat2") then
|
||||
chat2.send_message(minetest.get_player_by_name(sender), S("Request timed-out."), 0xFFFFFF)
|
||||
chat2.send_message(minetest.get_player_by_name(receiver), S("Request timed-out."), 0xFFFFFF)
|
||||
chat2.send_message(minetest.get_player_by_name(sender), S("Usage: /tpr <Player name>"), 0xFFFFFF)
|
||||
end
|
||||
return
|
||||
end
|
||||
return
|
||||
end
|
||||
end, receiver)
|
||||
|
||||
if not minetest.get_player_by_name(receiver) then
|
||||
minetest.chat_send_player(sender, S("There is no player by that name. Keep in mind this is case-sensitive, and the player must be online"))
|
||||
if minetest.get_modpath("chat2") then
|
||||
chat2.send_message(minetest.get_player_by_name(sender), S("There is no player by that name. Keep in mind this is case-sensitive, and the player must be online"), 0xFFFFFF)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if minetest.get_modpath("gamehub") then -- Compatibility with gamehub (UNTESTED)
|
||||
if gamehub.players[receiver] then
|
||||
minetest.chat_send_player(sender, S("Teleport request denied, player is in the gamehub!"))
|
||||
if minetest.get_modpath("chat2") then
|
||||
chat2.send_message(minetest.get_player_by_name(sender), S("Teleport request denied, player is in the gamehub!"), 0xFFFFFF)
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if minetest.get_modpath("chat2") then
|
||||
chat2.send_message(minetest.get_player_by_name(receiver), S("@1 is requesting to teleport to you. /tpy to accept", sender), 0xFFFFFF)
|
||||
chat2.send_message(minetest.get_player_by_name(sender), S("Teleport request sent! It will timeout in @1 seconds", tp.timeout_delay), 0xFFFFFF)
|
||||
end
|
||||
|
||||
minetest.chat_send_player(receiver, S("@1 is requesting to teleport to you. /tpy to accept", sender))
|
||||
minetest.chat_send_player(sender, S("Teleport request sent! It will timeout in @1 seconds", tp.timeout_delay))
|
||||
|
||||
-- Write name values to list and clear old values.
|
||||
tp.tpr_list[receiver] = sender
|
||||
|
||||
-- Teleport timeout delay
|
||||
minetest.after(tp.timeout_delay, function(name)
|
||||
if tp.tpr_list[name] then
|
||||
tp.tpr_list[name] = nil
|
||||
minetest.chat_send_player(sender, S("Request timed-out."))
|
||||
minetest.chat_send_player(receiver, S("Request timed-out."))
|
||||
|
||||
if minetest.get_modpath("chat2") then
|
||||
chat2.send_message(minetest.get_player_by_name(sender), S("Request timed-out."), 0xFFFFFF)
|
||||
chat2.send_message(minetest.get_player_by_name(receiver), S("Request timed-out."), 0xFFFFFF)
|
||||
end
|
||||
return
|
||||
end
|
||||
end, receiver)
|
||||
end
|
||||
|
||||
function tp.tphr_send(sender, receiver)
|
||||
@ -255,78 +247,83 @@ function tp.tphr_send(sender, receiver)
|
||||
end
|
||||
end
|
||||
|
||||
if minetest.check_player_privs(sender, {tp_admin = true}) and tp.enable_immediate_teleport then
|
||||
if receiver == "" then
|
||||
minetest.chat_send_player(sender, S("Usage: /tphr <Player name>"))
|
||||
if minetest.get_modpath("chat2") then
|
||||
chat2.send_message(minetest.get_player_by_name(sender), S("Usage. /tphr <Player name>"), 0xFFFFFF)
|
||||
end
|
||||
return
|
||||
end
|
||||
if not minetest.get_player_by_name(receiver) then
|
||||
minetest.chat_send_player(sender, S("There is no player by that name. Keep in mind this is case-sensitive, and the player must be online"))
|
||||
if minetest.get_modpath("chat2") then
|
||||
chat2.send_message(minetest.get_player_by_name(sender), S("There is no player by that name. Keep in mind this is case-sensitive, and the player must be online"), 0xFFFFFF)
|
||||
end
|
||||
return
|
||||
end
|
||||
tp.tphr_list[receiver] = sender
|
||||
tp.tpr_accept(receiver)
|
||||
minetest.chat_send_player(sender, S("@1 is teleporting to you.", receiver))
|
||||
if minetest.get_modpath("chat2") then
|
||||
chat2.send_message(minetest.get_player_by_name(sender), S("@1 is teleporting to you.", receiver), 0xFFFFFF)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if receiver == "" then
|
||||
minetest.chat_send_player(sender, S("Usage: /tphr <Player name>"))
|
||||
if minetest.get_modpath("chat2") then
|
||||
chat2.send_message(minetest.get_player_by_name(sender), S("Usage. /tphr <Player name>"), 0xFFFFFF)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if not minetest.get_player_by_name(receiver) then
|
||||
minetest.chat_send_player(sender, S("There is no player by that name. Keep in mind this is case-sensitive, and the player must be online"))
|
||||
if minetest.get_modpath("chat2") then
|
||||
chat2.send_message(minetest.get_player_by_name(sender), S("There is no player by that name. Keep in mind this is case-sensitive, and the player must be online"), 0xFFFFFF)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if minetest.get_modpath("gamehub") then -- Compatibility with gamehub (UNTESTED)
|
||||
if gamehub.players[receiver] then
|
||||
minetest.chat_send_player(sender, S("Teleport request denied, player is in the gamehub!"))
|
||||
if minetest.check_player_privs(sender, {tp_admin = true}) and tp.enable_immediate_teleport then
|
||||
if receiver == "" then
|
||||
minetest.chat_send_player(sender, S("Usage: /tphr <Player name>"))
|
||||
if minetest.get_modpath("chat2") then
|
||||
chat2.send_message(minetest.get_player_by_name(sender), S("Teleport request denied, player is in the gamehub!"), 0xFFFFFF)
|
||||
end
|
||||
chat2.send_message(minetest.get_player_by_name(sender), S("Usage. /tphr <Player name>"), 0xFFFFFF)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if not minetest.get_player_by_name(receiver) then
|
||||
minetest.chat_send_player(sender, S("There is no player by that name. Keep in mind this is case-sensitive, and the player must be online"))
|
||||
if minetest.get_modpath("chat2") then
|
||||
chat2.send_message(minetest.get_player_by_name(sender), S("There is no player by that name. Keep in mind this is case-sensitive, and the player must be online"), 0xFFFFFF)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
tp.tphr_list[receiver] = sender
|
||||
tp.tpr_accept(receiver)
|
||||
minetest.chat_send_player(sender, S("@1 is teleporting to you.", receiver))
|
||||
if minetest.get_modpath("chat2") then
|
||||
chat2.send_message(minetest.get_player_by_name(sender), S("@1 is teleporting to you.", receiver), 0xFFFFFF)
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if minetest.get_modpath("chat2") then
|
||||
chat2.send_message(minetest.get_player_by_name(receiver), S("@1 is requesting that you teleport to them. /tpy to accept; /tpn to deny", sender), 0xFFFFFF)
|
||||
chat2.send_message(minetest.get_player_by_name(sender), S("Teleport request sent! It will timeout in @1 seconds", tp.timeout_delay), 0xFFFFFF)
|
||||
end
|
||||
if receiver == "" then
|
||||
minetest.chat_send_player(sender, S("Usage: /tphr <Player name>"))
|
||||
if minetest.get_modpath("chat2") then
|
||||
chat2.send_message(minetest.get_player_by_name(sender), S("Usage. /tphr <Player name>"), 0xFFFFFF)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if not minetest.get_player_by_name(receiver) then
|
||||
minetest.chat_send_player(sender, S("There is no player by that name. Keep in mind this is case-sensitive, and the player must be online"))
|
||||
if minetest.get_modpath("chat2") then
|
||||
chat2.send_message(minetest.get_player_by_name(sender), S("There is no player by that name. Keep in mind this is case-sensitive, and the player must be online"), 0xFFFFFF)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if minetest.get_modpath("gamehub") then -- Compatibility with gamehub (UNTESTED)
|
||||
if gamehub.players[receiver] then
|
||||
minetest.chat_send_player(sender, S("Teleport request denied, player is in the gamehub!"))
|
||||
if minetest.get_modpath("chat2") then
|
||||
chat2.send_message(minetest.get_player_by_name(sender), S("Teleport request denied, player is in the gamehub!"), 0xFFFFFF)
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if minetest.get_modpath("chat2") then
|
||||
chat2.send_message(minetest.get_player_by_name(receiver), S("@1 is requesting that you teleport to them. /tpy to accept; /tpn to deny", sender), 0xFFFFFF)
|
||||
chat2.send_message(minetest.get_player_by_name(sender), S("Teleport request sent! It will timeout in @1 seconds", tp.timeout_delay), 0xFFFFFF)
|
||||
end
|
||||
|
||||
minetest.chat_send_player(receiver, S("@1 is requesting that you teleport to them. /tpy to accept; /tpn to deny", sender))
|
||||
minetest.chat_send_player(sender, S("Teleport request sent! It will timeout in @1 seconds", tp.timeout_delay))
|
||||
|
||||
-- Write name values to list and clear old values.
|
||||
tp.tphr_list[receiver] = sender
|
||||
|
||||
-- Teleport timeout delay
|
||||
minetest.after(tp.timeout_delay, function(name)
|
||||
if tp.tphr_list[name] then
|
||||
tp.tphr_list[name] = nil
|
||||
minetest.chat_send_player(sender, S("Request timed-out."))
|
||||
minetest.chat_send_player(receiver, S("Request timed-out."))
|
||||
|
||||
minetest.chat_send_player(receiver, S("@1 is requesting that you teleport to them. /tpy to accept; /tpn to deny", sender))
|
||||
minetest.chat_send_player(sender, S("Teleport request sent! It will timeout in @1 seconds", tp.timeout_delay))
|
||||
-- Write name values to list and clear old values.
|
||||
tp.tphr_list[receiver] = sender
|
||||
-- Teleport timeout delay
|
||||
minetest.after(tp.timeout_delay, function(name)
|
||||
if tp.tphr_list[name] then
|
||||
tp.tphr_list[name] = nil
|
||||
minetest.chat_send_player(sender, S("Request timed-out."))
|
||||
minetest.chat_send_player(receiver, S("Request timed-out."))
|
||||
if minetest.get_modpath("chat2") then
|
||||
chat2.send_message(minetest.get_player_by_name(sender), S("Request timed-out"), 0xFFFFFF)
|
||||
chat2.send_message(minetest.get_player_by_name(receiver), S("Request timed-out"), 0xFFFFFF)
|
||||
end
|
||||
return
|
||||
end
|
||||
end, receiver)
|
||||
end
|
||||
return
|
||||
end
|
||||
end, receiver)
|
||||
end
|
||||
|
||||
function tp.tpc_send(player, coordinates)
|
||||
@ -427,6 +424,7 @@ end
|
||||
|
||||
-- Teleport Accept Systems
|
||||
function tp.tpr_accept(name, param)
|
||||
|
||||
-- Check to prevent constant teleporting.
|
||||
if not tp.tpr_list[name] and not tp.tphr_list[name] then
|
||||
minetest.chat_send_player(name, S("Usage: /tpy allows you to accept teleport requests sent to you by other players"))
|
||||
|
Loading…
Reference in New Issue
Block a user