mirror of
https://github.com/sky-systems/sky_phone.git
synced 2026-08-28 22:01:40 +00:00
97db163cd0
* FIX - repair inventory metadata and ESX contracts Use the stable core_inventory metadata setter and validate the complete inventory adapter contract after provider bridges load. Preserve the real ESX configuration error instead of cascading into a missing RegisterUsableItem failure. * FIX - clarify phone opening without SIM * FIX - harden inventory and device contracts Validate SIM number configuration before item handling, preserve QB metadata mutation contracts, and propagate phone-open failures to callers. Extend regression coverage for inventory bridges and device bootstrap errors. * FIX - resolve reported phone interaction issues Stop game-input passthrough while NUI text fields are focused and add an independent hold-to-look option. Propagate SIM number formatting to the frontend, migrate configured currency symbols to utf8mb4, and clarify SkyRide, VaultX, and DarkChat behavior with focused contract coverage. * FIX - detect missing packaged phone UI Validate the generated NUI entrypoint, its referenced assets, and required static media when the resource starts. Print an actionable server-console warning for incomplete source archives, package phone sounds through the manifest, and cover the detection contract with Lua regressions.
90 lines
2.7 KiB
Lua
90 lines
2.7 KiB
Lua
SkyPhoneSimNumber = {}
|
|
|
|
function SkyPhoneSimNumber.ValidateConfiguration(length, prefix)
|
|
if type(length) ~= "number" or length ~= math.floor(length) or length < 1 or length > 24 then
|
|
return false, "NumberLength must be a whole number between 1 and 24"
|
|
end
|
|
if type(prefix) ~= "string" or prefix:find("%D") then
|
|
return false, "NumberPrefix must contain digits only"
|
|
end
|
|
if #prefix > length then
|
|
return false, "NumberPrefix cannot be longer than NumberLength"
|
|
end
|
|
return true
|
|
end
|
|
|
|
function SkyPhoneSimNumber.Normalize(value, length, prefix)
|
|
if type(value) ~= "string" and type(value) ~= "number" then
|
|
return nil
|
|
end
|
|
if not SkyPhoneSimNumber.ValidateConfiguration(length, prefix) then
|
|
return nil
|
|
end
|
|
local number = tostring(value):gsub("%D", "")
|
|
if #number ~= length or number:sub(1, #prefix) ~= prefix then
|
|
return nil
|
|
end
|
|
return number
|
|
end
|
|
|
|
function SkyPhoneSimNumber.NormalizeService(value, maximum_length)
|
|
if type(value) ~= "string" and type(value) ~= "number" then
|
|
return nil
|
|
end
|
|
local number = tostring(value):gsub("%D", "")
|
|
if number == "" or #number > maximum_length then
|
|
return nil
|
|
end
|
|
return number
|
|
end
|
|
|
|
function SkyPhoneSimNumber.FromEntropy(entropy, length, prefix)
|
|
if type(entropy) ~= "string" or entropy == "" then
|
|
return nil
|
|
end
|
|
if not SkyPhoneSimNumber.ValidateConfiguration(length, prefix) then
|
|
return nil
|
|
end
|
|
local source = entropy:gsub("%D", "")
|
|
if source == "" then
|
|
return nil
|
|
end
|
|
local number = prefix
|
|
local index = 1
|
|
while #number < length do
|
|
number = number .. source:sub(index, index)
|
|
index = index + 1
|
|
if index > #source and #number < length then
|
|
index = 1
|
|
end
|
|
end
|
|
return number
|
|
end
|
|
|
|
function SkyPhoneSimNumber.Format(value, groups, length, prefix)
|
|
local number = SkyPhoneSimNumber.Normalize(value, length, prefix)
|
|
if not number then
|
|
return tostring(value or "")
|
|
end
|
|
local formatted = {}
|
|
local offset = 1
|
|
for _, group_length in ipairs(groups) do
|
|
formatted[#formatted + 1] = number:sub(offset, offset + group_length - 1)
|
|
offset = offset + group_length
|
|
end
|
|
if offset <= #number then
|
|
formatted[#formatted + 1] = number:sub(offset)
|
|
end
|
|
return table.concat(formatted, " ")
|
|
end
|
|
|
|
function SkyPhoneSimNumber.Reserve(entropy, accept, length, prefix)
|
|
for _ = 1, 20 do
|
|
local candidate = SkyPhoneSimNumber.FromEntropy(entropy(), length, prefix)
|
|
if candidate and accept(candidate) then
|
|
return candidate
|
|
end
|
|
end
|
|
return nil
|
|
end
|