-
-
Notifications
You must be signed in to change notification settings - Fork 666
/
Copy pathteleport_to_player.lua
62 lines (53 loc) · 1.66 KB
/
teleport_to_player.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
local teleportToCreature = TalkAction("/listplayers")
function teleportToCreature.onSay(player, words, param)
-- create log
logCommand(player, words, param)
local showAll = param == "all" and true or false
local players = Game.getPlayers()
local playerList = {}
for _, targetPlayer in ipairs(players) do
if targetPlayer:getName() == player:getName() then
goto continue
end
if showAll then
table.insert(playerList, targetPlayer)
else
local isGhost = targetPlayer:isInGhostMode()
local isTraining = _G.OnExerciseTraining[targetPlayer:getId()]
local isIdle = targetPlayer:getIdleTime() >= 5 * 60 * 1000
local isInTrainingRoom = targetPlayer:getPosition():isInRange(Position(1015, 1109, 7), Position(1094, 1738, 7))
local isActive = not isGhost and not isTraining and not isIdle and not isInTrainingRoom
if isActive then
table.insert(playerList, targetPlayer)
end
end
::continue::
end
if #playerList == 0 then
player:sendCancelMessage("There are no active players.")
return true
end
local window = ModalWindow({
title = "Teleport to Player",
message = "select player to teleport",
})
for _, targetPlayer in pairs(playerList) do
if targetPlayer then
window:addChoice(targetPlayer:getName(), function(player, button, choice)
if button.name ~= "Select" then
return true
end
player:teleportTo(targetPlayer:getPosition())
end)
end
end
window:addButton("Select")
window:addButton("Close")
window:setDefaultEnterButton(0)
window:setDefaultEscapeButton(1)
window:sendToPlayer(player)
return true
end
teleportToCreature:separator(" ")
teleportToCreature:groupType("gamemaster")
teleportToCreature:register()