Skip to content

Commit

Permalink
Edited DarkRP.findPlayers to cycle from 1 to #
Browse files Browse the repository at this point in the history
  • Loading branch information
IP1A authored and FPtje committed Mar 16, 2024
1 parent 4245edf commit 2d81dd9
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions gamemode/modules/base/sh_util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,25 @@ function DarkRP.findPlayers(info)
local InfoPlayers = {}
for A in string.gmatch(info .. ";", "([a-zA-Z0-9:_.]*)[;(,%s)%c]") do
if A ~= "" then
table.insert(InfoPlayers, A)
InfoPlayers[#InfoPlayers+1] = A
end
end

for _, PlayerInfo in ipairs(InfoPlayers) do
for _ = 1, #InfoPlayers do
local PlayerInfo = InfoPlayers[_]
-- Playerinfo is always to be treated as UserID when it's a number
-- otherwise people with numbers in their names could get confused with UserID's of other players
if tonumber(PlayerInfo) then
if IsValid(Player(PlayerInfo)) and not found[Player(PlayerInfo)] then
found[Player(PlayerInfo)] = true
players = players or {}
table.insert(players, Player(PlayerInfo))
players[#players+1] = Player(PlayerInfo)
end
continue
end

for _, v in ipairs(pls) do
for _ = 1, #pls do
local v = pls[_]
-- Prevend duplicates
if found[v] then continue end

Expand All @@ -125,7 +127,7 @@ function DarkRP.findPlayers(info)
(v.SteamName and string.find(string.lower(v:SteamName()), string.lower(tostring(PlayerInfo)), 1, true) ~= nil) then
found[v] = true
players = players or {}
table.insert(players, v)
players[#players+1]=v
end
end
end
Expand Down

0 comments on commit 2d81dd9

Please sign in to comment.