Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Built-in Component Scanner #409

Merged
merged 4 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions lua/acf/menu/items_cl/scanner.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
local ACF = ACF

local function CreateMenu(Menu)
Menu:AddTitle("Scan a Player [WIP!]")
Menu:AddLabel([[Select a player below, then hit the Scan Player button. You will enter a spectator perspective mode that allows you to visualize the components of a contraption.

Rotate the camera with your mouse, and use WASD Space/Control to move your location relative to the target.
Use the scroll wheel to increase/decrease your movement speed.
Advanced controls are given to you on the top-right of your screen.

This was designed to help the community hold each other accountable, and can help with catching some often used exploits and cheating methods. It is still a work in progress, and there are a lot of features missing. Please report any issues on the GitHub repository.]])

local playerList = Menu:AddPanel("DListView")
playerList:Dock(TOP)
playerList:SetSize(0, 300)
playerList:SetMultiSelect(false)

playerList:AddColumn("Player Name")
local function PopulatePlayerList()
print("PopulatePlayerList called")
local _, selected = playerList:GetSelectedLine()
if IsValid(selected) and IsValid(selected.player) then
selected = selected.player
end

playerList:Clear()

for _, v in ipairs(player.GetAll()) do
local line = playerList:AddLine(v:Nick())
line.player = v
if line.player == selected then
playerList:SelectItem(line)
end
end
end
PopulatePlayerList()

net.Receive("ACF.Scanning.PlayerListChanged", function()
timer.Simple(1, function()
PopulatePlayerList()
end)
end)

local btn = Menu:AddButton("Scan Player")
local btn2 = Menu:AddButton("Refresh Players")
btn:Dock(TOP)
function btn:DoClickInternal()
local _, selected = playerList:GetSelectedLine()
if not IsValid(selected) then
Derma_Message("No player selected.", "Scanner Failure", "Go back")
return
end

ACF.Scanning.BeginScanning(selected.player)
end
function btn2:DoClickInternal()
PopulatePlayerList()
end
end

ACF.AddMenuItem(401, "Scanner", "Scan a Player...", "transmit", CreateMenu)
2 changes: 2 additions & 0 deletions lua/acf/menu/spawn_menu_cl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ do -- Menu population functions
ACF.AddMenuOption(101, "Settings", "wrench")
ACF.AddMenuOption(201, "Entities", "brick")
ACF.AddMenuOption(9999, "Fun Stuff", "bricks")
ACF.AddMenuOption(100000, "Scanner", "magnifier")
end


do -- ACF Menu context panel
local function GetSortedList(List)
local Result = {}
Expand Down
Loading
Loading