Skip to content

Commit

Permalink
Merge pull request #409 from marchc1/scanner
Browse files Browse the repository at this point in the history
Built-in Component Scanner
  • Loading branch information
thecraftianman authored Jun 25, 2024
2 parents 533b9c3 + 2a9f901 commit fa8e209
Show file tree
Hide file tree
Showing 3 changed files with 1,520 additions and 0 deletions.
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

0 comments on commit fa8e209

Please sign in to comment.