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.
This commit is contained in:
Linden
2021-11-14 01:42:36 +11:00
parent 5a925695bc
commit 6aede19f4e
2 changed files with 5 additions and 2 deletions

View File

@@ -14,8 +14,9 @@ end
local ServerCallback = table.create(0, 2) local ServerCallback = table.create(0, 2)
---@param resource string
---@param event 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. --- Sends an event to the server and halts the current thread until a response is returned.
ServerCallback.Await = function(resource, event, delay, ...) ServerCallback.Await = function(resource, event, delay, ...)
CallbackTimer(event, delay) CallbackTimer(event, delay)
@@ -29,8 +30,10 @@ ServerCallback.Await = function(resource, event, delay, ...)
return table.unpack(Citizen.Await(promise)) return table.unpack(Citizen.Await(promise))
end end
---@param resource string
---@param event string ---@param event string
---@param delay number ---@param delay number
---@param cb function
--- Sends an event to the server and triggers a callback function once the response is returned. --- Sends an event to the server and triggers a callback function once the response is returned.
ServerCallback.Async = function(resource, event, delay, cb, ...) ServerCallback.Async = function(resource, event, delay, cb, ...)
CallbackTimer(event, delay) CallbackTimer(event, delay)

View File

@@ -6,7 +6,7 @@ local table = table
local pairs = pairs local pairs = pairs
local function contains(tbl, value) local function contains(tbl, value)
if type(value) == 'string' then if type(value) ~= 'table' then
for _, v in pairs(tbl) do for _, v in pairs(tbl) do
if v == value then return true end if v == value then return true end
end end