Skip to content

Commit

Permalink
Search by 1 type at a time
Browse files Browse the repository at this point in the history
  • Loading branch information
lionbryce authored May 24, 2024
1 parent a266f9f commit 4c42451
Showing 1 changed file with 48 additions and 18 deletions.
66 changes: 48 additions & 18 deletions gamemode/modules/base/sh_util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,28 +58,58 @@ end
Find a player based on given information
---------------------------------------------------------------------------]]
function DarkRP.findPlayer(info)
if not info or info == "" then return nil end
local pls = player.GetAll()

for k = 1, #pls do -- Proven to be faster than pairs loop.
local v = pls[k]
if tonumber(info) == v:UserID() then
return v
end

if info == v:SteamID() then
return v
end

if string.find(string.lower(v:Nick()), string.lower(tostring(info)), 1, true) ~= nil then
return v
if not info or info == "" then return nil end

Check warning on line 61 in gamemode/modules/base/sh_util.lua

View workflow job for this annotation

GitHub Actions / Lint / lint

"Syntax inconsistency"

Inconsistent use of tabs and spaces for indentation
local pls = player.GetAll()

Check warning on line 63 in gamemode/modules/base/sh_util.lua

View workflow job for this annotation

GitHub Actions / Lint / lint

"Trailing whitespace"

Trailing whitespace
local count = #pls
local numberInfo = tonumber(info)
local lowerInfo = string.lower(tostring(info))

Check warning on line 66 in gamemode/modules/base/sh_util.lua

View workflow job for this annotation

GitHub Actions / Lint / lint

"Syntax inconsistency"

Inconsistent use of tabs and spaces for indentation

if numberInfo then -- since we'll be doing alot of scanning, need to make sure

Check warning on line 68 in gamemode/modules/base/sh_util.lua

View workflow job for this annotation

GitHub Actions / Lint / lint

"Syntax inconsistency"

Inconsistent use of tabs and spaces for indentation
for k = 1, count do
local v = pls[k]

Check warning on line 71 in gamemode/modules/base/sh_util.lua

View workflow job for this annotation

GitHub Actions / Lint / lint

"Trailing whitespace"

Trailing whitespace
if numberInfo == v:UserID() then -- darkrp relies on this being first
return v
end
end

if string.find(string.lower(v:SteamName()), string.lower(tostring(info)), 1, true) ~= nil then
return v
for k = 1, count do -- this loop could likely be combined with the above loop
local v = pls[k]

Check warning on line 79 in gamemode/modules/base/sh_util.lua

View workflow job for this annotation

GitHub Actions / Lint / lint

"Trailing whitespace"

Trailing whitespace
if info == v:SteamID64() then
return v
end
end
end

Check warning on line 84 in gamemode/modules/base/sh_util.lua

View workflow job for this annotation

GitHub Actions / Lint / lint

"Syntax inconsistency"

Inconsistent use of tabs and spaces for indentation
return nil

if string.StartsWith(lowerInfo, "steam_") then

Check warning on line 86 in gamemode/modules/base/sh_util.lua

View workflow job for this annotation

GitHub Actions / Lint / lint

"Syntax inconsistency"

Inconsistent use of tabs and spaces for indentation
for k = 1, count do
local v = pls[k]

Check warning on line 89 in gamemode/modules/base/sh_util.lua

View workflow job for this annotation

GitHub Actions / Lint / lint

"Trailing whitespace"

Trailing whitespace
if info == v:SteamID() then
return v
end
end
end

for k = 1, count do
local v = pls[k]

if string.find(string.lower(v:Nick()), lowerInfo, 1, true) ~= nil then
return v
end
end

for k = 1, count do
local v = pls[k]

if string.find(string.lower(v:SteamName()), lowerInfo, 1, true) ~= nil then
return v
end
end

return nil
end

--[[---------------------------------------------------------------------------
Expand Down

0 comments on commit 4c42451

Please sign in to comment.