Cleaned admin menu
This commit is contained in:
@@ -1,31 +1,52 @@
|
|||||||
|
|
||||||
local CommandsData = require("TOC/CommandsData")
|
local CommandsData = require("TOC/CommandsData")
|
||||||
|
-------------------
|
||||||
|
|
||||||
---@param playerNum number
|
---@param playerNum number
|
||||||
---@param context ISContextMenu
|
---@param context ISContextMenu
|
||||||
---@param items any
|
---@param worldobjects table
|
||||||
local function AddAdminTocOptions(playerNum, context, items)
|
local function AddAdminTocOptions(playerNum, context, worldobjects)
|
||||||
if not isAdmin() then return end
|
if not isAdmin() then return end
|
||||||
|
|
||||||
-- This is a global var already handled in vanilla zomboid, we don't need to find the player once again
|
local players = {}
|
||||||
---@cast clickedPlayer IsoPlayer
|
for _,v in ipairs(worldobjects) do
|
||||||
if clickedPlayer then
|
|
||||||
|
|
||||||
local clickedPlayerNum = clickedPlayer:getOnlineID()
|
for x=v:getSquare():getX()-1,v:getSquare():getX()+1 do
|
||||||
|
for y=v:getSquare():getY()-1,v:getSquare():getY()+1 do
|
||||||
|
local sq = getCell():getGridSquare(x,y,v:getSquare():getZ());
|
||||||
|
if sq then
|
||||||
|
for z=0,sq:getMovingObjects():size()-1 do
|
||||||
|
local o = sq:getMovingObjects():get(z)
|
||||||
|
if instanceof(o, "IsoPlayer") then
|
||||||
|
|
||||||
local option = context:addOption(getText("ContextMenu_Admin_TOC"), items, nil)
|
---@cast o IsoPlayer
|
||||||
|
|
||||||
|
local oId = o:getOnlineID()
|
||||||
|
players[oId] = o
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
for _, pl in pairs(players) do
|
||||||
|
|
||||||
|
---@cast pl IsoPlayer
|
||||||
|
|
||||||
|
local clickedPlayerNum = pl:getOnlineID()
|
||||||
|
|
||||||
|
local option = context:addOption(getText("ContextMenu_Admin_TOC") .. " - " .. pl:getUsername(), nil, nil)
|
||||||
local subMenu = ISContextMenu:getNew(context)
|
local subMenu = ISContextMenu:getNew(context)
|
||||||
context:addSubMenu(option, subMenu)
|
context:addSubMenu(option, subMenu)
|
||||||
|
|
||||||
subMenu:addOption(getText("ContextMenu_Admin_ResetTOC") .. " - " .. clickedPlayer:getUsername(), items, function()
|
subMenu:addOption(getText("ContextMenu_Admin_ResetTOC"), nil, function()
|
||||||
sendClientCommand(CommandsData.modules.TOC_RELAY, CommandsData.server.Relay.RelayExecuteInitialization, {patientNum=clickedPlayerNum} )
|
sendClientCommand(CommandsData.modules.TOC_RELAY, CommandsData.server.Relay.RelayExecuteInitialization, {patientNum=clickedPlayerNum} )
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- TODO add other options
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
Events.OnFillWorldObjectContextMenu.Add(AddAdminTocOptions)
|
Events.OnFillWorldObjectContextMenu.Add(AddAdminTocOptions)
|
||||||
Reference in New Issue
Block a user