mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
chore: various fix-ups from docs clean-up (#363)
- Add in missing js functions - getCurrentRadialId - requestScaleformMove - Change up math.tohex to maintain lowercase `0x` prefix - Add missing fields - Removed extra whitespaces Co-authored-by: Luke <39926192+LukeWasTakenn@users.noreply.github.com>
This commit is contained in:
@@ -21,7 +21,7 @@ function lib.getNearbyObjects(coords, maxDistance)
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return nearby
|
return nearby
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -86,8 +86,8 @@ end
|
|||||||
---@param upper? boolean
|
---@param upper? boolean
|
||||||
---@return string
|
---@return string
|
||||||
function math.tohex(n, upper)
|
function math.tohex(n, upper)
|
||||||
n = ('0x%x'):format(n)
|
local formatString = ('0x%s'):format(upper and '%X' or '%x')
|
||||||
return upper and n:upper() or n
|
return formatString:format(n)
|
||||||
end
|
end
|
||||||
|
|
||||||
---Converts input number into grouped digits
|
---Converts input number into grouped digits
|
||||||
@@ -99,4 +99,4 @@ function math.groupdigits(number, seperator) -- credit http://richard.warburton.
|
|||||||
return left..(num:reverse():gsub('(%d%d%d)','%1' .. (seperator or ',')):reverse())..right
|
return left..(num:reverse():gsub('(%d%d%d)','%1' .. (seperator or ',')):reverse())..right
|
||||||
end
|
end
|
||||||
|
|
||||||
return lib.math
|
return lib.math
|
||||||
|
|||||||
@@ -136,5 +136,4 @@ function table.isfrozen(tbl)
|
|||||||
return getmetatable(tbl) == 'readonly'
|
return getmetatable(tbl) == 'readonly'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
return lib.table
|
return lib.table
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ export const removeRadialItem = (item: string) => exports.ox_lib.removeRadialIte
|
|||||||
export const registerRadial = (radial: { id: string; items: Omit<RadialItem, 'id'>[] }) =>
|
export const registerRadial = (radial: { id: string; items: Omit<RadialItem, 'id'>[] }) =>
|
||||||
exports.ox_lib.registerRadial(radial);
|
exports.ox_lib.registerRadial(radial);
|
||||||
|
|
||||||
|
export const getCurrentRadialId = () => exports.ox_lib.getCurrentRadialId();
|
||||||
|
|
||||||
export const hideRadial = () => exports.ox_lib.hideRadial();
|
export const hideRadial = () => exports.ox_lib.hideRadial();
|
||||||
|
|
||||||
export const disableRadial = (state: boolean) => exports.ox_lib.disableRadial(state);
|
export const disableRadial = (state: boolean) => exports.ox_lib.disableRadial(state);
|
||||||
|
|||||||
@@ -41,12 +41,14 @@ export const requestModel = (model: string | number, timeout?: number): Promise<
|
|||||||
return streamingRequest(RequestModel, HasModelLoaded, 'model', model, timeout);
|
return streamingRequest(RequestModel, HasModelLoaded, 'model', model, timeout);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const requestStreamedTextureDict = (textureDict: string, timeout?: number): Promise<string> =>
|
|
||||||
streamingRequest(RequestStreamedTextureDict, HasStreamedTextureDictLoaded, 'textureDict', textureDict, timeout);
|
|
||||||
|
|
||||||
export const requestNamedPtfxAsset = (ptFxName: string, timeout?: number): Promise<string> =>
|
export const requestNamedPtfxAsset = (ptFxName: string, timeout?: number): Promise<string> =>
|
||||||
streamingRequest(RequestNamedPtfxAsset, HasNamedPtfxAssetLoaded, 'ptFxName', ptFxName, timeout);
|
streamingRequest(RequestNamedPtfxAsset, HasNamedPtfxAssetLoaded, 'ptFxName', ptFxName, timeout);
|
||||||
|
|
||||||
export const requestWeaponAsset = (weaponHash: string | number, timeout?: number, weaponResourceFlags: number = 31, extraWeaponComponentFlags: number = 0): Promise<string | number> => {
|
export const requestScaleformMovie = (scaleformName: string, timeout?: number): Promise<string> =>
|
||||||
return streamingRequest(RequestWeaponAsset, HasWeaponAssetLoaded, 'weaponHash', weaponHash, timeout, weaponResourceFlags, extraWeaponComponentFlags);
|
streamingRequest(RequestScaleformMovie, HasScaleformMovieLoaded, 'scaleformMovie', scaleformName, timeout);
|
||||||
}
|
|
||||||
|
export const requestStreamedTextureDict = (textureDict: string, timeout?: number): Promise<string> =>
|
||||||
|
streamingRequest(RequestStreamedTextureDict, HasStreamedTextureDictLoaded, 'textureDict', textureDict, timeout);
|
||||||
|
|
||||||
|
export const requestWeaponAsset = (weaponHash: string | number, timeout?: number, weaponResourceFlags: number = 31, extraWeaponComponentFlags: number = 0): Promise<string | number> =>
|
||||||
|
streamingRequest(RequestWeaponAsset, HasWeaponAssetLoaded, 'weaponHash', weaponHash, timeout, weaponResourceFlags, extraWeaponComponentFlags);
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ local openContextMenu = nil
|
|||||||
---@field menu? string
|
---@field menu? string
|
||||||
---@field icon? string | {[1]: IconProp, [2]: string};
|
---@field icon? string | {[1]: IconProp, [2]: string};
|
||||||
---@field iconColor? string
|
---@field iconColor? string
|
||||||
|
---@field image? string
|
||||||
|
---@field progress? number
|
||||||
---@field onSelect? fun(args: any)
|
---@field onSelect? fun(args: any)
|
||||||
---@field arrow? boolean
|
---@field arrow? boolean
|
||||||
---@field description? string
|
---@field description? string
|
||||||
|
|||||||
@@ -8,9 +8,12 @@ local openMenu
|
|||||||
|
|
||||||
---@class MenuOptions
|
---@class MenuOptions
|
||||||
---@field label string
|
---@field label string
|
||||||
|
---@field progress? number
|
||||||
|
---@field colorScheme? string
|
||||||
---@field icon? string | {[1]: IconProp, [2]: string};
|
---@field icon? string | {[1]: IconProp, [2]: string};
|
||||||
---@field checked? boolean
|
---@field iconColor? string
|
||||||
---@field values? table<string | { label: string, description: string }>
|
---@field values? table<string | { label: string, description: string }>
|
||||||
|
---@field checked? boolean
|
||||||
---@field description? string
|
---@field description? string
|
||||||
---@field defaultIndex? number
|
---@field defaultIndex? number
|
||||||
---@field args? {[any]: any}
|
---@field args? {[any]: any}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
---@alias NotificationPosition 'top' | 'top-right' | 'top-left' | 'bottom' | 'bottom-right' | 'bottom-left' | 'center-right' | 'center-left'
|
---@alias NotificationPosition 'top' | 'top-right' | 'top-left' | 'bottom' | 'bottom-right' | 'bottom-left' | 'center-right' | 'center-left'
|
||||||
---@alias NotificationType 'info' | 'warning' | 'success' | 'error'
|
---@alias NotificationType 'inform' | 'warning' | 'success' | 'error'
|
||||||
|
|
||||||
---@class NotifyProps
|
---@class NotifyProps
|
||||||
---@field id? string
|
---@field id? string
|
||||||
@@ -30,11 +30,11 @@ end
|
|||||||
|
|
||||||
---@param data DefaultNotifyProps
|
---@param data DefaultNotifyProps
|
||||||
function lib.defaultNotify(data)
|
function lib.defaultNotify(data)
|
||||||
-- Backwards compat for v3
|
-- Backwards compat for v3
|
||||||
data.type = data.status
|
data.type = data.status
|
||||||
if data.type == 'inform' then data.type = 'info' end
|
if data.type == 'inform' then data.type = 'info' end
|
||||||
return lib.notify(data)
|
return lib.notify(data)
|
||||||
end
|
end
|
||||||
|
|
||||||
RegisterNetEvent('ox_lib:notify', lib.notify)
|
RegisterNetEvent('ox_lib:notify', lib.notify)
|
||||||
RegisterNetEvent('ox_lib:defaultNotify', lib.defaultNotify)
|
RegisterNetEvent('ox_lib:defaultNotify', lib.defaultNotify)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
if cache.game == 'redm' then return end
|
if cache.game == 'redm' then return end
|
||||||
|
|
||||||
---@class VehicleProperties
|
---@class VehicleProperties
|
||||||
---@field model? string
|
---@field model? number
|
||||||
---@field plate? string
|
---@field plate? string
|
||||||
---@field plateIndex? number
|
---@field plateIndex? number
|
||||||
---@field bodyHealth? number
|
---@field bodyHealth? number
|
||||||
|
|||||||
Reference in New Issue
Block a user