Skip to content

Commit

Permalink
feat: remove ox_lib dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
mafewtm committed Jul 29, 2024
1 parent 6de1b78 commit b638311
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 7 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

Just a simple React Typescript loading screen utilizing Mantine UI

## Dependencies

- [ox_lib](https://github.com/overextended/ox_lib) (For version checking)

## How to build

```
Expand Down
2 changes: 0 additions & 2 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ description 'Just a simple React loading screen'
repository 'https://github.com/mafewtm/m_loading'
version '1.2.0'

shared_script '@ox_lib/init.lua'

server_script 'server/main.lua'

files {
Expand Down
43 changes: 42 additions & 1 deletion server/main.lua
Original file line number Diff line number Diff line change
@@ -1 +1,42 @@
lib.versionCheck('mafewtm/m_loading')
--- versionCheck functionality borrowed from ox_lib: https://github.com/overextended/ox_lib/blob/e10e8af0de655cbd8fa99c0d27840234c91828cb/resource/version/server.lua
local function versionCheck()
local resource = GetCurrentResourceName()
local currentVersion = GetResourceMetadata(resource, 'version', 0)

if currentVersion then
currentVersion = currentVersion:match('%d+%.%d+%.%d+')
end

if not currentVersion then
return print(("^1Unable to determine current resource version for '%s' ^0"):format(resource))
end

SetTimeout(1000, function()
PerformHttpRequest('https://api.github.com/repos/mafewtm/m_loading/releases/latest', function(status, response)
if status ~= 200 then return end

response = json.decode(response)
if response.prerelease then return end

local latestVersion = response.tag_name:match('%d+%.%d+%.%d+')
if not latestVersion or latestVersion == currentVersion then return end

local cv = { string.strsplit('.', currentVersion) }
local lv = { string.strsplit('.', latestVersion) }

for i = 1, #cv do
local current, minimum = tonumber(cv[i]), tonumber(lv[i])

if current ~= minimum then
if current < minimum then
return print(('^3An update is available for this resource (current version: %s)\r\n%s^0'):format(currentVersion, response.html_url))
else
break
end
end
end
end, 'GET')
end)
end

versionCheck()

0 comments on commit b638311

Please sign in to comment.