Skip to content

Commit

Permalink
feat(client/api): add export "zoneExists" (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnishBplayz authored Jun 1, 2024
1 parent 0025a31 commit fd28987
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions client/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,20 @@ function api.addSphereZone(data)
return lib.zones.sphere(data).id
end

---@param id number | string The ID of the zone to check. It can be either a number or a string representing the zone's index or name, respectively.
---@return boolean returns true if the zone with the specified ID exists, otherwise false.
function api.zoneExists(id)
if not Zones or (type(id) ~= 'number' and type(id) ~= 'string') then return false end

if type(id) == 'number' and Zones[id] then return true end

for key, zone in pairs(Zones) do
if type(id) == 'string' and zone.name == id then return true end
end

return false
end

---@param id number | string
---@param suppressWarning boolean?
function api.removeZone(id, suppressWarning)
Expand Down

0 comments on commit fd28987

Please sign in to comment.