Skip to content

Commit

Permalink
Allow GMs to summon players via tool #342
Browse files Browse the repository at this point in the history
  • Loading branch information
brightrim committed Feb 19, 2024
1 parent 0b2c8f0 commit ffcc5a5
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion gm/items/id_99_lockpicks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,40 @@ local function setuserTeleporter(user,Item)
user:requestSelectionDialog(sdTeleport)
end

local function summon(user, sourceItem)

local listedPlayers = {}

local onlinePlayers = world:getPlayersOnline()

local callback = function (dialog)

if (not dialog:getSuccess()) then
return
end

local playerToSummon = listedPlayers[dialog:getSelectedIndex() + 1]

if isValidChar(playerToSummon) then
playerToSummon:warp(position(user.pos.x, user.pos.y, user.pos.z))
else
user:inform("This character is not online anymore.")
end
end

local dialog = SelectionDialog("Summon", "Choose the player you wish to summon to your present location", callback)

for _, player in ipairs (onlinePlayers) do
if player.id ~= user.id then
dialog:addOption(0, player.name)
table.insert(listedPlayers, player)
end
end

user:requestSelectionDialog(dialog)

end

local function teleporter(user,item)
local validTarget = {}
local validCharPos = {}
Expand Down Expand Up @@ -1787,7 +1821,7 @@ function M.UseItem(user, SourceItem, ltstate)
user:increaseAttrib("foodlevel", 100000)

-- First check for mode change
local modes = {"Eraser", "Teleport", "Instant kill/ revive", "Char Settings", "Global events", "Events on single char", "Events on groups", "Faction info of chars in radius", "Quest events","Define Teleporter Targets","Define events on single char","Define events on groups","Test area","Reset tutorial","Persistence"}
local modes = {"Eraser", "Teleport", "Summon", "Instant kill/ revive", "Char Settings", "Global events", "Events on single char", "Events on groups", "Faction info of chars in radius", "Quest events","Define Teleporter Targets","Define events on single char","Define events on groups","Test area","Reset tutorial","Persistence"}
local cbSetMode = function (dialog)
if (not dialog:getSuccess()) then
return
Expand All @@ -1797,6 +1831,8 @@ function M.UseItem(user, SourceItem, ltstate)
eraser(user)
elseif index == 2 then
teleporter(user, SourceItem)
elseif index == 3 then
summon(user, SourceItem)
elseif index == 3 then
godMode(user, SourceItem, ltstate)
elseif index == 4 then
Expand Down

0 comments on commit ffcc5a5

Please sign in to comment.