-
-
Notifications
You must be signed in to change notification settings - Fork 669
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created script to show list of active players and teleport to player …
…selected.
- Loading branch information
1 parent
928fa2f
commit 554f2c2
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
local teleportToCreature = TalkAction("/activelist") | ||
|
||
function teleportToCreature.onSay(player, words, param) | ||
-- create log | ||
logCommand(player, words, param) | ||
|
||
local onlyActive = param == "active" and true or false | ||
|
||
local players = Game.getPlayers() | ||
local playerList = {} | ||
|
||
for _, targetPlayer in ipairs(players) do | ||
if not onlyActive then | ||
table.insert(playerList, targetPlayer) | ||
else | ||
local isGhost = targetPlayer:isInGhostMode() | ||
local isTraining = onExerciseTraining[targetPlayer:getId()] | ||
local isIdle = targetPlayer:getIdleTime() >= 5 * 60 * 1000 | ||
local isActive = not isGhost and not isTraining and not isIdle | ||
if isActive then | ||
table.insert(playerList, targetPlayer) | ||
end | ||
end | ||
end | ||
|
||
if #playerList == 0 then | ||
player:sendCancelMessage("There are no active players.") | ||
return false | ||
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() |