Skip to content

Conversation

overlordbleck
Copy link
Contributor

No description provided.

@overlordbleck overlordbleck self-assigned this Jul 14, 2022
@overlordbleck overlordbleck added the bug Something isn't working label Jul 14, 2022
Comment on lines +6 to +23
local function isTargetPlayer( ply, targetPlayers )
for _, p in pairs( targetPlayers ) do
if p == ply then
return true
end
end

return false
end

function cmd.arrest( callingPlayer, targetPlayers )
local entities = ents.GetAll()
local entCount = 0
local entCounts = {}

for _, ent in ipairs( entities ) do
local owner = ent.CPPIGetOwner and ent:CPPIGetOwner()
if owner and entCounts[owner] then
if owner and isTargetPlayer( owner ) then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead we could make a lookup table first, which would only loop through the players once

function cmd.arrest( callingPlayer, targetPlayers )
    local entities = ents.GetAll()
    local entCount = 0
    local entCounts = {}

    local targetLookup= {}
    for _, ply in ipairs( targetPlayers ) do
        targetLookup[ply] = true
    end

    for _, ent in ipairs( entities ) do
        local owner = ent.CPPIGetOwner and ent:CPPIGetOwner() or ent:GetOwner()
        if owner and targetLookup[owner] then

@sarahsturgeon sarahsturgeon changed the base branch from master to dev July 27, 2022 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants