mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
refactor(resource/version): checkDependency optional print and return
Send 'true' to match old behaviour (print message, return nil). New behaviour has no output unless sending a third argument.
This commit is contained in:
@@ -1,8 +1,14 @@
|
|||||||
function lib.checkDependency(resource, minimumVersion)
|
function lib.checkDependency(resource, minimumVersion, printMessage)
|
||||||
local currentVersion = GetResourceMetadata(resource, 'version', 0):match('%d%.%d+%.%d+')
|
local currentVersion = GetResourceMetadata(resource, 'version', 0):match('%d%.%d+%.%d+')
|
||||||
|
|
||||||
if currentVersion < minimumVersion then
|
if currentVersion < minimumVersion then
|
||||||
return print(("^1%s requires version '%s' of '%s' (current version: %s)^0"):format(GetInvokingResource() or GetCurrentResourceName(), minimumVersion, resource, currentVersion))
|
local msg = ("^1%s requires version '%s' of '%s' (current version: %s)^0"):format(GetInvokingResource() or GetCurrentResourceName(), minimumVersion, resource, currentVersion)
|
||||||
|
|
||||||
|
if printMessage then
|
||||||
|
return print(msg)
|
||||||
|
end
|
||||||
|
|
||||||
|
return false, msg
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|||||||
Reference in New Issue
Block a user