fix: fuck some shit with ipairs

This commit is contained in:
Linventif 2024-07-20 15:13:07 +00:00
parent 466e3cad4e
commit 5984ab5013
13 changed files with 19 additions and 20 deletions

View File

@ -201,7 +201,7 @@ function gmInte.openConfigMenu(data)
messageLabel:Dock(FILL) messageLabel:Dock(FILL)
messageLabel:SetText("Here you can configure your server settings.\nServer ID and Token are available on the webpanel in the server settings.\nThe documentation is available at https://docs.gmod-integration.com/\nIf you need help, please contact us on our discord server.") messageLabel:SetText("Here you can configure your server settings.\nServer ID and Token are available on the webpanel in the server settings.\nThe documentation is available at https://docs.gmod-integration.com/\nIf you need help, please contact us on our discord server.")
messageLabel:SetWrap(true) messageLabel:SetWrap(true)
for k, catName in ipairs(configCat) do for k, catName in pairs(configCat) do
local collapsibleCategory = vgui.Create("DCollapsibleCategory", scrollPanel) local collapsibleCategory = vgui.Create("DCollapsibleCategory", scrollPanel)
collapsibleCategory:Dock(TOP) collapsibleCategory:Dock(TOP)
collapsibleCategory:DockMargin(10, 0, 10, 10) collapsibleCategory:DockMargin(10, 0, 10, 10)
@ -215,13 +215,13 @@ function gmInte.openConfigMenu(data)
configList:EnableVerticalScrollbar(false) configList:EnableVerticalScrollbar(false)
collapsibleCategory:SetContents(configList) collapsibleCategory:SetContents(configList)
local categoryConfig = {} local categoryConfig = {}
for k, v in ipairs(possibleConfig) do for k, v in pairs(possibleConfig) do
if v.category == catName then table.insert(categoryConfig, v) end if v.category == catName then table.insert(categoryConfig, v) end
end end
// Sort by position // Sort by position
table.sort(categoryConfig, function(a, b) return (a.position || 0) < (b.position || 0) end) table.sort(categoryConfig, function(a, b) return (a.position || 0) < (b.position || 0) end)
for k, actualConfig in ipairs(categoryConfig) do for k, actualConfig in pairs(categoryConfig) do
local panel = vgui.Create("DPanel", configList) local panel = vgui.Create("DPanel", configList)
panel:Dock(TOP) panel:Dock(TOP)
panel:SetSize(300, 25) panel:SetSize(300, 25)
@ -245,7 +245,6 @@ function gmInte.openConfigMenu(data)
input.OnLoseFocus = function(self) if actualConfig.secret then self:SetText("*** Click to show ***") end end input.OnLoseFocus = function(self) if actualConfig.secret then self:SetText("*** Click to show ***") end end
local isLastID = 0 local isLastID = 0
input.OnChange = function(self) input.OnChange = function(self)
value = self:GetValue()
if actualConfig.resetIfEmpty && self:GetValue() == "" && actualConfig.defaultValue then if actualConfig.resetIfEmpty && self:GetValue() == "" && actualConfig.defaultValue then
self:SetText(actualConfig.defaultValue) self:SetText(actualConfig.defaultValue)
return return
@ -286,7 +285,7 @@ function gmInte.openConfigMenu(data)
buttonGrid:SetColWide(frame:GetWide() / 2 - 5) buttonGrid:SetColWide(frame:GetWide() / 2 - 5)
buttonGrid:SetRowHeight(45) buttonGrid:SetRowHeight(45)
local buttonsCount = 0 local buttonsCount = 0
for k, v in ipairs(buttonsInfo) do for k, v in pairs(buttonsInfo) do
if v.condition && !v.condition(data) then continue end if v.condition && !v.condition(data) then continue end
local button = vgui.Create("DButton") local button = vgui.Create("DButton")
button:SetText(v.label) button:SetText(v.label)

View File

@ -1,6 +1,6 @@
function gmInte.chatAddText(data) function gmInte.chatAddText(data)
local args = {} local args = {}
for _, v in ipairs(data) do for _, v in pairs(data) do
table.insert(args, v.color) table.insert(args, v.color)
table.insert(args, v.text) table.insert(args, v.text)
end end

View File

@ -22,13 +22,13 @@ function gmInte.createImgurMaterials(materials, addon_var, folder, name)
end) end)
end end
for k, v in ipairs(materials) do for k, v in pairs(materials) do
getMatFromUrl("https://i.imgur.com/" .. v .. ".png", k) getMatFromUrl("https://i.imgur.com/" .. v .. ".png", k)
end end
end end
function gmInte.redowloadMaterials() function gmInte.redowloadMaterials()
for k, v in ipairs(ImageCache) do for k, v in pairs(ImageCache) do
v.addon_var[v.id] = Material("../data/" .. v.folder .. "/" .. v.id .. ".png", "noclamp smooth") v.addon_var[v.id] = Material("../data/" .. v.folder .. "/" .. v.id .. ".png", "noclamp smooth")
gmInte.log("materials", v.name .. " - Image Redownloaded - " .. v.id .. ".png") gmInte.log("materials", v.name .. " - Image Redownloaded - " .. v.id .. ".png")
end end

View File

@ -1,6 +1,6 @@
local function websocketDLLExist() local function websocketDLLExist()
local files, _ = file.Find("lua/bin/*", "GAME") local files, _ = file.Find("lua/bin/*", "GAME")
for k, v in ipairs(files) do for k, v in pairs(files) do
if v:find("gwsockets") then return true end if v:find("gwsockets") then return true end
end end
return false return false

View File

@ -6,7 +6,7 @@ local conFuncs = {
["get-server-id"] = function() print(gmInte.config.id || "none") end, ["get-server-id"] = function() print(gmInte.config.id || "none") end,
["screenshot"] = function(args) ["screenshot"] = function(args)
if !args[2] then return gmInte.log("No SteamID64 provided") end if !args[2] then return gmInte.log("No SteamID64 provided") end
for _, ply in ipairs(player.GetAll()) do for _, ply in pairs(player.GetAll()) do
if ply:SteamID64() == args[2] then return gmInte.takeScreenshot(ply) end if ply:SteamID64() == args[2] then return gmInte.takeScreenshot(ply) end
end end
end, end,

View File

@ -12,7 +12,7 @@ local function filterMessage(reason)
"Service provided by Gmod Integration", "Service provided by Gmod Integration",
} }
for k, v in ipairs(Message) do for k, v in pairs(Message) do
Message[k] = "\n" .. v Message[k] = "\n" .. v
end end
return table.concat(Message) return table.concat(Message)

View File

@ -90,7 +90,7 @@ end
hook.Add("gmInte:PlayerReady", "gmInte:Player:Ready", function(ply) gmInte.playerReady(ply) end) hook.Add("gmInte:PlayerReady", "gmInte:Player:Ready", function(ply) gmInte.playerReady(ply) end)
hook.Add("ShutDown", "gmInte:Server:Shutdown:SavePlayers", function() hook.Add("ShutDown", "gmInte:Server:Shutdown:SavePlayers", function()
for ply, ply in ipairs(player.GetAll()) do for _, ply in pairs(player.GetAll()) do
gmInte.playerDisconnected(ply) gmInte.playerDisconnected(ply)
end end
end) end)

View File

@ -14,7 +14,7 @@ function gmInte.saveSetting(setting, value)
gmInte.log("Setting Saved") gmInte.log("Setting Saved")
if value == "websocketFQDN" || value == "id" || value == "token" then gmInte.resetWebSocket() end if value == "websocketFQDN" || value == "id" || value == "token" then gmInte.resetWebSocket() end
// send to all players the new public config // send to all players the new public config
for _, ply in ipairs(player.GetAll()) do for _, ply in pairs(player.GetAll()) do
if ply:IsValid() && ply:IsPlayer(ply) then if ply:IsValid() && ply:IsPlayer(ply) then
gmInte.log("Sending new Public Config to " .. ply:Nick(), true) gmInte.log("Sending new Public Config to " .. ply:Nick(), true)
gmInte.publicGetConfig(ply) gmInte.publicGetConfig(ply)
@ -66,7 +66,7 @@ end
function gmInte.superadminSetConfig(ply, data) function gmInte.superadminSetConfig(ply, data)
if !ply:IsValid() || !ply:IsPlayer(ply) || !ply:IsSuperAdmin() then return end if !ply:IsValid() || !ply:IsPlayer(ply) || !ply:IsSuperAdmin() then return end
for k, v in ipairs(data) do for k, v in pairs(data) do
gmInte.saveSetting(k, v) gmInte.saveSetting(k, v)
end end

View File

@ -1,5 +1,5 @@
function gmInte.wsSyncBan(data) function gmInte.wsSyncBan(data)
for _, ply in ipairs(player.GetAll()) do for _, ply in pairs(player.GetAll()) do
if ply:SteamID64() == data.steam then ply:Kick(data.reason || "You have been banned from the server.") end if ply:SteamID64() == data.steam then ply:Kick(data.reason || "You have been banned from the server.") end
end end
end end

View File

@ -1,5 +1,5 @@
function gmInte.wsSyncKick(data) function gmInte.wsSyncKick(data)
for _, ply in ipairs(player.GetAll()) do for _, ply in pairs(player.GetAll()) do
if ply:SteamID64() == data.steam then ply:Kick(data.reason || "You have been banned from the server.") end if ply:SteamID64() == data.steam then ply:Kick(data.reason || "You have been banned from the server.") end
end end
end end

View File

@ -72,7 +72,7 @@ end)
// For those who refuse to use CAMI (bro, WTF), routine scan // For those who refuse to use CAMI (bro, WTF), routine scan
local lastScan = {} local lastScan = {}
timer.Create("gmInte:SyncRoles:PlayerScan", 3, 0, function() timer.Create("gmInte:SyncRoles:PlayerScan", 3, 0, function()
for k, v in ipairs(player.GetAll()) do for k, v in pairs(player.GetAll()) do
if lastScan[v:SteamID64()] == v:GetUserGroup() then continue end if lastScan[v:SteamID64()] == v:GetUserGroup() then continue end
gmInte.playerChangeGroup(v:SteamID64(), lastScan[v:SteamID64()], v:GetUserGroup()) gmInte.playerChangeGroup(v:SteamID64(), lastScan[v:SteamID64()], v:GetUserGroup())
lastScan[v:SteamID64()] = v:GetUserGroup() lastScan[v:SteamID64()] = v:GetUserGroup()

View File

@ -19,7 +19,7 @@ end
function gmInte.getPlayersFormat() function gmInte.getPlayersFormat()
local players = {} local players = {}
for k, v in ipairs(player.GetAll()) do for k, v in pairs(player.GetAll()) do
table.insert(players, gmInte.getPlayerFormat(v)) table.insert(players, gmInte.getPlayerFormat(v))
end end
return players return players

View File

@ -39,13 +39,13 @@ end
local function getCustomValues(ply) local function getCustomValues(ply)
local values = {} local values = {}
// Get compatability values // Get compatability values
for key, value in ipairs(getCustomCompatability(ply)) do for key, value in pairs(getCustomCompatability(ply)) do
values[key] = value values[key] = value
end end
// Get custom values or overwrite compatability values // Get custom values or overwrite compatability values
if ply.gmIntCustomValues then if ply.gmIntCustomValues then
for key, value in ipairs(ply.gmIntCustomValues) do for key, value in pairs(ply.gmIntCustomValues) do
values[key] = value values[key] = value
end end
end end