From 6aede19f4e2a5c266594637e8518aa8892771dd6 Mon Sep 17 00:00:00 2001 From: Linden <65407488+thelindat@users.noreply.github.com> Date: Sun, 14 Nov 2021 01:42:36 +1100 Subject: [PATCH] fix(table): correctly check if table contains value for non-tables Only strings were allowed through this initial check, but we want non-table values to check if v = value. --- imports/callbacks/client.lua | 5 ++++- imports/table/shared.lua | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/imports/callbacks/client.lua b/imports/callbacks/client.lua index 1fe917b..03528f1 100644 --- a/imports/callbacks/client.lua +++ b/imports/callbacks/client.lua @@ -14,8 +14,9 @@ end local ServerCallback = table.create(0, 2) +---@param resource string ---@param event string ----@param delay number +---@param delay number prevent the event from being called for the given time --- Sends an event to the server and halts the current thread until a response is returned. ServerCallback.Await = function(resource, event, delay, ...) CallbackTimer(event, delay) @@ -29,8 +30,10 @@ ServerCallback.Await = function(resource, event, delay, ...) return table.unpack(Citizen.Await(promise)) end +---@param resource string ---@param event string ---@param delay number +---@param cb function --- Sends an event to the server and triggers a callback function once the response is returned. ServerCallback.Async = function(resource, event, delay, cb, ...) CallbackTimer(event, delay) diff --git a/imports/table/shared.lua b/imports/table/shared.lua index 425079e..7007f0c 100644 --- a/imports/table/shared.lua +++ b/imports/table/shared.lua @@ -6,7 +6,7 @@ local table = table local pairs = pairs local function contains(tbl, value) - if type(value) == 'string' then + if type(value) ~= 'table' then for _, v in pairs(tbl) do if v == value then return true end end