From 2d81dd9391290dca05808ae3ba211d70d67e02bd Mon Sep 17 00:00:00 2001 From: biest <57289047+IP1A@users.noreply.github.com> Date: Wed, 6 Mar 2024 16:21:30 +0300 Subject: [PATCH] Edited DarkRP.findPlayers to cycle from 1 to # --- gamemode/modules/base/sh_util.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/gamemode/modules/base/sh_util.lua b/gamemode/modules/base/sh_util.lua index 954ab803b..26907a527 100644 --- a/gamemode/modules/base/sh_util.lua +++ b/gamemode/modules/base/sh_util.lua @@ -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 @@ -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