This repository was archived by the owner on Oct 12, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathinit.lua
More file actions
117 lines (96 loc) · 3.55 KB
/
Copy pathinit.lua
File metadata and controls
117 lines (96 loc) · 3.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
local supv_core <const>, service <const> = 'supv_core', (IsDuplicityVersion() and 'server') or 'client'
local LoadResourceFile <const>, IsDuplicityVersion <const>, joaat <const>, await <const>, GetCurrentResourceName <const> = LoadResourceFile, IsDuplicityVersion, joaat, Citizen.Await, GetCurrentResourceName
local GetGameName <const> = GetGameName
-- local eventCaches = {}
---@param str string
---@return string
local function FormatByte(str)
local binaryString = ""
for i = 1, #str do
local byte <const> = str:byte(i)
local bits = {}
for j = 7, 0, -1 do
bits[#bits + 1] = (byte >> j) & 1
end
binaryString = binaryString .. table.concat(bits)
end
return binaryString
end
---@param name string
---@param from? string<'client' | 'server'> default is supv.service
---@return string
local function FormatEvent(self, name, from)
--if eventCaches[name] then return eventCaches[name] end
--eventCaches[name] = FormatByte(("%s%s"):format(from and joaat(from) or joaat(service), joaat(name)))
--return eventCaches[name]
return FormatByte(("%s%s"):format(from and joaat(from) or joaat(service), joaat(name)))
end
local supv = setmetatable({
service = service, ---@type string<'client' | 'server'>
name = supv_core, ---@type string<'supv_core'>
env = supv_core, ---@type string<'resource_name?'>
game = GetGameName(), ---@type string<'fivem' | 'redm'>
hashEvent = FormatEvent,
build = GetGameBuildNumber(),
await = await,
lang = GetConvar('supv:locale', 'fr') ---@type string<'fr' | 'en' | unknown>
}, {
__newindex = function(self, name, value)
rawset(self, name, value)
if type(value) == 'function' then
exports(name, value)
end
end
})
_ENV.supv = supv
local loaded = {}
package = {
loaded = setmetatable({}, {
__index = loaded,
__newindex = function() end,
__metatable = false,
}),
path = './?.lua;'
}
local _require = require
function require(modname)
local module = loaded[modname]
if not module then
if module == false then
error(("^1circular-dependency occurred when loading module '%s'^0"):format(modname), 2)
end
local success, result = pcall(_require, modname)
if success then
loaded[modname] = result
return result
end
local modpath = modname:gsub('%.', '/')
local paths = { string.strsplit(';', package.path) }
for i = 1, #paths do
local scriptPath = paths[i]:gsub('%?', modpath):gsub('%.+%/+', '')
local resourceFile = LoadResourceFile(supv_core, scriptPath)
if resourceFile then
loaded[modname] = false
scriptPath = ('@@%s/%s'):format(supv_core, scriptPath)
local chunk, err = load(resourceFile, scriptPath)
if err or not chunk then
loaded[modname] = nil
return error(err or ("unable to load module '%s'"):format(modname), 3)
end
module = chunk(modname) or true
loaded[modname] = module
return module
end
end
return error(("module '%s' not found"):format(modname), 2)
end
return module
end
local callback = require(('imports.callback.%s'):format(service))
if service == 'server' then
require('imports.version.server').check('github', nil, 500)
elseif service == 'client' then
local cache = {}
_ENV.cache = cache
end
_ENV.callback = callback