From 4dc2a46dc3156fc0e0454cf7b8ac5328b7d08da9 Mon Sep 17 00:00:00 2001 From: Linventif Date: Tue, 9 Jul 2024 09:07:59 +0000 Subject: [PATCH] opti: pairs(player.GetAll()) -> ipairs(player.GetAll()) --- lua/gmod_integration/server/sv_con.lua | 2 +- lua/gmod_integration/server/sv_players.lua | 2 +- lua/gmod_integration/server/sv_settings.lua | 2 +- lua/gmod_integration/shared/sh_api_format.lua | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/gmod_integration/server/sv_con.lua b/lua/gmod_integration/server/sv_con.lua index 8c6f842..94300e0 100644 --- a/lua/gmod_integration/server/sv_con.lua +++ b/lua/gmod_integration/server/sv_con.lua @@ -6,7 +6,7 @@ local conFuncs = { ["get-server-id"] = function() print(gmInte.config.id || "none") end, ["screenshot"] = function(args) if !args[2] then return gmInte.log("No SteamID64 provided") end - for _, ply in pairs(player.GetAll()) do + for _, ply in ipairs(player.GetAll()) do if ply:SteamID64() == args[2] then return gmInte.takeScreenshot(ply) end end end, diff --git a/lua/gmod_integration/server/sv_players.lua b/lua/gmod_integration/server/sv_players.lua index 91dddcd..f90602f 100644 --- a/lua/gmod_integration/server/sv_players.lua +++ b/lua/gmod_integration/server/sv_players.lua @@ -90,7 +90,7 @@ end hook.Add("gmInte:PlayerReady", "gmInte:Player:Ready", function(ply) gmInte.playerReady(ply) end) hook.Add("ShutDown", "gmInte:Server:Shutdown:SavePlayers", function() - for ply, ply in pairs(player.GetAll()) do + for ply, ply in ipairs(player.GetAll()) do gmInte.playerDisconnected(ply) end end) diff --git a/lua/gmod_integration/server/sv_settings.lua b/lua/gmod_integration/server/sv_settings.lua index 41f5df5..1191502 100644 --- a/lua/gmod_integration/server/sv_settings.lua +++ b/lua/gmod_integration/server/sv_settings.lua @@ -14,7 +14,7 @@ function gmInte.saveSetting(setting, value) gmInte.log("Setting Saved") if value == "websocketFQDN" || value == "id" || value == "token" then gmInte.resetWebSocket() end // send to all players the new public config - for _, ply in pairs(player.GetAll()) do + for _, ply in ipairs(player.GetAll()) do if ply:IsValid() && ply:IsPlayer(ply) then gmInte.log("Sending new Public Config to " .. ply:Nick(), true) gmInte.publicGetConfig(ply) diff --git a/lua/gmod_integration/shared/sh_api_format.lua b/lua/gmod_integration/shared/sh_api_format.lua index da378b1..41418b4 100644 --- a/lua/gmod_integration/shared/sh_api_format.lua +++ b/lua/gmod_integration/shared/sh_api_format.lua @@ -19,7 +19,7 @@ end function gmInte.getPlayersFormat() local players = {} - for k, v in pairs(player.GetAll()) do + for k, v in ipairs(player.GetAll()) do table.insert(players, gmInte.getPlayerFormat(v)) end return players