Skip to content

Commit

Permalink
refactor(client/api): show warning when debug zone is created
Browse files Browse the repository at this point in the history
Can't wait for "how fix??"
  • Loading branch information
thelindat committed Aug 10, 2023
1 parent 83cff4d commit cea7848
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions client/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,36 @@ local api = setmetatable({}, {
end
})

local function debugWarning(msg)
local trace = Citizen.InvokeNative(`FORMAT_STACK_TRACE` & 0xFFFFFFFF, nil, 0, Citizen.ResultAsString())
local _, _, src = string.strsplit('\n', trace, 4)

warn(('%s ^0%s\n'):format(msg, src:gsub(".-%(", '(')))
end

---@param data OxTargetPolyZone
---@return number
function api.addPolyZone(data)
if data.debug then debugWarning('Creating new PolyZone with debug enabled.') end

data.resource = GetInvokingResource()
return lib.zones.poly(data).id
end

---@param data OxTargetBoxZone
---@return number
function api.addBoxZone(data)
if data.debug then debugWarning('Creating new BoxZone with debug enabled.') end

data.resource = GetInvokingResource()
return lib.zones.box(data).id
end

---@param data OxTargetSphereZone
---@return number
function api.addSphereZone(data)
if data.debug then debugWarning('Creating new SphereZone with debug enabled.') end

data.resource = GetInvokingResource()
return lib.zones.sphere(data).id
end
Expand Down

0 comments on commit cea7848

Please sign in to comment.