mirror of
https://github.com/sky-systems/sky_phone.git
synced 2026-08-29 09:18:57 +00:00
Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| af1ae8510d | |||
| 197dce8767 | |||
| 1bd0adbea3 | |||
| f70b1cc37d | |||
| 7df62153a2 | |||
| 1949a37006 | |||
| 219d523edf | |||
| 20faedc1a2 | |||
| 87fa234c49 | |||
| 7bc4eb6993 | |||
| 740bdda0db | |||
| 7f97072c75 | |||
| 42f5e8f493 | |||
| d8a7721917 | |||
| 15e32799d4 | |||
| d6b03ac2b7 | |||
| 9dd330da93 | |||
| a9b0c4e0f4 | |||
| 8e2523d555 | |||
| f5b28c7fda | |||
| 3a45aa159a | |||
| 22165d64df |
@@ -119,5 +119,5 @@ jobs:
|
||||
"${archive}.sha256" \
|
||||
--verify-tag \
|
||||
--generate-notes \
|
||||
--title "$GITHUB_REF_NAME Beta"
|
||||
--title "Sky Phone $GITHUB_REF_NAME"
|
||||
fi
|
||||
|
||||
@@ -86,7 +86,7 @@ Sky Phone is built to be the **free FiveM phone you can choose without accepting
|
||||
| Layer | Supported options |
|
||||
| --- | --- |
|
||||
| **Frameworks** | ESX Legacy, QBCore, Qbox |
|
||||
| **Inventories** | ak47_inventory, codem-inventory, core_inventory, jaksam_inventory, jpr-inventory, lj-inventory, mf-inventory, one_inventory, origen_inventory, ox_inventory, ps-inventory, qb-inventory, qs-inventory, smx-inventory, tgiann-inventory, hex_4_inventory, and native ESX inventory |
|
||||
| **Inventories** | ox_inventory, qb-inventory, lj-inventory, qs-inventory, codem-inventory, core_inventory, mf-inventory, smx-inventory, hex_4_inventory, and native ESX inventory |
|
||||
| **Calls** | YACA, PMA Voice, SaltyChat |
|
||||
| **Radio** | YACA, PMA Voice, SaltyChat |
|
||||
| **Housing** | RTX Housing, Quasar Housing, VMS Housing, RX Housing, NoLag Properties, SN Properties, ESX Property, qbx_properties |
|
||||
@@ -121,33 +121,20 @@ Sky Phone is built to be the **free FiveM phone you can choose without accepting
|
||||
| **Framework** | ESX Legacy (`es_extended`), QBCore (`qb-core`), or Qbox (`qbx_core`) |
|
||||
| **Inventory** | Choose one supported adapter from the table below |
|
||||
|
||||
| Inventory (configuration value) | Metadata support | Unique Phones | Notes |
|
||||
| Inventory | Metadata support | Unique Phones | Notes |
|
||||
| --- | --- | --- | --- |
|
||||
| `jaksam_inventory` (`jaksam`) | Yes | Yes | Direct per-slot metadata; usable items are registered through jaksam_inventory |
|
||||
| `qs-inventory` (`qs`) | Yes | Yes | Full per-slot metadata |
|
||||
| `ps-inventory` (`ps`) | Yes | Yes | QBCore only; uses item `info` metadata |
|
||||
| `codem-inventory` (`codem`) | Yes | Yes | Full per-slot metadata |
|
||||
| `tgiann-inventory` (`tgiann`) | Yes | Yes | Per-slot metadata; item definitions must enable `hasMetadata` |
|
||||
| `core_inventory` (`core`) | Yes | Yes | Full per-slot metadata |
|
||||
| `jpr-inventory` (`jpr`) | Yes | Yes | QBCore only; uses item `info` metadata |
|
||||
| `origen_inventory` (`origen`) | Yes | Yes | Full per-slot metadata |
|
||||
| `ak47_inventory` (`ak47`) | Yes | Yes | Uses per-slot item `info` metadata |
|
||||
| `one_inventory` (`one`) | Yes | Yes | Full per-slot metadata |
|
||||
| `ox_inventory` (`ox`) | Yes | Yes | Full per-item phone and physical SIM metadata |
|
||||
| `mf-inventory` (`mf`) | Yes | Yes | ESX only |
|
||||
| `smx-inventory` (`smx`) | Yes | Yes | ESX only; one metadata record per configured item name through the player metadata bridge |
|
||||
| `lj-inventory` (`lj`) | Yes | Yes | QBCore inventory with item `info` metadata |
|
||||
| `qb-inventory` (`qb`) | Yes | Yes | Uses item `info` metadata |
|
||||
| `hex_4_inventory` (`hex`) | **No metadata support** | **No, Unique Phones are not possible** | ESX only; Sky Phone automatically disables unique phones and physical SIM cards |
|
||||
| Native ESX inventory (`esx`) | **No metadata support** | **No, Unique Phones are not possible** | Count-based items; Sky Phone automatically disables unique phones and physical SIM cards |
|
||||
| `ox_inventory` | Yes | Yes | Full per-item phone and physical SIM metadata |
|
||||
| `qb-inventory` | Yes | Yes | Uses item `info` metadata |
|
||||
| `lj-inventory` | Yes | Yes | QBCore inventory with item `info` metadata |
|
||||
| `qs-inventory` | Yes | Yes | Full per-slot metadata |
|
||||
| `codem-inventory` | Yes | Yes | Full per-slot metadata |
|
||||
| `core_inventory` | Yes | Yes | Full per-slot metadata |
|
||||
| `mf-inventory` | Yes | Yes | Supported with ESX |
|
||||
| `smx-inventory` | Yes | Yes | Supported with ESX through the player metadata bridge |
|
||||
| `hex_4_inventory` | **No metadata support** | **No, Unique Phones are not possible** | ESX only; set `Config.Phone.Unique = false` and `Config.Sim.Enabled = false` |
|
||||
| Native ESX inventory | **No metadata support** | **No, Unique Phones are not possible** | Count-based items; set `Config.Phone.Unique = false` and `Config.Sim.Enabled = false` |
|
||||
|
||||
`hex_4_inventory` and native ESX inventory cannot persist per-item metadata. Sky Phone therefore forces `Config.Phone.Unique` and `Config.Sim.Enabled` to `false` at runtime whenever either adapter is active.
|
||||
|
||||
`Config.Bridge.Inventory = "auto"` detects framework-compatible adapters in the table order. This deliberately matches the Sky inventory priority so a dedicated inventory is selected before a compatibility resource it may run beside. You may configure either the short value shown in parentheses or the exact resource name.
|
||||
|
||||
The adapters shared with `sky_base` are implemented locally inside Sky Phone. Installing or starting `sky_base` is not required; Sky Phone remains a standalone resource.
|
||||
|
||||
For configuration parity with `sky_base`, `qb-inv` is accepted as an alias for `qb`, while `qbox` selects the Qbox-native `ox_inventory` adapter.
|
||||
`hex_4_inventory` and native ESX inventory cannot persist per-item metadata. Unique Phones and physical SIM cards are therefore unavailable with these adapters.
|
||||
|
||||
### Voice
|
||||
|
||||
@@ -216,7 +203,6 @@ The files contain clearly separated sections for:
|
||||
| Section | Purpose |
|
||||
| --- | --- |
|
||||
| `Config.Bridge` | Framework, inventory, language, callback timeout, and debug mode |
|
||||
| `Config.CommandPermissions` | Fixed groups for the admin panel, test data, verification commands, and social moderation |
|
||||
| `Config.Phone` | Phone item, movement, unique-device mode, and development command |
|
||||
| `Config.Sim` | Physical or virtual SIM behavior and number formatting |
|
||||
| `Config.Calls` / `Config.Radio` | Voice providers, call behavior, radio limits, and permissions |
|
||||
@@ -242,31 +228,21 @@ Config.PhoneConfigurator = {
|
||||
}
|
||||
```
|
||||
|
||||
When enabled, the generated `source/shared/config_default.lua` is the shipped first-run baseline.
|
||||
The frontend build recreates this file from `config.lua` and the server-only `media.lua`; do not edit
|
||||
the generated snapshot directly. Sky Phone creates the `sky_phone_configurator` table automatically,
|
||||
loads its saved values before framework and phone
|
||||
When enabled, `config.lua` and the server-only `media.lua` are first-run defaults. Sky Phone creates
|
||||
the `sky_phone_configurator` table automatically, loads its saved values before framework and phone
|
||||
modules initialize, and exposes the editor through `/phonepanel`. Nothing autosaves: stage changes
|
||||
in the Phone Configurator tool and press the green check. Saving verifies both SQL payloads and then
|
||||
applies the new server, client, media, app, item, command, provider, animation, and UI values through
|
||||
Sky Phone's internal runtime refresh. It does not execute a resource restart command.
|
||||
|
||||
Every configurable `Config.*` value from `config.lua`, including server-only sections, and every
|
||||
value from `Config.Media` is discovered automatically. The bootstrap switch and
|
||||
`Config.CommandPermissions` intentionally remain file-owned: the switch decides whether SQL
|
||||
configuration is loaded, while permissions must remain authoritative outside the panel. The fixed
|
||||
permission table is never displayed or overwritten by the Phone Configurator, and its stable keys do
|
||||
not change when their commands are renamed in the panel. Lists, nested objects, vectors,
|
||||
Every `Config.*` value from `config.lua`, including server-only sections, and every value from
|
||||
`Config.Media` is discovered automatically. The bootstrap switch above intentionally remains
|
||||
file-owned because it decides whether SQL configuration is loaded. Lists, nested objects, vectors,
|
||||
and numeric-keyed Lua tables use structured editors instead of raw JSON. Shipped schema rows stay
|
||||
editable but cannot be renamed, converted, or removed. Every list and table still accepts any number
|
||||
of additional rows; administrator-added rows remain removable. Company job keys are intentionally
|
||||
fully removable because `Config.Companies.Definitions` is a freely managed job collection.
|
||||
|
||||
ESX and QBCore use the groups listed in `Config.CommandPermissions`. Qbox checks the configured ACE
|
||||
objects first and then its framework groups. The standard Qbox `permissions.cfg` grants the `admin`
|
||||
ACE to `group.admin`, so an identifier assigned to `group.admin` can open `/phonepanel` with the
|
||||
shipped `phonepanel` permission list. Restart `sky_phone` after changing fixed permissions.
|
||||
|
||||
Media API keys and server peppers are never returned in plaintext to the NUI. Existing secrets are
|
||||
shown only as configured and are replaced only when an administrator enters a new value.
|
||||
|
||||
@@ -374,9 +350,9 @@ Default entries for unique phones with physical SIM cards:
|
||||
|
||||
Do not configure an LB Phone client event or client export. Sky Phone registers the usable items through its server-side inventory adapter.
|
||||
|
||||
The server registers `Config.Phone.Item` as usable for every supported inventory adapter: `ak47`, `codem`, `core`, `jaksam`, `jpr`, `lj`, `mf`, `one`, `origen`, `ox`, `ps`, `qb`, `qs`, `smx`, `tgiann`, `hex`, and `esx`. Resource startup fails visibly if the selected adapter or its resource is unavailable.
|
||||
The server registers `Config.Phone.Item` as usable for every supported inventory adapter: `ox`, `qb`, `lj`, `qs`, `codem`, `core`, `mf`, `smx`, `hex`, and `esx`. Resource startup fails visibly if the selected adapter cannot complete that registration.
|
||||
|
||||
The `hex` and `esx` adapters use ESX's count-based item API, which cannot persist per-item phone or physical SIM metadata. Sky Phone automatically forces `Config.Phone.Unique = false` and `Config.Sim.Enabled = false` while either adapter is active. `auto` selects `hex` when `hex_4_inventory` is started and otherwise falls back to `esx` on an ESX server when no metadata-capable inventory is detected.
|
||||
The `hex` and `esx` adapters use ESX's count-based item API. They require both `Config.Phone.Unique = false` and `Config.Sim.Enabled = false` because this API cannot persist per-item phone or physical SIM metadata. `auto` selects `hex` when `hex_4_inventory` is started and otherwise falls back to `esx` on an ESX server when no metadata-capable inventory is detected.
|
||||
|
||||
### QBCore-style item tables
|
||||
|
||||
@@ -385,67 +361,6 @@ The `hex` and `esx` adapters use ESX's count-based item API, which cannot persis
|
||||
- Physical SIM items must always be unique.
|
||||
- SIM items are not required when `Config.Sim.Enabled = false`.
|
||||
|
||||
Example for `qb-inventory`, `lj-inventory`, `ps-inventory`, and `jpr-inventory`:
|
||||
|
||||
```lua
|
||||
phone = {
|
||||
name = "phone",
|
||||
label = "iFruit Phone",
|
||||
weight = 200,
|
||||
type = "item",
|
||||
image = "phone.png",
|
||||
unique = true,
|
||||
useable = true,
|
||||
shouldClose = true,
|
||||
description = "A personal mobile phone",
|
||||
},
|
||||
|
||||
sky_phone_sim_registered = {
|
||||
name = "sky_phone_sim_registered",
|
||||
label = "Registered SIM",
|
||||
weight = 5,
|
||||
type = "item",
|
||||
image = "sky_phone_sim_registered.png",
|
||||
unique = true,
|
||||
useable = true,
|
||||
shouldClose = true,
|
||||
},
|
||||
|
||||
sky_phone_sim_anonymous = {
|
||||
name = "sky_phone_sim_anonymous",
|
||||
label = "Anonymous SIM",
|
||||
weight = 5,
|
||||
type = "item",
|
||||
image = "sky_phone_sim_anonymous.png",
|
||||
unique = true,
|
||||
useable = true,
|
||||
shouldClose = true,
|
||||
},
|
||||
```
|
||||
|
||||
For `tgiann-inventory`, set `hasMetadata = true`, `useable = true`, and `shouldClose = true` on all three item definitions. Follow the inventory's own item schema for the remaining adapters; the required behavior is always the same: a unique phone or physical SIM must occupy its own slot and its metadata table must survive moving, dropping, storing, and trading the item.
|
||||
|
||||
### Unique Phones and metadata
|
||||
|
||||
Sky Phone owns the metadata values and writes them server-side. Do not pre-generate IMEIs or phone numbers in item definitions:
|
||||
|
||||
| Item | Metadata written by Sky Phone |
|
||||
| --- | --- |
|
||||
| Phone | `imei`; when a SIM is inserted, also `sim_id`, `phone_number`, and `formatted_number` |
|
||||
| Physical SIM | `sim_metadata_version`, `sim_id`, `phone_number`, `formatted_number`, `sim_type`, and registration details where applicable |
|
||||
|
||||
When a metadata-capable phone item is used for the first time, Sky Phone reserves an IMEI and writes it back to that exact slot. Existing metadata is preserved. The adapter then reads the slot again and rejects the operation if the inventory did not persist the requested values.
|
||||
|
||||
For reliable Unique Phones:
|
||||
|
||||
- Set `Config.Phone.Unique = true`.
|
||||
- Make the phone item non-stackable/unique. Every phone slot must contain exactly one item.
|
||||
- If `Config.Sim.Enabled = true`, make both physical SIM items non-stackable/unique and metadata-capable too.
|
||||
- Do not use inventory conversion, admin, crafting, or shop scripts that strip item metadata. Copying an item with its metadata also copies its IMEI; duplicated IMEIs are reported in the server console.
|
||||
- When changing inventory systems, migrate the complete item metadata table. Without the old `imei`, the next use creates a new device identity and does not automatically attach the old handset data.
|
||||
|
||||
With `Config.Phone.Unique = false`, the handset identity is stored once per framework character instead of on each phone item. The phone item may stack. Physical SIMs still require per-item metadata, so `Config.Sim.Enabled` must be `false` on `hex` and native `esx`.
|
||||
|
||||
## Phone and SIM modes
|
||||
|
||||
The two mode switches are independent:
|
||||
|
||||
+5
-40
@@ -2,49 +2,15 @@ const fs = require('node:fs')
|
||||
const path = require('node:path')
|
||||
|
||||
const frontendRoot = __dirname
|
||||
const resourceDirectory = path.join(frontendRoot, '..', 'sky_phone')
|
||||
const sourceDirectory = path.join(frontendRoot, 'dist')
|
||||
const targetDirectory = path.join(resourceDirectory, 'source', 'html')
|
||||
const configDefaultPath = path.join(
|
||||
resourceDirectory,
|
||||
const targetDirectory = path.join(
|
||||
frontendRoot,
|
||||
'..',
|
||||
'sky_phone',
|
||||
'source',
|
||||
'shared',
|
||||
'config_default.lua',
|
||||
'html',
|
||||
)
|
||||
|
||||
function readLuaSource(...segments) {
|
||||
return fs
|
||||
.readFileSync(path.join(resourceDirectory, ...segments), 'utf8')
|
||||
.replace(/\r\n?/g, '\n')
|
||||
.trimEnd()
|
||||
}
|
||||
|
||||
function generateConfigDefault() {
|
||||
const configSource = readLuaSource('config', 'config.lua').replace(
|
||||
/\n?-- CONFIG_DEFAULT_EXCLUDE_START[\s\S]*?-- CONFIG_DEFAULT_EXCLUDE_END\n?/g,
|
||||
'\n',
|
||||
)
|
||||
const mediaSource = readLuaSource('config', 'media.lua')
|
||||
const generatedSource = [
|
||||
'-- GENERATED by frontend/build.cjs from config/config.lua and config/media.lua - do not edit.',
|
||||
'-- Escrowed snapshot of the shipped defaults used by the Phone Configurator.',
|
||||
'local realConfig = Config',
|
||||
'Config = {}',
|
||||
'',
|
||||
configSource,
|
||||
'',
|
||||
mediaSource,
|
||||
'',
|
||||
'ConfigDefaults = Config',
|
||||
'Config = realConfig',
|
||||
'',
|
||||
].join('\n')
|
||||
|
||||
fs.mkdirSync(path.dirname(configDefaultPath), { recursive: true })
|
||||
fs.writeFileSync(configDefaultPath, generatedSource, 'utf8')
|
||||
console.log(`Generated Phone Configurator defaults at ${configDefaultPath}`)
|
||||
}
|
||||
|
||||
if (!fs.existsSync(sourceDirectory)) {
|
||||
throw new Error(
|
||||
'Missing frontend/dist. Run vite build before publishing the NUI.',
|
||||
@@ -62,5 +28,4 @@ const normalizedIndex = fs
|
||||
.replace(/\n[ \t]*\n([ \t]*<\/body>)/g, '\n$1')
|
||||
fs.writeFileSync(targetIndex, normalizedIndex)
|
||||
|
||||
generateConfigDefault()
|
||||
console.log(`Published NUI to ${targetDirectory}`)
|
||||
|
||||
@@ -54,14 +54,6 @@ const config = readFileSync(
|
||||
new URL('../../../sky_phone/config/config.lua', import.meta.url),
|
||||
'utf8',
|
||||
)
|
||||
const configDefaultsSource = config.replace(
|
||||
/\r?\n?-- CONFIG_DEFAULT_EXCLUDE_START[\s\S]*?-- CONFIG_DEFAULT_EXCLUDE_END\r?\n?/g,
|
||||
'\n',
|
||||
)
|
||||
const mediaConfig = readFileSync(
|
||||
new URL('../../../sky_phone/config/media.lua', import.meta.url),
|
||||
'utf8',
|
||||
)
|
||||
const schema = readFileSync(
|
||||
new URL('../../../sky_phone/sql/install.sql', import.meta.url),
|
||||
'utf8',
|
||||
@@ -77,17 +69,6 @@ const configuratorServer = readFileSync(
|
||||
),
|
||||
'utf8',
|
||||
)
|
||||
const configDefault = readFileSync(
|
||||
new URL(
|
||||
'../../../sky_phone/source/shared/config_default.lua',
|
||||
import.meta.url,
|
||||
),
|
||||
'utf8',
|
||||
)
|
||||
const frontendBuild = readFileSync(
|
||||
new URL('../../build.cjs', import.meta.url),
|
||||
'utf8',
|
||||
)
|
||||
const configuratorClient = readFileSync(
|
||||
new URL(
|
||||
'../../../sky_phone/source/client/phone_configurator.lua',
|
||||
@@ -235,14 +216,12 @@ describe('standalone admin panel contracts', () => {
|
||||
it('authorizes every server request without requiring a phone session', () => {
|
||||
expect(server).not.toContain('SkyPhone.RequireSession(source)')
|
||||
expect(server).toContain(
|
||||
'Bridge.Framework.HasPermission(source, "phonepanel")',
|
||||
'Bridge.Framework.HasAdminGroup(source, Config.AdminPanel.AdminGroups)',
|
||||
)
|
||||
expect(server).toContain('Config.AdminPanel.ReadRequestsPerMinute')
|
||||
expect(server).toContain('Config.AdminPanel.ActionRequestsPerMinute')
|
||||
expect(server).toContain('Config.AdminPanel.CredentialRevealsPerMinute')
|
||||
expect(config).toContain('Config.AdminPanel = {')
|
||||
expect(config).toContain('Config.CommandPermissions = {')
|
||||
expect(config).not.toContain('AdminGroups =')
|
||||
})
|
||||
|
||||
it('opens directly from the configurable command with dedicated focus', () => {
|
||||
@@ -293,12 +272,6 @@ describe('standalone admin panel contracts', () => {
|
||||
expect(schema).toContain(
|
||||
'CREATE TABLE IF NOT EXISTS `sky_phone_configurator`',
|
||||
)
|
||||
expect(
|
||||
manifest.indexOf("'source/shared/config_default.lua'"),
|
||||
).toBeGreaterThan(manifest.indexOf("'config/media.lua'"))
|
||||
expect(manifest.indexOf("'source/shared/config_default.lua'")).toBeLessThan(
|
||||
manifest.indexOf("'source/server/phone_configurator.lua'"),
|
||||
)
|
||||
expect(
|
||||
manifest.indexOf("'source/server/phone_configurator.lua'"),
|
||||
).toBeLessThan(manifest.indexOf("'source/bridge/server/framework.lua'"))
|
||||
@@ -308,36 +281,11 @@ describe('standalone admin panel contracts', () => {
|
||||
expect(configuratorServer).toContain('AND `revision` = ?')
|
||||
expect(configuratorServer).toContain('configurator_enabled')
|
||||
expect(configuratorServer).toMatch(
|
||||
/for key, value in pairs\(ConfigDefaults\)[\s\S]*?key ~= "Media"[\s\S]*?key ~= "PhoneConfigurator"/,
|
||||
/for key, value in pairs\(Config\)[\s\S]*?key ~= "Media"[\s\S]*?key ~= "PhoneConfigurator"/,
|
||||
)
|
||||
expect(configuratorServer).toContain(
|
||||
'default_media = serialize_value(ConfigDefaults.Media)',
|
||||
'default_media = serialize_value(Config.Media)',
|
||||
)
|
||||
expect(configDefault).toContain(
|
||||
'GENERATED by frontend/build.cjs from config/config.lua and config/media.lua',
|
||||
)
|
||||
expect(configDefault).toContain('local realConfig = Config')
|
||||
expect(configDefault).toContain('ConfigDefaults = Config')
|
||||
expect(configDefault.replace(/\r\n?/g, '\n').trimEnd()).toBe(
|
||||
[
|
||||
'-- GENERATED by frontend/build.cjs from config/config.lua and config/media.lua - do not edit.',
|
||||
'-- Escrowed snapshot of the shipped defaults used by the Phone Configurator.',
|
||||
'local realConfig = Config',
|
||||
'Config = {}',
|
||||
'',
|
||||
configDefaultsSource.replace(/\r\n?/g, '\n').trimEnd(),
|
||||
'',
|
||||
mediaConfig.replace(/\r\n?/g, '\n').trimEnd(),
|
||||
'',
|
||||
'ConfigDefaults = Config',
|
||||
'Config = realConfig',
|
||||
].join('\n'),
|
||||
)
|
||||
expect(frontendBuild).toContain("readLuaSource('config', 'config.lua')")
|
||||
expect(frontendBuild).toContain("readLuaSource('config', 'media.lua')")
|
||||
expect(frontendBuild).toContain("'config_default.lua'")
|
||||
expect(configDefault).not.toContain('Config.PhoneConfigurator')
|
||||
expect(configDefault).not.toContain('Config.CommandPermissions')
|
||||
expect(configuratorServer).toContain(
|
||||
'build_sections("config", stored_config',
|
||||
)
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
import { readFileSync } from 'node:fs'
|
||||
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
function source(path: string): string {
|
||||
return readFileSync(new URL(path, import.meta.url), 'utf8')
|
||||
}
|
||||
|
||||
const config = source('../../sky_phone/config/config.lua')
|
||||
const configDefault = source('../../sky_phone/source/shared/config_default.lua')
|
||||
const framework = source('../../sky_phone/source/bridge/server/framework.lua')
|
||||
const qbox = source('../../sky_phone/source/bridge/server/frameworks/qbox.lua')
|
||||
const configurator = source(
|
||||
'../../sky_phone/source/server/phone_configurator.lua',
|
||||
)
|
||||
const configuratorFixture = source('../testserver/configurator-fixture.cjs')
|
||||
|
||||
describe('fixed server permissions', () => {
|
||||
it('defines every protected phone capability only in config.lua', () => {
|
||||
expect(config).toContain('Config.CommandPermissions = {')
|
||||
for (const permission of [
|
||||
'phonepanel',
|
||||
'phonetestdata',
|
||||
'fliptokverify',
|
||||
'picstagramverify',
|
||||
'picstagramadmin',
|
||||
]) {
|
||||
expect(config).toMatch(new RegExp(`\\s${permission} = \\{`))
|
||||
}
|
||||
expect(config).not.toContain('AdminGroups =')
|
||||
expect(configDefault).not.toContain('Config.PhoneConfigurator')
|
||||
expect(configDefault).not.toContain('Config.CommandPermissions')
|
||||
expect(configDefault).not.toContain('AdminGroups =')
|
||||
})
|
||||
|
||||
it('keeps fixed permissions outside SQL and removes legacy group fields', () => {
|
||||
expect(configurator).toContain('key ~= "CommandPermissions"')
|
||||
expect(configurator).toContain('if key ~= "CommandPermissions" then')
|
||||
expect(configuratorFixture).toContain('delete config.CommandPermissions')
|
||||
for (const path of [
|
||||
'AdminPanel.AdminGroups',
|
||||
'TestData.AdminGroups',
|
||||
'FlipTok.AdminGroups',
|
||||
'Picstagram.AdminGroups',
|
||||
]) {
|
||||
expect(configurator).toContain(`["${path}"] = true`)
|
||||
}
|
||||
expect(configurator).toContain(
|
||||
'Phone Configurator enabled: file-based settings from config.lua',
|
||||
)
|
||||
expect(configurator).toContain(
|
||||
'(except Config.CommandPermissions) and media.lua are disabled',
|
||||
)
|
||||
})
|
||||
|
||||
it('authorizes Qbox through ACE before retaining framework group support', () => {
|
||||
expect(framework).toContain(
|
||||
'local groups = Config.CommandPermissions[permission]',
|
||||
)
|
||||
expect(qbox).toContain(
|
||||
'if IsPlayerAceAllowed(tostring(source), group) then',
|
||||
)
|
||||
expect(qbox.indexOf('IsPlayerAceAllowed')).toBeLessThan(
|
||||
qbox.indexOf('exports.qbx_core:HasGroup'),
|
||||
)
|
||||
})
|
||||
|
||||
it('uses stable permission identifiers for every protected operation', () => {
|
||||
const expectations = [
|
||||
['../../sky_phone/source/server/admin.lua', 'phonepanel'],
|
||||
['../../sky_phone/source/server/testdata.lua', 'phonetestdata'],
|
||||
['../../sky_phone/source/server/fliptok.lua', 'fliptokverify'],
|
||||
['../../sky_phone/source/server/picstagram.lua', 'picstagramverify'],
|
||||
['../../sky_phone/source/server/picstagram.lua', 'picstagramadmin'],
|
||||
] as const
|
||||
|
||||
for (const [path, permission] of expectations) {
|
||||
expect(source(path)).toContain(
|
||||
`Bridge.Framework.HasPermission(source, "${permission}")`,
|
||||
)
|
||||
}
|
||||
})
|
||||
})
|
||||
@@ -3,27 +3,17 @@ import { readFileSync } from 'node:fs'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
const readResourceFile = (path: string) =>
|
||||
readFileSync(
|
||||
new URL(`../../sky_phone/${path}`, import.meta.url),
|
||||
'utf8',
|
||||
).replace(/\r\n/g, '\n')
|
||||
readFileSync(new URL(`../../sky_phone/${path}`, import.meta.url), 'utf8').replace(/\r\n/g, '\n')
|
||||
const readFrontendFile = (path: string) =>
|
||||
readFileSync(new URL(path, import.meta.url), 'utf8')
|
||||
|
||||
const inventoryAdapters = [
|
||||
['jaksam', 'source/bridge/server/inventory/jaksam.lua'],
|
||||
['ox', 'source/bridge/server/inventory/ox.lua'],
|
||||
['qb', 'source/bridge/server/inventory/qb.lua'],
|
||||
['lj', 'source/bridge/server/inventory/qb.lua'],
|
||||
['qs', 'source/bridge/server/inventory/qs.lua'],
|
||||
['ps', 'source/bridge/server/inventory/ps.lua'],
|
||||
['codem', 'source/bridge/server/inventory/codem.lua'],
|
||||
['tgiann', 'source/bridge/server/inventory/tgiann.lua'],
|
||||
['core', 'source/bridge/server/inventory/core.lua'],
|
||||
['jpr', 'source/bridge/server/inventory/jpr.lua'],
|
||||
['origen', 'source/bridge/server/inventory/origen.lua'],
|
||||
['ak47', 'source/bridge/server/inventory/ak47.lua'],
|
||||
['one', 'source/bridge/server/inventory/one.lua'],
|
||||
['mf', 'source/bridge/server/inventory/mf.lua'],
|
||||
['smx', 'source/bridge/server/inventory/smx.lua'],
|
||||
['hex', 'source/bridge/server/inventory/esx.lua'],
|
||||
@@ -52,30 +42,17 @@ describe('phone inventory contracts', () => {
|
||||
)
|
||||
})
|
||||
|
||||
it('auto-detects registered inventories and forces metadata-free adapters into compatible modes', () => {
|
||||
it('auto-detects HEX and limits count-based ESX inventories to metadata-free modes', () => {
|
||||
const inventoryBridge = readResourceFile(
|
||||
'source/bridge/server/inventory.lua',
|
||||
)
|
||||
|
||||
expect(inventoryBridge).toContain(
|
||||
'{ name = "hex", resource = "hex_4_inventory", framework = "esx", metadata = false },',
|
||||
)
|
||||
expect(inventoryBridge).toContain(
|
||||
'GetResourceState(adapter.resource) == "started"',
|
||||
)
|
||||
expect(inventoryBridge).toContain('configured_inventory = adapter.name')
|
||||
expect(inventoryBridge).toContain('selected_adapter.metadata == false')
|
||||
expect(inventoryBridge).toContain('Config.Phone.Unique = false')
|
||||
expect(inventoryBridge).toContain('Config.Sim.Enabled = false')
|
||||
expect(inventoryBridge).toContain(
|
||||
'does not support item metadata; unique phones and physical SIM cards were disabled automatically',
|
||||
)
|
||||
expect(inventoryBridge).toContain(
|
||||
'AddEventHandler("sky_phone:configurator:serverUpdated"',
|
||||
)
|
||||
expect(inventoryBridge).not.toContain(
|
||||
'cannot store unique phone or physical SIM metadata',
|
||||
'GetResourceState("hex_4_inventory") == "started"',
|
||||
)
|
||||
expect(inventoryBridge).toContain('configured_inventory = "hex"')
|
||||
expect(inventoryBridge).toContain('Config.Phone.Unique ~= false')
|
||||
expect(inventoryBridge).toContain('Config.Sim.Enabled ~= false')
|
||||
})
|
||||
|
||||
it('provides the LB IsOpen export alias from the authoritative client state', () => {
|
||||
@@ -126,15 +103,9 @@ describe('phone inventory contracts', () => {
|
||||
expect(equippedNumberExport).toBeDefined()
|
||||
expect(equippedNumberResolver).toBeDefined()
|
||||
expect(equippedNumberExport).toContain('type(player) == "number"')
|
||||
expect(equippedNumberExport).toContain(
|
||||
'online_source_for_identifier(player)',
|
||||
)
|
||||
expect(phoneServer).toContain(
|
||||
'Bridge.Inventory.GetSlotsWithItem(source, Config.Phone.Item)',
|
||||
)
|
||||
expect(phoneServer).toContain(
|
||||
'return resolve_equipped_phone_number(player)',
|
||||
)
|
||||
expect(equippedNumberExport).toContain('online_source_for_identifier(player)')
|
||||
expect(phoneServer).toContain('Bridge.Inventory.GetSlotsWithItem(source, Config.Phone.Item)')
|
||||
expect(phoneServer).toContain('return resolve_equipped_phone_number(player)')
|
||||
expect(equippedNumberExport).not.toContain('tonumber(player)')
|
||||
expect(equippedNumberExport).not.toContain('equipped_phone_numbers[player]')
|
||||
expect(equippedNumberResolver).not.toContain('return cached_number')
|
||||
@@ -189,9 +160,7 @@ describe('phone inventory contracts', () => {
|
||||
expect(phoneClient).toContain(
|
||||
'TriggerEvent("sky_phone:client:phoneToggled", false)',
|
||||
)
|
||||
expect(phoneBridge).toContain(
|
||||
'TriggerEvent("lb-phone:numberChanged", phone_number)',
|
||||
)
|
||||
expect(phoneBridge).toContain('TriggerEvent("lb-phone:numberChanged", phone_number)')
|
||||
expect(phoneBridge).toContain('TriggerEvent("lb-phone:phoneToggled", open)')
|
||||
})
|
||||
|
||||
@@ -244,9 +213,7 @@ describe('phone inventory contracts', () => {
|
||||
expect(mediaServer).toContain(
|
||||
'TriggerEvent("sky_phone:server:galleryMediaDeleted", src, phone_number, deleted_link)',
|
||||
)
|
||||
expect(phoneBridge).toContain(
|
||||
'TriggerEvent("lb-phone:phoneNumberGenerated"',
|
||||
)
|
||||
expect(phoneBridge).toContain('TriggerEvent("lb-phone:phoneNumberGenerated"')
|
||||
expect(phoneBridge).toContain('TriggerEvent("lb-phone:factoryReset"')
|
||||
expect(phoneBridge).toContain('TriggerEvent("lb-phone:deletedFromGallery"')
|
||||
})
|
||||
|
||||
@@ -10,22 +10,14 @@ type LuaToken = {
|
||||
}
|
||||
|
||||
const frontendSourceDirectory = fileURLToPath(new URL('../', import.meta.url))
|
||||
const localeDirectory = fileURLToPath(
|
||||
new URL('../../../sky_phone/config/locales/', import.meta.url),
|
||||
const englishLocaleSource = readFileSync(
|
||||
new URL('../../../sky_phone/config/locales/en.lua', import.meta.url),
|
||||
'utf8',
|
||||
)
|
||||
const localeSources = new Map(
|
||||
readdirSync(localeDirectory, { withFileTypes: true })
|
||||
.filter((entry) => entry.isFile() && entry.name.endsWith('.lua'))
|
||||
.map((entry) => [
|
||||
entry.name.replace(/\.lua$/, ''),
|
||||
readFileSync(join(localeDirectory, entry.name), 'utf8'),
|
||||
]),
|
||||
const germanLocaleSource = readFileSync(
|
||||
new URL('../../../sky_phone/config/locales/de.lua', import.meta.url),
|
||||
'utf8',
|
||||
)
|
||||
const englishLocaleSource = localeSources.get('en')
|
||||
const germanLocaleSource = localeSources.get('de')
|
||||
if (!englishLocaleSource || !germanLocaleSource) {
|
||||
throw new Error('The bundled English and German phone locales are required.')
|
||||
}
|
||||
const phoneStoreSource = readFileSync(
|
||||
new URL('./phone.ts', import.meta.url),
|
||||
'utf8',
|
||||
@@ -156,10 +148,6 @@ function collectPlaceholders(value: string): string[] {
|
||||
return [...new Set(value.match(/\{[A-Za-z0-9_]+\}/g) ?? [])].sort()
|
||||
}
|
||||
|
||||
function collectNumberTokens(value: string): string[] {
|
||||
return value.match(/\d+/g) ?? []
|
||||
}
|
||||
|
||||
function collectDefaultLocalePaths(source: string): Set<string> {
|
||||
const ast = ts.createSourceFile(
|
||||
'phone.ts',
|
||||
@@ -235,26 +223,10 @@ function collectFrontendFiles(directory: string): string[] {
|
||||
}
|
||||
|
||||
describe('phone locale contract', () => {
|
||||
const localeValues = new Map(
|
||||
[...localeSources].map(([locale, source]) => [
|
||||
locale,
|
||||
collectLuaLocaleValues(source),
|
||||
]),
|
||||
)
|
||||
const englishValues = localeValues.get('en')!
|
||||
const germanValues = localeValues.get('de')!
|
||||
const translatedLocaleValues = [...localeValues].filter(
|
||||
([locale]) => locale !== 'en',
|
||||
)
|
||||
const englishValues = collectLuaLocaleValues(englishLocaleSource)
|
||||
const germanValues = collectLuaLocaleValues(germanLocaleSource)
|
||||
const englishPaths = new Set(englishValues.keys())
|
||||
|
||||
it.each([...localeSources])(
|
||||
'registers the %s locale under its file name',
|
||||
(locale, source) => {
|
||||
expect(source.match(/^Locales\["([^"]+)"\]/)?.[1]).toBe(locale)
|
||||
},
|
||||
)
|
||||
|
||||
it('keeps every bundled frontend fallback in en.lua', () => {
|
||||
const missing = [...collectDefaultLocalePaths(phoneStoreSource)].filter(
|
||||
(path) => !englishPaths.has(`Nui.${path}`),
|
||||
@@ -299,52 +271,26 @@ describe('phone locale contract', () => {
|
||||
}
|
||||
})
|
||||
|
||||
it.each(translatedLocaleValues)(
|
||||
'keeps %s structurally aligned with English',
|
||||
(_locale, values) => {
|
||||
expect([...values.keys()].sort()).toEqual([...englishPaths].sort())
|
||||
},
|
||||
)
|
||||
it('keeps German structurally aligned with English', () => {
|
||||
const germanPaths = new Set(germanValues.keys())
|
||||
|
||||
it.each(translatedLocaleValues)(
|
||||
'keeps %s interpolation placeholders aligned with English',
|
||||
(_locale, values) => {
|
||||
const mismatches = [...englishValues].flatMap(
|
||||
([path, englishValue]) => {
|
||||
const translatedValue = values.get(path)
|
||||
return translatedValue !== undefined &&
|
||||
JSON.stringify(collectPlaceholders(translatedValue)) !==
|
||||
JSON.stringify(collectPlaceholders(englishValue))
|
||||
? [
|
||||
`${path}: ${collectPlaceholders(englishValue).join(', ')} != ${collectPlaceholders(translatedValue).join(', ')}`,
|
||||
]
|
||||
: []
|
||||
},
|
||||
)
|
||||
expect([...germanPaths].sort()).toEqual([...englishPaths].sort())
|
||||
})
|
||||
|
||||
expect(mismatches).toEqual([])
|
||||
},
|
||||
)
|
||||
it('keeps German interpolation placeholders aligned with English', () => {
|
||||
const mismatches = [...englishValues].flatMap(([path, englishValue]) => {
|
||||
const germanValue = germanValues.get(path)
|
||||
return germanValue !== undefined &&
|
||||
JSON.stringify(collectPlaceholders(germanValue)) !==
|
||||
JSON.stringify(collectPlaceholders(englishValue))
|
||||
? [
|
||||
`${path}: ${collectPlaceholders(englishValue).join(', ')} != ${collectPlaceholders(germanValue).join(', ')}`,
|
||||
]
|
||||
: []
|
||||
})
|
||||
|
||||
it.each(translatedLocaleValues)(
|
||||
'keeps %s numeric source values intact',
|
||||
(_locale, values) => {
|
||||
const mismatches = [...englishValues].flatMap(([path, englishValue]) => {
|
||||
const expected = collectNumberTokens(englishValue)
|
||||
if (!expected.length) return []
|
||||
|
||||
const remaining = collectNumberTokens(values.get(path) ?? '')
|
||||
for (const token of expected) {
|
||||
const index = remaining.indexOf(token)
|
||||
if (index >= 0) remaining.splice(index, 1)
|
||||
else return [`${path}: missing numeric token ${token}`]
|
||||
}
|
||||
return []
|
||||
})
|
||||
|
||||
expect(mismatches).toEqual([])
|
||||
},
|
||||
)
|
||||
expect(mismatches).toEqual([])
|
||||
})
|
||||
|
||||
it('keeps standard app names German and custom game names unchanged', () => {
|
||||
const standardAppNames = {
|
||||
|
||||
@@ -945,6 +945,7 @@ const adminPanelFallbackLocales = {
|
||||
entry: 'Entry',
|
||||
general: 'General',
|
||||
subtabs: {
|
||||
AdminGroups: 'Admin Groups',
|
||||
Dictionaries: 'Dictionaries',
|
||||
Clips: 'Clips',
|
||||
Transforms: 'Transforms',
|
||||
|
||||
@@ -16,7 +16,9 @@ describe('admin configurator descriptions', () => {
|
||||
expect(configuratorDescriptionKey('Media.RequestTimeoutMs', 10000)).toBe(
|
||||
'milliseconds',
|
||||
)
|
||||
expect(configuratorDescriptionKey('Radio.AllowedJobs', [])).toBe('access')
|
||||
expect(configuratorDescriptionKey('AdminPanel.AdminGroups', [])).toBe(
|
||||
'access',
|
||||
)
|
||||
expect(configuratorDescriptionKey('FiveManage.ApiKey', '')).toBe(
|
||||
'credential',
|
||||
)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { readdirSync, readFileSync } from 'node:fs'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
import { describe, expect, it } from 'vitest'
|
||||
@@ -41,21 +41,24 @@ describe('App Store preview catalog', () => {
|
||||
expect(visualSignatures.size).toBe(storeAppIds.length)
|
||||
})
|
||||
|
||||
it('localizes every specialized preview in the fallback and every configured locale', () => {
|
||||
const localeDirectory = fileURLToPath(
|
||||
new URL('../../../sky_phone/config/locales/', import.meta.url),
|
||||
)
|
||||
it('localizes every specialized preview in the fallback, English and German locales', () => {
|
||||
const localeSources = [
|
||||
readFileSync(
|
||||
fileURLToPath(new URL('../stores/phone.ts', import.meta.url)),
|
||||
'utf8',
|
||||
),
|
||||
...readdirSync(localeDirectory)
|
||||
.filter((fileName) => fileName.endsWith('.lua'))
|
||||
.sort()
|
||||
.map((fileName) =>
|
||||
readFileSync(`${localeDirectory}/${fileName}`, 'utf8'),
|
||||
readFileSync(
|
||||
fileURLToPath(
|
||||
new URL('../../../sky_phone/config/locales/en.lua', import.meta.url),
|
||||
),
|
||||
'utf8',
|
||||
),
|
||||
readFileSync(
|
||||
fileURLToPath(
|
||||
new URL('../../../sky_phone/config/locales/de.lua', import.meta.url),
|
||||
),
|
||||
'utf8',
|
||||
),
|
||||
]
|
||||
|
||||
for (const appId of PREVIEWABLE_BUILTIN_APP_IDS) {
|
||||
|
||||
@@ -661,7 +661,6 @@ function loadConfiguratorSections() {
|
||||
)
|
||||
const media = mediaRoot.Media
|
||||
delete config.PhoneConfigurator
|
||||
delete config.CommandPermissions
|
||||
delete config.Media
|
||||
return [...buildSections('config', config), ...buildSections('media', media)]
|
||||
}
|
||||
|
||||
@@ -61,19 +61,14 @@ function countStructure(structure: ConfiguratorStructure | undefined): number {
|
||||
}
|
||||
|
||||
describe('admin configurator fixture', () => {
|
||||
it('exposes every SQL-managed config.lua root through the full live preview', () => {
|
||||
it('exposes every config.lua root through the full live preview', () => {
|
||||
const sections = loadConfiguratorSections()
|
||||
const fields = sections.flatMap((section) => section.fields)
|
||||
const roots = [
|
||||
...configSource.matchAll(/^\s{0,4}Config\.([A-Za-z0-9_]+)\s*=/gm),
|
||||
]
|
||||
.map((match) => match[1])
|
||||
.filter(
|
||||
(root) =>
|
||||
root !== 'Media' &&
|
||||
root !== 'PhoneConfigurator' &&
|
||||
root !== 'CommandPermissions',
|
||||
)
|
||||
.filter((root) => root !== 'Media' && root !== 'PhoneConfigurator')
|
||||
|
||||
expect(sections).toHaveLength(45)
|
||||
expect(
|
||||
|
||||
+2
-15
@@ -134,7 +134,7 @@ Sky Phone is built to be the **free FiveM phone you can choose without accepting
|
||||
- `hex_4_inventory`
|
||||
- Native ESX inventory
|
||||
|
||||
`mf-inventory` and `smx-inventory` are supported with ESX. The native ESX and HEX adapters use count-based items, so Sky Phone automatically disables unique phones and physical SIM cards while either adapter is active.
|
||||
`mf-inventory` and `smx-inventory` are supported with ESX. The native ESX and HEX adapters use count-based items and therefore require unique phones and physical SIM cards to be disabled.
|
||||
|
||||
### Voice
|
||||
|
||||
@@ -196,7 +196,6 @@ The files contain clearly separated sections for:
|
||||
| Section | Purpose |
|
||||
| --- | --- |
|
||||
| `Config.Bridge` | Framework, inventory, language, callback timeout, and debug mode |
|
||||
| `Config.CommandPermissions` | Fixed groups for the admin panel, test data, verification commands, and social moderation |
|
||||
| `Config.Phone` | Phone item, movement, unique-device mode, and development command |
|
||||
| `Config.Sim` | Physical or virtual SIM behavior and number formatting |
|
||||
| `Config.Calls` / `Config.Radio` | Voice providers, call behavior, radio limits, and permissions |
|
||||
@@ -212,18 +211,6 @@ The files contain clearly separated sections for:
|
||||
|
||||
Restart `sky_phone` after changing Lua configuration.
|
||||
|
||||
When `Config.PhoneConfigurator.Enabled` is enabled, the generated `source/shared/config_default.lua`
|
||||
provides the shipped SQL baseline. The frontend build recreates it from `config.lua` and the
|
||||
server-only `media.lua`; do not edit the generated snapshot directly.
|
||||
|
||||
`Config.PhoneConfigurator` and `Config.CommandPermissions` remain file-owned and are omitted from
|
||||
the generated default snapshot. Permissions are not displayed in the Phone Configurator and stay
|
||||
authoritative while SQL configuration is enabled. Their stable keys do not change when a command is
|
||||
renamed in the panel. ESX and QBCore use their framework permissions. Qbox checks the configured ACE
|
||||
objects first and then its framework groups, so the standard `permissions.cfg` mapping from
|
||||
`group.admin` to the `admin` ACE works with the shipped `phonepanel` permission list. Restart
|
||||
`sky_phone` after changing fixed permissions.
|
||||
|
||||
### Language
|
||||
|
||||
Available locales:
|
||||
@@ -325,7 +312,7 @@ Do not configure an LB Phone client event or client export. Sky Phone registers
|
||||
|
||||
The server registers `Config.Phone.Item` as usable for every supported inventory adapter: `ox`, `qb`, `lj`, `qs`, `codem`, `core`, `mf`, `smx`, `hex`, and `esx`. Resource startup fails visibly if the selected adapter cannot complete that registration.
|
||||
|
||||
The `hex` and `esx` adapters use ESX's count-based item API, which cannot persist per-item phone or physical SIM metadata. Sky Phone automatically forces `Config.Phone.Unique = false` and `Config.Sim.Enabled = false` while either adapter is active. `auto` selects `hex` when `hex_4_inventory` is started and otherwise falls back to `esx` on an ESX server when no metadata-capable inventory is detected.
|
||||
The `hex` and `esx` adapters use ESX's count-based item API. They require both `Config.Phone.Unique = false` and `Config.Sim.Enabled = false` because this API cannot persist per-item phone or physical SIM metadata. `auto` selects `hex` when `hex_4_inventory` is started and otherwise falls back to `esx` on an ESX server when no metadata-capable inventory is detected.
|
||||
|
||||
### QBCore-style item tables
|
||||
|
||||
|
||||
@@ -10,36 +10,19 @@
|
||||
Keep option names unchanged. Restart sky_phone after editing this file.
|
||||
]]
|
||||
|
||||
-- CONFIG_DEFAULT_EXCLUDE_START
|
||||
-- When enabled, the active configuration is loaded from SQL and managed through
|
||||
-- /phonepanel. Frontend builds snapshot the shipped defaults from config.lua and
|
||||
-- media.lua into source/shared/config_default.lua.
|
||||
-- When enabled, config.lua and media.lua only provide first-run defaults.
|
||||
-- The active configuration is loaded from SQL and managed through /phonepanel.
|
||||
Config.PhoneConfigurator = {
|
||||
Enabled = true,
|
||||
}
|
||||
|
||||
-- Fixed server permissions. These values remain authoritative even while the
|
||||
-- Phone Configurator is enabled and are intentionally not shown in its panel.
|
||||
-- Group names use the active framework's permissions. On Qbox they also match
|
||||
-- ACE objects such as "admin" from the standard permissions.cfg.
|
||||
Config.CommandPermissions = {
|
||||
phonepanel = { "god", "superadmin", "admin" },
|
||||
phonetestdata = { "god", "superadmin", "admin" },
|
||||
fliptokverify = { "god", "superadmin", "admin" },
|
||||
picstagramverify = { "god", "superadmin", "admin" },
|
||||
picstagramadmin = { "god", "superadmin", "admin" },
|
||||
}
|
||||
-- CONFIG_DEFAULT_EXCLUDE_END
|
||||
|
||||
-- =============================================================================
|
||||
-- Core, framework and device
|
||||
-- =============================================================================
|
||||
|
||||
Config.Bridge = {
|
||||
Framework = "auto", -- auto, esx, qbox, qb
|
||||
-- auto, ak47, codem, core, jaksam, jpr, lj, mf, one, origen, ox, ps, qb, qs, smx, tgiann, hex, esx
|
||||
-- Compatibility aliases: qb-inv -> qb, qbox -> ox
|
||||
Inventory = "auto",
|
||||
Inventory = "auto", -- auto, ox, qb, lj, qs, codem, core, mf, smx, hex, esx
|
||||
Locale = "en",
|
||||
CallbackTimeout = 15000,
|
||||
Debug = false, -- true: show debug/info output; warnings and errors are always shown
|
||||
@@ -49,7 +32,7 @@ Config.Command = "phone"
|
||||
|
||||
Config.Phone = {
|
||||
Item = "phone",
|
||||
Unique = true, -- true: data follows each phone item; false: one persistent phone per character; forced false for metadata-free inventories
|
||||
Unique = true, -- true: data follows each phone item; false: one persistent phone per character; hex/esx require false
|
||||
Keybind = "F1", -- false disables the configurable phone key mapping
|
||||
AllowMovement = true, -- true: game input stays active while the mobile phone is open
|
||||
HoldToLook = {
|
||||
@@ -64,6 +47,7 @@ Config.TestData = {
|
||||
Enabled = false, -- development/test servers only; keep disabled in production
|
||||
Command = "phonetestdata",
|
||||
AdminOnly = false, -- enable only on development servers; every run is scoped to the executing player's phone
|
||||
AdminGroups = { "admin", "superadmin" },
|
||||
}
|
||||
|
||||
Config.CustomApps = {
|
||||
@@ -90,6 +74,7 @@ Config.Security = {
|
||||
Config.AdminPanel = {
|
||||
Enabled = true,
|
||||
Command = "phonepanel",
|
||||
AdminGroups = { "admin", "superadmin" },
|
||||
MaximumPlayers = 128,
|
||||
ReadRequestsPerMinute = 60,
|
||||
ActionRequestsPerMinute = 30,
|
||||
@@ -99,7 +84,7 @@ Config.AdminPanel = {
|
||||
}
|
||||
|
||||
Config.Sim = {
|
||||
Enabled = true, -- false: devices receive a persistent random number automatically; forced false for metadata-free inventories
|
||||
Enabled = true, -- false: devices receive a persistent random number automatically; hex/esx require false
|
||||
RegisteredItem = "sky_phone_sim_registered",
|
||||
AnonymousItem = "sky_phone_sim_anonymous",
|
||||
NumberLength = 10, -- total number of digits, including NumberPrefix
|
||||
@@ -498,6 +483,7 @@ Config.FlipTok = {
|
||||
MaxPostMedia = 10,
|
||||
MusicTracks = {},
|
||||
VerifyCommand = "fliptokverify",
|
||||
AdminGroups = { "admin" },
|
||||
ReportWebhookConvar = "sky_phone_fliptok_report_webhook",
|
||||
}
|
||||
|
||||
@@ -519,6 +505,7 @@ Config.Picstagram = {
|
||||
ReportDetailsMaxLength = 500,
|
||||
ReportReasons = { "spam", "harassment", "dangerous", "illegal", "other" },
|
||||
VerifyCommand = "picstagramverify",
|
||||
AdminGroups = { "admin" },
|
||||
}
|
||||
|
||||
Config.Feather = {
|
||||
|
||||
@@ -2139,6 +2139,7 @@ Locales["de"] = {
|
||||
}
|
||||
|
||||
Locales["de"].Nui.AdminPanel.configurator.table.subtabs = {
|
||||
AdminGroups = "Admin-Gruppen",
|
||||
Dictionaries = "Animationsdateien",
|
||||
Clips = "Clips",
|
||||
Transforms = "Transformationen",
|
||||
|
||||
@@ -2139,6 +2139,7 @@ Locales["en"] = {
|
||||
}
|
||||
|
||||
Locales["en"].Nui.AdminPanel.configurator.table.subtabs = {
|
||||
AdminGroups = "Admin Groups",
|
||||
Dictionaries = "Dictionaries",
|
||||
Clips = "Clips",
|
||||
Transforms = "Transforms",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,25 +2,19 @@
|
||||
Sky Phone media configuration
|
||||
|
||||
This file is loaded on the server only. Keep API keys private. When the
|
||||
phone configurator is enabled in config.lua, the active media configuration
|
||||
is loaded from SQL and frontend builds copy the shipped values from this
|
||||
file into source/shared/config_default.lua.
|
||||
phone configurator is enabled in config.lua, these values are first-run
|
||||
defaults and the active media configuration is loaded from SQL.
|
||||
]]
|
||||
|
||||
Config.Media = {
|
||||
-- Create or sign in to an account at https://developers.giphy.com/, open
|
||||
-- the Developer Dashboard, choose "Create an API Key", and paste it here.
|
||||
GiphyApiKey = "",
|
||||
GiphyApiKey = "", -- Paste the GIPHY API key here.
|
||||
GifPageSize = 24,
|
||||
GifRating = "pg-13",
|
||||
UrlMaxLength = 2048,
|
||||
AllowedGifHosts = { "giphy.com" },
|
||||
|
||||
-- Create or sign in at https://fivemanage.com/, create or select your team,
|
||||
-- then open Dashboard > Tokens and create a token with Media access. Keep
|
||||
-- this server-only token private and paste it here.
|
||||
FiveManage = {
|
||||
ApiKey = "",
|
||||
ApiKey = "", -- Paste a newly generated FiveManage V3 Media API token here.
|
||||
BaseUrl = "https://api.fivemanage.com/api/v3/file",
|
||||
RequestTimeoutMs = 10000,
|
||||
UploadTimeoutMs = 25000,
|
||||
|
||||
@@ -6,7 +6,7 @@ use_experimental_fxv2_oal 'yes'
|
||||
|
||||
author 'Sky-Systems'
|
||||
description 'Sky Phone'
|
||||
version '0.2.7'
|
||||
version '0.2.5'
|
||||
|
||||
provide 'lb-phone'
|
||||
provide '17mov_Phone'
|
||||
@@ -32,7 +32,6 @@ client_scripts {
|
||||
'config/config.lua',
|
||||
'config/locales/en.lua',
|
||||
'config/locales/de.lua',
|
||||
'config/locales/es.lua',
|
||||
'source/bridge/client/callbacks.lua',
|
||||
'source/client/phone_configurator.lua',
|
||||
'source/bridge/client/framework.lua',
|
||||
@@ -78,8 +77,6 @@ server_scripts {
|
||||
'config/media.lua',
|
||||
'config/locales/en.lua',
|
||||
'config/locales/de.lua',
|
||||
'config/locales/es.lua',
|
||||
'source/shared/config_default.lua',
|
||||
'source/server/nui_build_check.lua',
|
||||
'source/server/update_check.lua',
|
||||
'source/bridge/server/database.lua',
|
||||
|
||||
@@ -19,23 +19,3 @@ Bridge.Framework.Name = configured_framework
|
||||
function Bridge.Framework.GetName()
|
||||
return Bridge.Framework.Name
|
||||
end
|
||||
|
||||
function Bridge.Framework.HasPermission(source, permission)
|
||||
if type(permission) ~= "string" or permission == "" then
|
||||
error("[sky_phone] Permission identifiers must be non-empty strings.")
|
||||
end
|
||||
|
||||
local groups = Config.CommandPermissions[permission]
|
||||
if type(groups) ~= "table" or #groups == 0 then
|
||||
local message = "[sky_phone] Config.CommandPermissions.%s must contain at least one group."
|
||||
error(message:format(permission))
|
||||
end
|
||||
for index, group in ipairs(groups) do
|
||||
if type(group) ~= "string" or group == "" then
|
||||
local message = "[sky_phone] Config.CommandPermissions.%s[%s] must be a non-empty string."
|
||||
error(message:format(permission, index))
|
||||
end
|
||||
end
|
||||
|
||||
return Bridge.Framework.HasAdminGroup(source, groups)
|
||||
end
|
||||
|
||||
@@ -24,13 +24,6 @@ function Bridge.Framework.HasAdminGroup(source, groups)
|
||||
if not player then
|
||||
return false
|
||||
end
|
||||
|
||||
for _, group in ipairs(groups) do
|
||||
if IsPlayerAceAllowed(tostring(source), group) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
return exports.qbx_core:HasGroup(source, groups)
|
||||
end
|
||||
|
||||
|
||||
@@ -1,92 +1,60 @@
|
||||
local inventory_adapters = {
|
||||
{ name = "jaksam", resource = "jaksam_inventory" },
|
||||
{ name = "qs", resource = "qs-inventory" },
|
||||
{ name = "ps", resource = "ps-inventory", framework = "qb" },
|
||||
{ name = "codem", resource = "codem-inventory" },
|
||||
{ name = "tgiann", resource = "tgiann-inventory" },
|
||||
{ name = "core", resource = "core_inventory" },
|
||||
{ name = "jpr", resource = "jpr-inventory", framework = "qb" },
|
||||
{ name = "origen", resource = "origen_inventory" },
|
||||
{ name = "ak47", resource = "ak47_inventory" },
|
||||
{ name = "one", resource = "one_inventory" },
|
||||
{ name = "ox", resource = "ox_inventory" },
|
||||
{ name = "mf", resource = "mf-inventory", framework = "esx" },
|
||||
{ name = "smx", resource = "smx-inventory", framework = "esx" },
|
||||
{ name = "lj", resource = "lj-inventory" },
|
||||
{ name = "qb", resource = "qb-inventory" },
|
||||
{ name = "hex", resource = "hex_4_inventory", framework = "esx", metadata = false },
|
||||
{ name = "esx", resource = "es_extended", framework = "esx", metadata = false },
|
||||
}
|
||||
|
||||
local inventory_aliases = {
|
||||
["qb-inv"] = "qb",
|
||||
qbox = "ox",
|
||||
}
|
||||
local supported_inventories = {}
|
||||
for _, adapter in ipairs(inventory_adapters) do
|
||||
inventory_aliases[adapter.resource] = adapter.name
|
||||
supported_inventories[adapter.name] = adapter
|
||||
end
|
||||
|
||||
local configured_inventory = Config.Bridge.Inventory
|
||||
configured_inventory = inventory_aliases[configured_inventory] or configured_inventory
|
||||
local framework_name = Bridge.Framework.GetName()
|
||||
|
||||
if configured_inventory == "auto" then
|
||||
for _, adapter in ipairs(inventory_adapters) do
|
||||
local compatible_framework = not adapter.framework or adapter.framework == framework_name
|
||||
if adapter.name ~= "esx" and compatible_framework and GetResourceState(adapter.resource) == "started" then
|
||||
configured_inventory = adapter.name
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if configured_inventory == "auto" and framework_name == "esx" then
|
||||
if GetResourceState("ox_inventory") == "started" then
|
||||
configured_inventory = "ox"
|
||||
elseif GetResourceState("qb-inventory") == "started" then
|
||||
configured_inventory = "qb"
|
||||
elseif GetResourceState("lj-inventory") == "started" then
|
||||
configured_inventory = "lj"
|
||||
elseif GetResourceState("qs-inventory") == "started" then
|
||||
configured_inventory = "qs"
|
||||
elseif GetResourceState("codem-inventory") == "started" then
|
||||
configured_inventory = "codem"
|
||||
elseif GetResourceState("core_inventory") == "started" then
|
||||
configured_inventory = "core"
|
||||
elseif GetResourceState("mf-inventory") == "started" then
|
||||
configured_inventory = "mf"
|
||||
elseif GetResourceState("smx-inventory") == "started" then
|
||||
configured_inventory = "smx"
|
||||
elseif GetResourceState("hex_4_inventory") == "started" then
|
||||
configured_inventory = "hex"
|
||||
elseif Bridge.Framework.GetName() == "esx" then
|
||||
configured_inventory = "esx"
|
||||
end
|
||||
end
|
||||
|
||||
local selected_adapter = supported_inventories[configured_inventory]
|
||||
if not selected_adapter then
|
||||
local supported_inventories = {
|
||||
ox = true,
|
||||
qb = true,
|
||||
lj = true,
|
||||
qs = true,
|
||||
codem = true,
|
||||
core = true,
|
||||
mf = true,
|
||||
smx = true,
|
||||
hex = true,
|
||||
esx = true,
|
||||
}
|
||||
|
||||
if not supported_inventories[configured_inventory] then
|
||||
error(("[sky_phone] Unsupported or unavailable inventory '%s'. Configure a supported inventory adapter."):format(tostring(configured_inventory)))
|
||||
end
|
||||
if GetResourceState(selected_adapter.resource) ~= "started" then
|
||||
error(("[sky_phone] Inventory '%s' is configured, but resource '%s' is not started.")
|
||||
:format(tostring(configured_inventory), selected_adapter.resource))
|
||||
end
|
||||
if selected_adapter.framework and selected_adapter.framework ~= framework_name then
|
||||
error(("[sky_phone] Inventory '%s' is only supported with framework '%s'.")
|
||||
:format(tostring(configured_inventory), selected_adapter.framework))
|
||||
end
|
||||
|
||||
Bridge.Inventory.Name = configured_inventory
|
||||
|
||||
local metadata_free_inventory = selected_adapter.metadata == false
|
||||
|
||||
local function enforce_metadata_compatibility()
|
||||
if not metadata_free_inventory then
|
||||
return
|
||||
end
|
||||
|
||||
local modes_changed = Config.Phone.Unique ~= false or Config.Sim.Enabled ~= false
|
||||
Config.Phone.Unique = false
|
||||
Config.Sim.Enabled = false
|
||||
|
||||
if modes_changed then
|
||||
Bridge.Debug(
|
||||
"warn",
|
||||
"[sky_phone] Inventory '%s' does not support item metadata; unique phones and physical SIM cards were disabled automatically.",
|
||||
configured_inventory
|
||||
)
|
||||
if configured_inventory == "hex" or configured_inventory == "esx" then
|
||||
if Bridge.Framework.GetName() ~= "esx" then
|
||||
Bridge.Inventory.ConfigurationError =
|
||||
("[sky_phone] Inventory '%s' is only supported with ESX."):format(configured_inventory)
|
||||
elseif Config.Phone.Unique ~= false or Config.Sim.Enabled ~= false then
|
||||
Bridge.Inventory.ConfigurationError = ("[sky_phone] Inventory '%s' cannot store unique phone or physical SIM metadata. Set Config.Phone.Unique = false and Config.Sim.Enabled = false, or configure a metadata-capable inventory.")
|
||||
:format(configured_inventory)
|
||||
end
|
||||
end
|
||||
|
||||
enforce_metadata_compatibility()
|
||||
|
||||
AddEventHandler("sky_phone:configurator:serverUpdated", enforce_metadata_compatibility)
|
||||
|
||||
function Bridge.Inventory.NormalizeItem(item, metadata_field, fallback_slot)
|
||||
if type(item) ~= "table" then
|
||||
function Bridge.Inventory.NormalizeItem(item, metadata_field)
|
||||
if not item then
|
||||
return nil
|
||||
end
|
||||
|
||||
@@ -95,15 +63,11 @@ function Bridge.Inventory.NormalizeItem(item, metadata_field, fallback_slot)
|
||||
metadata = item.metadata or item.info
|
||||
end
|
||||
|
||||
local slot = item.slot or item.id or fallback_slot
|
||||
local numeric_slot = tonumber(slot)
|
||||
local count = tonumber(item.count or item.amount or item.quantity) or 0
|
||||
|
||||
return {
|
||||
name = item.name or item.item,
|
||||
slot = numeric_slot or slot,
|
||||
count = count,
|
||||
amount = count,
|
||||
name = item.name,
|
||||
slot = item.slot or item.id,
|
||||
count = tonumber(item.count or item.amount) or 0,
|
||||
amount = tonumber(item.amount or item.count) or 0,
|
||||
metadata = type(metadata) == "table" and metadata or {},
|
||||
}
|
||||
end
|
||||
@@ -120,13 +84,3 @@ function Bridge.Inventory.MetadataMatches(actual, expected)
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function Bridge.Inventory.ResolveUsableItem(...)
|
||||
for index = select("#", ...), 1, -1 do
|
||||
local candidate = select(index, ...)
|
||||
if type(candidate) == "table" and (candidate.name or candidate.item) then
|
||||
return candidate
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
if Bridge.Inventory.Name ~= "ak47" then
|
||||
return
|
||||
end
|
||||
|
||||
local inventory = exports["ak47_inventory"]
|
||||
|
||||
local function normalize(item, fallback_slot)
|
||||
local normalized = Bridge.Inventory.NormalizeItem(item, "info", fallback_slot)
|
||||
if not normalized or not normalized.name or normalized.amount < 1 then
|
||||
return nil
|
||||
end
|
||||
return normalized
|
||||
end
|
||||
|
||||
function Bridge.Inventory.GetResourceName()
|
||||
return "ak47_inventory"
|
||||
end
|
||||
|
||||
function Bridge.Inventory.GetSlot(source, slot_id)
|
||||
local identifier = Bridge.Framework.GetIdentifier(source)
|
||||
local numeric_slot = tonumber(slot_id)
|
||||
if not identifier or not numeric_slot then
|
||||
return nil
|
||||
end
|
||||
return normalize(inventory:GetSlot(identifier, numeric_slot), numeric_slot)
|
||||
end
|
||||
|
||||
function Bridge.Inventory.GetSlotsWithItem(source, item_name, metadata)
|
||||
local identifier = Bridge.Framework.GetIdentifier(source)
|
||||
if not identifier then
|
||||
return {}
|
||||
end
|
||||
|
||||
local matches = {}
|
||||
local filter_metadata = type(metadata) == "table" and metadata or nil
|
||||
for index, item in pairs(inventory:GetSlotsWithItem(identifier, item_name, filter_metadata, filter_metadata ~= nil) or {}) do
|
||||
local normalized = normalize(item, tonumber(index) or index)
|
||||
if normalized and normalized.name == item_name
|
||||
and Bridge.Inventory.MetadataMatches(normalized.metadata, metadata) then
|
||||
matches[#matches + 1] = normalized
|
||||
end
|
||||
end
|
||||
return matches
|
||||
end
|
||||
|
||||
function Bridge.Inventory.SetSlotMetadata(source, slot_id, metadata)
|
||||
local identifier = Bridge.Framework.GetIdentifier(source)
|
||||
local slot = identifier and Bridge.Inventory.GetSlot(source, slot_id) or nil
|
||||
if not slot then
|
||||
return false
|
||||
end
|
||||
|
||||
local requested_metadata = type(metadata) == "table" and metadata or {}
|
||||
inventory:SetItemInfo(identifier, slot.slot, requested_metadata)
|
||||
local updated = Bridge.Inventory.GetSlot(source, slot.slot)
|
||||
return updated and Bridge.Inventory.MetadataMatches(updated.metadata, requested_metadata) or false
|
||||
end
|
||||
|
||||
function Bridge.Inventory.CanCarryItem(source, item_name, count)
|
||||
return inventory:CanAddItem(source, item_name, count) == true
|
||||
end
|
||||
|
||||
function Bridge.Inventory.AddItem(source, item_name, count, slot, metadata)
|
||||
if not Bridge.Inventory.CanCarryItem(source, item_name, count, metadata) then
|
||||
return false
|
||||
end
|
||||
return inventory:AddItem(source, item_name, count, slot, metadata or {}) == true
|
||||
end
|
||||
|
||||
function Bridge.Inventory.RemoveItem(source, item_name, count, slot, metadata)
|
||||
if metadata and not slot then
|
||||
local slots = Bridge.Inventory.GetSlotsWithItem(source, item_name, metadata)
|
||||
slot = slots[1] and slots[1].slot or nil
|
||||
if not slot then
|
||||
return 0
|
||||
end
|
||||
end
|
||||
|
||||
local removed = inventory:RemoveItem(source, item_name, count, slot)
|
||||
return removed ~= false and count or 0
|
||||
end
|
||||
|
||||
function Bridge.Inventory.RegisterUsableItem(item_name, callback)
|
||||
return Bridge.Framework.RegisterUsableItem(item_name, function(source, ...)
|
||||
callback(source, normalize(Bridge.Inventory.ResolveUsableItem(...)))
|
||||
end)
|
||||
end
|
||||
@@ -9,8 +9,7 @@ local function normalize(item)
|
||||
end
|
||||
|
||||
local function get_inventory(source)
|
||||
local identifier = Bridge.Framework.GetIdentifier(source)
|
||||
return identifier and inventory:GetInventory(identifier, source) or {}
|
||||
return inventory:GetInventory(false, source) or {}
|
||||
end
|
||||
|
||||
function Bridge.Inventory.GetResourceName()
|
||||
@@ -28,14 +27,9 @@ end
|
||||
|
||||
function Bridge.Inventory.GetSlotsWithItem(source, item_name, metadata)
|
||||
local matches = {}
|
||||
local items = inventory:GetItemsByName(source, item_name) or {}
|
||||
if items.name then
|
||||
items = { items }
|
||||
end
|
||||
for _, item in pairs(items) do
|
||||
for _, item in pairs(get_inventory(source)) do
|
||||
local normalized = normalize(item)
|
||||
if normalized and normalized.name == item_name
|
||||
and Bridge.Inventory.MetadataMatches(normalized.metadata, metadata) then
|
||||
if normalized.name == item_name and Bridge.Inventory.MetadataMatches(normalized.metadata, metadata) then
|
||||
matches[#matches + 1] = normalized
|
||||
end
|
||||
end
|
||||
@@ -72,7 +66,7 @@ function Bridge.Inventory.RemoveItem(source, item_name, count, slot, metadata)
|
||||
end
|
||||
|
||||
function Bridge.Inventory.RegisterUsableItem(item_name, callback)
|
||||
return Bridge.Framework.RegisterUsableItem(item_name, function(source, ...)
|
||||
callback(source, normalize(Bridge.Inventory.ResolveUsableItem(...)))
|
||||
return Bridge.Framework.RegisterUsableItem(item_name, function(source, item)
|
||||
callback(source, normalize(item))
|
||||
end)
|
||||
end
|
||||
|
||||
@@ -39,15 +39,11 @@ end
|
||||
|
||||
function Bridge.Inventory.SetSlotMetadata(source, slot_id, metadata)
|
||||
local numeric_slot = tonumber(slot_id)
|
||||
local slot = numeric_slot and Bridge.Inventory.GetSlot(source, numeric_slot) or nil
|
||||
if not slot then
|
||||
if not numeric_slot then
|
||||
return false
|
||||
end
|
||||
|
||||
local requested_metadata = type(metadata) == "table" and metadata or {}
|
||||
inventory:setMetadata(source, numeric_slot, requested_metadata)
|
||||
local updated = Bridge.Inventory.GetSlot(source, numeric_slot)
|
||||
return updated and Bridge.Inventory.MetadataMatches(updated.metadata, requested_metadata) or false
|
||||
inventory:setMetadata(source, numeric_slot, metadata or {})
|
||||
return true
|
||||
end
|
||||
|
||||
function Bridge.Inventory.CanCarryItem()
|
||||
|
||||
@@ -1,94 +0,0 @@
|
||||
if Bridge.Inventory.Name ~= "jaksam" then
|
||||
return
|
||||
end
|
||||
|
||||
local inventory = exports["jaksam_inventory"]
|
||||
|
||||
local function normalize(item)
|
||||
local normalized = Bridge.Inventory.NormalizeItem(item)
|
||||
if not normalized or not normalized.name or normalized.amount < 1 then
|
||||
return nil
|
||||
end
|
||||
return normalized
|
||||
end
|
||||
|
||||
local function get_inventory(source)
|
||||
local player_inventory = inventory:getInventory(source)
|
||||
return type(player_inventory) == "table" and type(player_inventory.items) == "table"
|
||||
and player_inventory.items or {}
|
||||
end
|
||||
|
||||
function Bridge.Inventory.GetResourceName()
|
||||
return "jaksam_inventory"
|
||||
end
|
||||
|
||||
function Bridge.Inventory.GetSlot(source, slot_id)
|
||||
for index, item in pairs(get_inventory(source)) do
|
||||
local normalized = normalize(item)
|
||||
local item_slot = normalized and (normalized.slot or tonumber(index)) or nil
|
||||
if tostring(item_slot) == tostring(slot_id) then
|
||||
normalized.slot = item_slot
|
||||
return normalized
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
function Bridge.Inventory.GetSlotsWithItem(source, item_name, metadata)
|
||||
local matches = {}
|
||||
for index, item in pairs(get_inventory(source)) do
|
||||
local normalized = normalize(item)
|
||||
if normalized and normalized.name == item_name
|
||||
and Bridge.Inventory.MetadataMatches(normalized.metadata, metadata) then
|
||||
normalized.slot = normalized.slot or tonumber(index) or index
|
||||
matches[#matches + 1] = normalized
|
||||
end
|
||||
end
|
||||
return matches
|
||||
end
|
||||
|
||||
function Bridge.Inventory.SetSlotMetadata(source, slot_id, metadata)
|
||||
local slot = Bridge.Inventory.GetSlot(source, slot_id)
|
||||
if not slot then
|
||||
return false
|
||||
end
|
||||
|
||||
local requested_metadata = type(metadata) == "table" and metadata or {}
|
||||
local success = inventory:setItemMetadataInSlot(source, slot.slot, requested_metadata)
|
||||
if success ~= true then
|
||||
return false
|
||||
end
|
||||
local updated = Bridge.Inventory.GetSlot(source, slot.slot)
|
||||
return updated and Bridge.Inventory.MetadataMatches(updated.metadata, requested_metadata) or false
|
||||
end
|
||||
|
||||
function Bridge.Inventory.CanCarryItem(source, item_name, count)
|
||||
return inventory:canCarryItem(source, item_name, count) == true
|
||||
end
|
||||
|
||||
function Bridge.Inventory.AddItem(source, item_name, count, slot, metadata)
|
||||
if not Bridge.Inventory.CanCarryItem(source, item_name, count, metadata) then
|
||||
return false
|
||||
end
|
||||
local success = inventory:addItem(source, item_name, count, metadata or {}, slot)
|
||||
return success == true
|
||||
end
|
||||
|
||||
function Bridge.Inventory.RemoveItem(source, item_name, count, slot, metadata)
|
||||
if metadata and not slot then
|
||||
local slots = Bridge.Inventory.GetSlotsWithItem(source, item_name, metadata)
|
||||
slot = slots[1] and slots[1].slot or nil
|
||||
if not slot then
|
||||
return 0
|
||||
end
|
||||
end
|
||||
local success = inventory:removeItem(source, item_name, count, nil, slot)
|
||||
return success == true and count or 0
|
||||
end
|
||||
|
||||
function Bridge.Inventory.RegisterUsableItem(item_name, callback)
|
||||
inventory:registerUsableItem(item_name, function(source, ...)
|
||||
callback(source, normalize(Bridge.Inventory.ResolveUsableItem(...)))
|
||||
end)
|
||||
return true
|
||||
end
|
||||
@@ -1,109 +0,0 @@
|
||||
if Bridge.Inventory.Name ~= "jpr" then
|
||||
return
|
||||
end
|
||||
|
||||
if Bridge.Framework.GetName() ~= "qb" then
|
||||
error("[sky_phone] jpr-inventory is only supported with QBCore.")
|
||||
end
|
||||
|
||||
local inventory = exports["jpr-inventory"]
|
||||
local QBCore = exports["qb-core"]:GetCoreObject()
|
||||
|
||||
local function normalize(item, fallback_slot)
|
||||
local normalized = Bridge.Inventory.NormalizeItem(item, "info", fallback_slot)
|
||||
if not normalized or not normalized.name or normalized.amount < 1 then
|
||||
return nil
|
||||
end
|
||||
return normalized
|
||||
end
|
||||
|
||||
local function get_inventory(source)
|
||||
local player = QBCore.Functions.GetPlayer(tonumber(source))
|
||||
return player and player.PlayerData.items or {}
|
||||
end
|
||||
|
||||
local function restore_slot(source, slot, metadata)
|
||||
local restored = inventory:AddItem(source, slot.name, slot.amount, slot.slot, metadata, "sky_phone:metadata-rollback")
|
||||
if not restored then
|
||||
Bridge.Debug(
|
||||
"error",
|
||||
"[sky_phone] jpr-inventory could not restore item '%s' in slot %s after a metadata update failed.",
|
||||
tostring(slot.name),
|
||||
tostring(slot.slot)
|
||||
)
|
||||
end
|
||||
return restored == true
|
||||
end
|
||||
|
||||
function Bridge.Inventory.GetResourceName()
|
||||
return "jpr-inventory"
|
||||
end
|
||||
|
||||
function Bridge.Inventory.GetSlot(source, slot_id)
|
||||
local numeric_slot = tonumber(slot_id)
|
||||
return numeric_slot and normalize(inventory:GetItemBySlot(source, numeric_slot), numeric_slot) or nil
|
||||
end
|
||||
|
||||
function Bridge.Inventory.GetSlotsWithItem(source, item_name, metadata)
|
||||
local matches = {}
|
||||
for index, item in pairs(get_inventory(source)) do
|
||||
local normalized = normalize(item, tonumber(index) or index)
|
||||
if normalized and normalized.name == item_name
|
||||
and Bridge.Inventory.MetadataMatches(normalized.metadata, metadata) then
|
||||
normalized.slot = normalized.slot or tonumber(index) or index
|
||||
matches[#matches + 1] = normalized
|
||||
end
|
||||
end
|
||||
return matches
|
||||
end
|
||||
|
||||
function Bridge.Inventory.SetSlotMetadata(source, slot_id, metadata)
|
||||
local slot = Bridge.Inventory.GetSlot(source, slot_id)
|
||||
if not slot or slot.amount < 1 then
|
||||
return false
|
||||
end
|
||||
|
||||
local previous_metadata = slot.metadata
|
||||
local requested_metadata = type(metadata) == "table" and metadata or {}
|
||||
if inventory:RemoveItem(source, slot.name, slot.amount, slot.slot, "sky_phone:metadata-update") ~= true then
|
||||
return false
|
||||
end
|
||||
if inventory:AddItem(source, slot.name, slot.amount, slot.slot, requested_metadata, "sky_phone:metadata-update") ~= true then
|
||||
restore_slot(source, slot, previous_metadata)
|
||||
return false
|
||||
end
|
||||
|
||||
local updated = Bridge.Inventory.GetSlot(source, slot.slot)
|
||||
if updated and Bridge.Inventory.MetadataMatches(updated.metadata, requested_metadata) then
|
||||
return true
|
||||
end
|
||||
|
||||
inventory:RemoveItem(source, slot.name, slot.amount, slot.slot, "sky_phone:metadata-rollback")
|
||||
restore_slot(source, slot, previous_metadata)
|
||||
return false
|
||||
end
|
||||
|
||||
function Bridge.Inventory.CanCarryItem()
|
||||
return true
|
||||
end
|
||||
|
||||
function Bridge.Inventory.AddItem(source, item_name, count, slot, metadata)
|
||||
return inventory:AddItem(source, item_name, count, slot, metadata or {}, "sky_phone") == true
|
||||
end
|
||||
|
||||
function Bridge.Inventory.RemoveItem(source, item_name, count, slot, metadata)
|
||||
if metadata and not slot then
|
||||
local slots = Bridge.Inventory.GetSlotsWithItem(source, item_name, metadata)
|
||||
slot = slots[1] and slots[1].slot or nil
|
||||
if not slot then
|
||||
return 0
|
||||
end
|
||||
end
|
||||
return inventory:RemoveItem(source, item_name, count, slot, "sky_phone") == true and count or 0
|
||||
end
|
||||
|
||||
function Bridge.Inventory.RegisterUsableItem(item_name, callback)
|
||||
return Bridge.Framework.RegisterUsableItem(item_name, function(source, ...)
|
||||
callback(source, normalize(Bridge.Inventory.ResolveUsableItem(...)))
|
||||
end)
|
||||
end
|
||||
@@ -1,76 +0,0 @@
|
||||
if Bridge.Inventory.Name ~= "one" then
|
||||
return
|
||||
end
|
||||
|
||||
local inventory = exports.one_inventory
|
||||
|
||||
local function normalize(item, fallback_slot)
|
||||
local normalized = Bridge.Inventory.NormalizeItem(item, nil, fallback_slot)
|
||||
if not normalized or not normalized.name or normalized.amount < 1 then
|
||||
return nil
|
||||
end
|
||||
return normalized
|
||||
end
|
||||
|
||||
function Bridge.Inventory.GetResourceName()
|
||||
return "one_inventory"
|
||||
end
|
||||
|
||||
function Bridge.Inventory.GetSlot(source, slot_id)
|
||||
local numeric_slot = tonumber(slot_id)
|
||||
return numeric_slot and normalize(inventory:GetSlot(source, numeric_slot), numeric_slot) or nil
|
||||
end
|
||||
|
||||
function Bridge.Inventory.GetSlotsWithItem(source, item_name, metadata)
|
||||
local matches = {}
|
||||
for index, item in pairs(inventory:SearchInventory(source, item_name, metadata) or {}) do
|
||||
local normalized = normalize(item, tonumber(index) or index)
|
||||
if normalized and normalized.name == item_name
|
||||
and Bridge.Inventory.MetadataMatches(normalized.metadata, metadata) then
|
||||
matches[#matches + 1] = normalized
|
||||
end
|
||||
end
|
||||
return matches
|
||||
end
|
||||
|
||||
function Bridge.Inventory.SetSlotMetadata(source, slot_id, metadata)
|
||||
local slot = Bridge.Inventory.GetSlot(source, slot_id)
|
||||
if not slot then
|
||||
return false
|
||||
end
|
||||
|
||||
local requested_metadata = type(metadata) == "table" and metadata or {}
|
||||
if inventory:SetItemMetadata(source, slot.slot, requested_metadata) ~= true then
|
||||
return false
|
||||
end
|
||||
local updated = Bridge.Inventory.GetSlot(source, slot.slot)
|
||||
return updated and Bridge.Inventory.MetadataMatches(updated.metadata, requested_metadata) or false
|
||||
end
|
||||
|
||||
function Bridge.Inventory.CanCarryItem(source, item_name, count)
|
||||
return inventory:CanCarryItem(source, item_name, count) == true
|
||||
end
|
||||
|
||||
function Bridge.Inventory.AddItem(source, item_name, count, slot, metadata)
|
||||
if not Bridge.Inventory.CanCarryItem(source, item_name, count, metadata) then
|
||||
return false
|
||||
end
|
||||
return inventory:AddItem(source, item_name, count, metadata or {}, slot) == true
|
||||
end
|
||||
|
||||
function Bridge.Inventory.RemoveItem(source, item_name, count, slot, metadata)
|
||||
if metadata and not slot then
|
||||
local slots = Bridge.Inventory.GetSlotsWithItem(source, item_name, metadata)
|
||||
slot = slots[1] and slots[1].slot or nil
|
||||
if not slot then
|
||||
return 0
|
||||
end
|
||||
end
|
||||
return inventory:RemoveItem(source, item_name, count, metadata, slot) == true and count or 0
|
||||
end
|
||||
|
||||
function Bridge.Inventory.RegisterUsableItem(item_name, callback)
|
||||
return Bridge.Framework.RegisterUsableItem(item_name, function(source, ...)
|
||||
callback(source, normalize(Bridge.Inventory.ResolveUsableItem(...)))
|
||||
end)
|
||||
end
|
||||
@@ -1,88 +0,0 @@
|
||||
if Bridge.Inventory.Name ~= "origen" then
|
||||
return
|
||||
end
|
||||
|
||||
local inventory = exports.origen_inventory
|
||||
|
||||
local function normalize(item)
|
||||
local normalized = Bridge.Inventory.NormalizeItem(item)
|
||||
if not normalized or not normalized.name or normalized.amount < 1 then
|
||||
return nil
|
||||
end
|
||||
return normalized
|
||||
end
|
||||
|
||||
local function get_inventory(source)
|
||||
local player_inventory = inventory:GetInventory(source)
|
||||
return type(player_inventory) == "table" and type(player_inventory.inventory) == "table"
|
||||
and player_inventory.inventory or {}
|
||||
end
|
||||
|
||||
function Bridge.Inventory.GetResourceName()
|
||||
return "origen_inventory"
|
||||
end
|
||||
|
||||
function Bridge.Inventory.GetSlot(source, slot_id)
|
||||
for index, item in pairs(get_inventory(source)) do
|
||||
local normalized = normalize(item)
|
||||
local item_slot = normalized and (normalized.slot or tonumber(index)) or nil
|
||||
if tostring(item_slot) == tostring(slot_id) then
|
||||
normalized.slot = item_slot
|
||||
return normalized
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
function Bridge.Inventory.GetSlotsWithItem(source, item_name, metadata)
|
||||
local matches = {}
|
||||
for index, item in pairs(get_inventory(source)) do
|
||||
local normalized = normalize(item)
|
||||
if normalized and normalized.name == item_name
|
||||
and Bridge.Inventory.MetadataMatches(normalized.metadata, metadata) then
|
||||
normalized.slot = normalized.slot or tonumber(index) or index
|
||||
matches[#matches + 1] = normalized
|
||||
end
|
||||
end
|
||||
return matches
|
||||
end
|
||||
|
||||
function Bridge.Inventory.SetSlotMetadata(source, slot_id, metadata)
|
||||
local slot = Bridge.Inventory.GetSlot(source, slot_id)
|
||||
if not slot then
|
||||
return false
|
||||
end
|
||||
|
||||
local requested_metadata = type(metadata) == "table" and metadata or {}
|
||||
inventory:setMetadata(source, slot.slot, requested_metadata)
|
||||
local updated = Bridge.Inventory.GetSlot(source, slot.slot)
|
||||
return updated and Bridge.Inventory.MetadataMatches(updated.metadata, requested_metadata) or false
|
||||
end
|
||||
|
||||
function Bridge.Inventory.CanCarryItem(source, item_name, count)
|
||||
return inventory:canCarryItem(source, item_name, count) == true
|
||||
end
|
||||
|
||||
function Bridge.Inventory.AddItem(source, item_name, count, slot, metadata)
|
||||
if not Bridge.Inventory.CanCarryItem(source, item_name, count, metadata) then
|
||||
return false
|
||||
end
|
||||
return inventory:addItem(source, item_name, count, metadata or {}, slot, false) == true
|
||||
end
|
||||
|
||||
function Bridge.Inventory.RemoveItem(source, item_name, count, slot, metadata)
|
||||
if metadata and not slot then
|
||||
local slots = Bridge.Inventory.GetSlotsWithItem(source, item_name, metadata)
|
||||
slot = slots[1] and slots[1].slot or nil
|
||||
if not slot then
|
||||
return 0
|
||||
end
|
||||
end
|
||||
return inventory:removeItem(source, item_name, count, nil, slot, false) == true and count or 0
|
||||
end
|
||||
|
||||
function Bridge.Inventory.RegisterUsableItem(item_name, callback)
|
||||
return Bridge.Framework.RegisterUsableItem(item_name, function(source, ...)
|
||||
callback(source, normalize(Bridge.Inventory.ResolveUsableItem(...)))
|
||||
end)
|
||||
end
|
||||
@@ -44,10 +44,8 @@ function Bridge.Inventory.SetSlotMetadata(source, slot_id, metadata)
|
||||
return false
|
||||
end
|
||||
|
||||
local requested_metadata = type(metadata) == "table" and metadata or {}
|
||||
inventory:SetMetadata(source, tonumber(slot_id), requested_metadata)
|
||||
local updated = Bridge.Inventory.GetSlot(source, slot_id)
|
||||
return updated and Bridge.Inventory.MetadataMatches(updated.metadata, requested_metadata) or false
|
||||
inventory:SetMetadata(source, tonumber(slot_id), metadata or {})
|
||||
return true
|
||||
end
|
||||
|
||||
function Bridge.Inventory.CanCarryItem(source, item_name, count, metadata)
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
if Bridge.Inventory.Name ~= "ps" then
|
||||
return
|
||||
end
|
||||
|
||||
if Bridge.Framework.GetName() ~= "qb" then
|
||||
error("[sky_phone] ps-inventory is only supported with QBCore.")
|
||||
end
|
||||
|
||||
local inventory = exports["ps-inventory"]
|
||||
local QBCore = exports["qb-core"]:GetCoreObject()
|
||||
|
||||
local function normalize(item, fallback_slot)
|
||||
local normalized = Bridge.Inventory.NormalizeItem(item, "info", fallback_slot)
|
||||
if not normalized or not normalized.name or normalized.amount < 1 then
|
||||
return nil
|
||||
end
|
||||
return normalized
|
||||
end
|
||||
|
||||
local function get_inventory(source)
|
||||
local player = QBCore.Functions.GetPlayer(tonumber(source))
|
||||
return player and player.PlayerData.items or {}
|
||||
end
|
||||
|
||||
local function restore_slot(source, slot, metadata)
|
||||
local restored = inventory:AddItem(source, slot.name, slot.amount, slot.slot, metadata)
|
||||
if not restored then
|
||||
Bridge.Debug(
|
||||
"error",
|
||||
"[sky_phone] ps-inventory could not restore item '%s' in slot %s after a metadata update failed.",
|
||||
tostring(slot.name),
|
||||
tostring(slot.slot)
|
||||
)
|
||||
end
|
||||
return restored == true
|
||||
end
|
||||
|
||||
function Bridge.Inventory.GetResourceName()
|
||||
return "ps-inventory"
|
||||
end
|
||||
|
||||
function Bridge.Inventory.GetSlot(source, slot_id)
|
||||
local numeric_slot = tonumber(slot_id)
|
||||
return numeric_slot and normalize(inventory:GetItemBySlot(source, numeric_slot), numeric_slot) or nil
|
||||
end
|
||||
|
||||
function Bridge.Inventory.GetSlotsWithItem(source, item_name, metadata)
|
||||
local matches = {}
|
||||
for index, item in pairs(get_inventory(source)) do
|
||||
local normalized = normalize(item, tonumber(index) or index)
|
||||
if normalized and normalized.name == item_name
|
||||
and Bridge.Inventory.MetadataMatches(normalized.metadata, metadata) then
|
||||
normalized.slot = normalized.slot or tonumber(index) or index
|
||||
matches[#matches + 1] = normalized
|
||||
end
|
||||
end
|
||||
return matches
|
||||
end
|
||||
|
||||
function Bridge.Inventory.SetSlotMetadata(source, slot_id, metadata)
|
||||
local slot = Bridge.Inventory.GetSlot(source, slot_id)
|
||||
if not slot or slot.amount < 1 then
|
||||
return false
|
||||
end
|
||||
|
||||
local previous_metadata = slot.metadata
|
||||
local requested_metadata = type(metadata) == "table" and metadata or {}
|
||||
if inventory:RemoveItem(source, slot.name, slot.amount, slot.slot) ~= true then
|
||||
return false
|
||||
end
|
||||
if inventory:AddItem(source, slot.name, slot.amount, slot.slot, requested_metadata) ~= true then
|
||||
restore_slot(source, slot, previous_metadata)
|
||||
return false
|
||||
end
|
||||
|
||||
local updated = Bridge.Inventory.GetSlot(source, slot.slot)
|
||||
if updated and Bridge.Inventory.MetadataMatches(updated.metadata, requested_metadata) then
|
||||
return true
|
||||
end
|
||||
|
||||
inventory:RemoveItem(source, slot.name, slot.amount, slot.slot)
|
||||
restore_slot(source, slot, previous_metadata)
|
||||
return false
|
||||
end
|
||||
|
||||
function Bridge.Inventory.CanCarryItem()
|
||||
return true
|
||||
end
|
||||
|
||||
function Bridge.Inventory.AddItem(source, item_name, count, slot, metadata)
|
||||
return inventory:AddItem(source, item_name, count, slot, metadata or {}) == true
|
||||
end
|
||||
|
||||
function Bridge.Inventory.RemoveItem(source, item_name, count, slot, metadata)
|
||||
if metadata and not slot then
|
||||
local slots = Bridge.Inventory.GetSlotsWithItem(source, item_name, metadata)
|
||||
slot = slots[1] and slots[1].slot or nil
|
||||
if not slot then
|
||||
return 0
|
||||
end
|
||||
end
|
||||
return inventory:RemoveItem(source, item_name, count, slot) == true and count or 0
|
||||
end
|
||||
|
||||
function Bridge.Inventory.RegisterUsableItem(item_name, callback)
|
||||
return Bridge.Framework.RegisterUsableItem(item_name, function(source, ...)
|
||||
callback(source, normalize(Bridge.Inventory.ResolveUsableItem(...)))
|
||||
end)
|
||||
end
|
||||
@@ -1,75 +0,0 @@
|
||||
if Bridge.Inventory.Name ~= "tgiann" then
|
||||
return
|
||||
end
|
||||
|
||||
local inventory = exports["tgiann-inventory"]
|
||||
|
||||
local function normalize(item, fallback_slot)
|
||||
local normalized = Bridge.Inventory.NormalizeItem(item, "info", fallback_slot)
|
||||
if not normalized or not normalized.name or normalized.amount < 1 then
|
||||
return nil
|
||||
end
|
||||
return normalized
|
||||
end
|
||||
|
||||
function Bridge.Inventory.GetResourceName()
|
||||
return "tgiann-inventory"
|
||||
end
|
||||
|
||||
function Bridge.Inventory.GetSlot(source, slot_id)
|
||||
local numeric_slot = tonumber(slot_id)
|
||||
return numeric_slot and normalize(inventory:GetItemBySlot(source, numeric_slot), numeric_slot) or nil
|
||||
end
|
||||
|
||||
function Bridge.Inventory.GetSlotsWithItem(source, item_name, metadata)
|
||||
local matches = {}
|
||||
for index, item in pairs(inventory:GetPlayerItems(source) or {}) do
|
||||
local normalized = normalize(item, tonumber(index) or index)
|
||||
if normalized and normalized.name == item_name
|
||||
and Bridge.Inventory.MetadataMatches(normalized.metadata, metadata) then
|
||||
normalized.slot = normalized.slot or tonumber(index) or index
|
||||
matches[#matches + 1] = normalized
|
||||
end
|
||||
end
|
||||
return matches
|
||||
end
|
||||
|
||||
function Bridge.Inventory.SetSlotMetadata(source, slot_id, metadata)
|
||||
local slot = Bridge.Inventory.GetSlot(source, slot_id)
|
||||
if not slot then
|
||||
return false
|
||||
end
|
||||
|
||||
local requested_metadata = type(metadata) == "table" and metadata or {}
|
||||
inventory:UpdateItemMetadata(source, slot.name, slot.slot, requested_metadata)
|
||||
local updated = Bridge.Inventory.GetSlot(source, slot.slot)
|
||||
return updated and Bridge.Inventory.MetadataMatches(updated.metadata, requested_metadata) or false
|
||||
end
|
||||
|
||||
function Bridge.Inventory.CanCarryItem(source, item_name, count)
|
||||
return inventory:CanCarryItem(source, item_name, count) == true
|
||||
end
|
||||
|
||||
function Bridge.Inventory.AddItem(source, item_name, count, slot, metadata)
|
||||
if not Bridge.Inventory.CanCarryItem(source, item_name, count, metadata) then
|
||||
return false
|
||||
end
|
||||
return inventory:AddItem(source, item_name, count, slot, metadata or {}) == true
|
||||
end
|
||||
|
||||
function Bridge.Inventory.RemoveItem(source, item_name, count, slot, metadata)
|
||||
if metadata and not slot then
|
||||
local slots = Bridge.Inventory.GetSlotsWithItem(source, item_name, metadata)
|
||||
slot = slots[1] and slots[1].slot or nil
|
||||
if not slot then
|
||||
return 0
|
||||
end
|
||||
end
|
||||
return inventory:RemoveItem(source, item_name, count, slot, metadata) == true and count or 0
|
||||
end
|
||||
|
||||
function Bridge.Inventory.RegisterUsableItem(item_name, callback)
|
||||
return Bridge.Framework.RegisterUsableItem(item_name, function(source, ...)
|
||||
callback(source, normalize(Bridge.Inventory.ResolveUsableItem(...)))
|
||||
end)
|
||||
end
|
||||
@@ -98,7 +98,7 @@ end
|
||||
|
||||
local function require_admin(source, operation, maximum)
|
||||
if not Config.AdminPanel.Enabled
|
||||
or not Bridge.Framework.HasPermission(source, "phonepanel")
|
||||
or not Bridge.Framework.HasAdminGroup(source, Config.AdminPanel.AdminGroups)
|
||||
then
|
||||
Bridge.Debug("warn", "[sky_phone] Rejected admin panel access from source %s.", tostring(source))
|
||||
return nil, { success = false, error = "not_authorized" }
|
||||
@@ -121,7 +121,7 @@ local function run_admin_command(command_source)
|
||||
TriggerClientEvent("sky_phone:admin:command-error", player_source, "disabled")
|
||||
return
|
||||
end
|
||||
if not Bridge.Framework.HasPermission(player_source, "phonepanel") then
|
||||
if not Bridge.Framework.HasAdminGroup(player_source, Config.AdminPanel.AdminGroups) then
|
||||
Bridge.Debug(
|
||||
"warn",
|
||||
"[sky_phone] Rejected admin panel command from source %s.",
|
||||
|
||||
@@ -943,7 +943,7 @@ local function run_verify_command(source, arguments)
|
||||
notificationType = notification_type,
|
||||
})
|
||||
end
|
||||
if source ~= 0 and not Bridge.Framework.HasPermission(source, "fliptokverify") then
|
||||
if source ~= 0 and not Bridge.Framework.HasAdminGroup(source, Config.FlipTok.AdminGroups) then
|
||||
send_command_feedback(command_locale.noPermission, "error")
|
||||
Bridge.Debug(
|
||||
"warn",
|
||||
|
||||
@@ -17,21 +17,6 @@ local updated_at
|
||||
local updated_by_name
|
||||
local is_sequence
|
||||
|
||||
local FIXED_CONFIG_PATHS = {
|
||||
CommandPermissions = true,
|
||||
["AdminPanel.AdminGroups"] = true,
|
||||
["TestData.AdminGroups"] = true,
|
||||
["FlipTok.AdminGroups"] = true,
|
||||
["Picstagram.AdminGroups"] = true,
|
||||
}
|
||||
|
||||
if configurator_enabled then
|
||||
print(
|
||||
"[sky_phone] Phone Configurator enabled: file-based settings from config.lua " ..
|
||||
"(except Config.CommandPermissions) and media.lua are disabled; SQL configuration is active."
|
||||
)
|
||||
end
|
||||
|
||||
local CLIENT_CONFIG_KEYS = {
|
||||
AdminPanel = true,
|
||||
Animations = true,
|
||||
@@ -267,7 +252,7 @@ local function upgrade_legacy_map(defaults, saved)
|
||||
return { __skyType = "map", entries = entries }
|
||||
end
|
||||
|
||||
local function merge_values(defaults, saved, path, excluded_paths)
|
||||
local function merge_values(defaults, saved, path)
|
||||
path = path or ""
|
||||
if type(defaults) ~= "table" or type(saved) ~= "table" then
|
||||
return copy_value(saved)
|
||||
@@ -293,12 +278,7 @@ local function merge_values(defaults, saved, path, excluded_paths)
|
||||
key = entry.key,
|
||||
keyType = entry.keyType,
|
||||
value = saved_entry
|
||||
and merge_values(
|
||||
entry.value,
|
||||
saved_entry.value,
|
||||
path .. "." .. tostring(entry.key),
|
||||
excluded_paths
|
||||
)
|
||||
and merge_values(entry.value, saved_entry.value, path .. "." .. tostring(entry.key))
|
||||
or copy_value(entry.value),
|
||||
}
|
||||
included[identity] = true
|
||||
@@ -318,7 +298,7 @@ local function merge_values(defaults, saved, path, excluded_paths)
|
||||
local merged = copy_value(saved)
|
||||
for index, child in ipairs(defaults) do
|
||||
merged[index] = saved[index] ~= nil
|
||||
and merge_values(child, saved[index], path .. "." .. tostring(index), excluded_paths)
|
||||
and merge_values(child, saved[index], path .. "." .. tostring(index))
|
||||
or copy_value(child)
|
||||
end
|
||||
return merged
|
||||
@@ -329,13 +309,11 @@ local function merge_values(defaults, saved, path, excluded_paths)
|
||||
|
||||
local merged = copy_value(defaults)
|
||||
for key, child in pairs(saved) do
|
||||
local child_path = path == "" and tostring(key) or (path .. "." .. tostring(key))
|
||||
if not excluded_paths or not excluded_paths[child_path] then
|
||||
if merged[key] ~= nil then
|
||||
merged[key] = merge_values(merged[key], child, child_path, excluded_paths)
|
||||
else
|
||||
merged[key] = copy_value(child)
|
||||
end
|
||||
if merged[key] ~= nil then
|
||||
local child_path = path == "" and tostring(key) or (path .. "." .. tostring(key))
|
||||
merged[key] = merge_values(merged[key], child, child_path)
|
||||
else
|
||||
merged[key] = copy_value(child)
|
||||
end
|
||||
end
|
||||
return merged
|
||||
@@ -378,12 +356,10 @@ local function apply_runtime_configuration()
|
||||
|
||||
local runtime_config = deserialize_value(stored_config)
|
||||
for key, value in pairs(runtime_config) do
|
||||
if key ~= "CommandPermissions" then
|
||||
if type(Config[key]) == "table" and type(value) == "table" then
|
||||
apply_runtime_table(Config[key], value)
|
||||
else
|
||||
Config[key] = value
|
||||
end
|
||||
if type(Config[key]) == "table" and type(value) == "table" then
|
||||
apply_runtime_table(Config[key], value)
|
||||
else
|
||||
Config[key] = value
|
||||
end
|
||||
end
|
||||
local runtime_media = deserialize_value(stored_media)
|
||||
@@ -1056,12 +1032,7 @@ local function read_stored_row()
|
||||
end
|
||||
|
||||
local function apply_stored_row(row)
|
||||
stored_config = merge_values(
|
||||
default_config,
|
||||
decode_payload(row.config_payload, "config"),
|
||||
"",
|
||||
FIXED_CONFIG_PATHS
|
||||
)
|
||||
stored_config = merge_values(default_config, decode_payload(row.config_payload, "config"), "")
|
||||
stored_media = merge_values(default_media, decode_payload(row.media_payload, "media"), "")
|
||||
revision = tonumber(row.revision) or 1
|
||||
updated_at = row.updated_at
|
||||
@@ -1069,12 +1040,12 @@ local function apply_stored_row(row)
|
||||
end
|
||||
|
||||
default_config = {}
|
||||
for key, value in pairs(ConfigDefaults) do
|
||||
if key ~= "Media" and key ~= "PhoneConfigurator" and key ~= "CommandPermissions" then
|
||||
for key, value in pairs(Config) do
|
||||
if key ~= "Media" and key ~= "PhoneConfigurator" then
|
||||
default_config[key] = serialize_value(value)
|
||||
end
|
||||
end
|
||||
default_media = serialize_value(ConfigDefaults.Media)
|
||||
default_media = serialize_value(Config.Media)
|
||||
|
||||
Bridge.Database.Migrate("sky_phone_configurator", { SkyPhoneConfiguratorSchema })
|
||||
Bridge.Database.Query(([[
|
||||
|
||||
@@ -319,7 +319,7 @@ local function create_activity(recipient_id, actor_id, kind, post_id)
|
||||
end
|
||||
|
||||
local function is_admin(source)
|
||||
return Bridge.Framework.HasPermission(source, "picstagramadmin")
|
||||
return Bridge.Framework.HasAdminGroup(source, Config.Picstagram.AdminGroups)
|
||||
end
|
||||
|
||||
Bridge.Callbacks.Register("sky_phone:picstagram:register", function(source, data)
|
||||
@@ -1464,7 +1464,7 @@ local function run_verify_command(source, args)
|
||||
notificationType = notification_type,
|
||||
})
|
||||
end
|
||||
if source ~= 0 and not Bridge.Framework.HasPermission(source, "picstagramverify") then
|
||||
if source ~= 0 and not Bridge.Framework.HasAdminGroup(source, Config.Picstagram.AdminGroups) then
|
||||
send_command_feedback(command_locale.noPermission, "error")
|
||||
Bridge.Debug(
|
||||
"warn",
|
||||
|
||||
@@ -1045,7 +1045,7 @@ local function run_test_data_command(source)
|
||||
Bridge.Debug("warn", "[sky_phone] The test data command must be run by an in-game player.")
|
||||
return
|
||||
end
|
||||
if Config.TestData.AdminOnly and not Bridge.Framework.HasPermission(source, "phonetestdata") then
|
||||
if Config.TestData.AdminOnly and not Bridge.Framework.HasAdminGroup(source, Config.TestData.AdminGroups) then
|
||||
Bridge.Debug("warn", "[sky_phone] Source %s attempted to run the restricted test data command.", tostring(source))
|
||||
TriggerClientEvent("sky_phone:testdata:feedback", source, false)
|
||||
return
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,64 +0,0 @@
|
||||
Config = {
|
||||
Bridge = {
|
||||
Framework = "qbox",
|
||||
},
|
||||
CommandPermissions = {
|
||||
phonepanel = { "god", "superadmin", "admin" },
|
||||
},
|
||||
}
|
||||
|
||||
Bridge = {
|
||||
Framework = {},
|
||||
}
|
||||
|
||||
function GetResourceState(resource)
|
||||
assert(resource == "qbx_core")
|
||||
return "started"
|
||||
end
|
||||
|
||||
function GetPlayers()
|
||||
return { "1" }
|
||||
end
|
||||
|
||||
local ace_permissions = {}
|
||||
local framework_permission = false
|
||||
|
||||
function IsPlayerAceAllowed(source, permission)
|
||||
assert(source == "1")
|
||||
return ace_permissions[permission] == true
|
||||
end
|
||||
|
||||
exports = {
|
||||
qbx_core = {
|
||||
GetPlayer = function(_, source)
|
||||
if tonumber(source) ~= 1 then
|
||||
return nil
|
||||
end
|
||||
return {
|
||||
PlayerData = {
|
||||
citizenid = "test-citizen",
|
||||
},
|
||||
}
|
||||
end,
|
||||
HasGroup = function(_, source, groups)
|
||||
assert(source == 1)
|
||||
assert(groups == Config.CommandPermissions.phonepanel)
|
||||
return framework_permission
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
dofile("sky_phone/source/bridge/server/framework.lua")
|
||||
dofile("sky_phone/source/bridge/server/frameworks/qbox.lua")
|
||||
|
||||
ace_permissions.admin = true
|
||||
assert(Bridge.Framework.HasPermission(1, "phonepanel"), "Qbox ACE permissions must grant access")
|
||||
|
||||
ace_permissions.admin = false
|
||||
framework_permission = true
|
||||
assert(Bridge.Framework.HasPermission(1, "phonepanel"), "Qbox framework groups must remain supported")
|
||||
|
||||
local success = pcall(Bridge.Framework.HasPermission, 1, "missing")
|
||||
assert(not success, "Missing fixed permission definitions must fail loudly")
|
||||
|
||||
print("framework permission tests passed")
|
||||
@@ -1,9 +1,3 @@
|
||||
local event_handlers = {}
|
||||
|
||||
AddEventHandler = function(event_name, callback)
|
||||
event_handlers[event_name] = callback
|
||||
end
|
||||
|
||||
local function reset_bridge(inventory_name, unique_phones, sim_cards_enabled)
|
||||
Config = {
|
||||
Bridge = {
|
||||
@@ -199,18 +193,11 @@ exports = {
|
||||
}
|
||||
load_inventory_contract("sky_phone/source/bridge/server/inventory/esx.lua")
|
||||
|
||||
assert(Config.Phone.Unique == false)
|
||||
assert(Config.Sim.Enabled == false)
|
||||
assert(Bridge.Inventory.ConfigurationError == nil)
|
||||
|
||||
Config.Phone.Unique = true
|
||||
Config.Sim.Enabled = true
|
||||
event_handlers["sky_phone:configurator:serverUpdated"]()
|
||||
assert(Config.Phone.Unique == false)
|
||||
assert(Config.Sim.Enabled == false)
|
||||
|
||||
assert(Bridge.Inventory.RegisterUsableItem("phone", function()
|
||||
end))
|
||||
local ok, configuration_error = pcall(Bridge.Inventory.RegisterUsableItem, "phone", function()
|
||||
end)
|
||||
assert(not ok)
|
||||
assert(configuration_error:find("Config.Phone.Unique = false", 1, true))
|
||||
assert(configuration_error:find("Config.Sim.Enabled = false", 1, true))
|
||||
|
||||
local manifest_file = assert(io.open("sky_phone/fxmanifest.lua", "rb"))
|
||||
local manifest = manifest_file:read("*a")
|
||||
|
||||
@@ -1,321 +0,0 @@
|
||||
AddEventHandler = function()
|
||||
end
|
||||
|
||||
local function reset_bridge(inventory_name, resource_name, inventory_export, framework_name, extra_exports)
|
||||
Config = {
|
||||
Bridge = { Inventory = inventory_name },
|
||||
Phone = { Unique = true },
|
||||
Sim = { Enabled = true },
|
||||
}
|
||||
|
||||
local usable_items = {}
|
||||
Bridge = {
|
||||
Debug = function()
|
||||
end,
|
||||
Framework = {
|
||||
GetName = function()
|
||||
return framework_name or "qb"
|
||||
end,
|
||||
GetIdentifier = function(source)
|
||||
return ("player:%s"):format(source)
|
||||
end,
|
||||
RegisterUsableItem = function(item_name, callback)
|
||||
usable_items[item_name] = callback
|
||||
return true
|
||||
end,
|
||||
},
|
||||
Inventory = {},
|
||||
}
|
||||
|
||||
exports = extra_exports or {}
|
||||
exports[resource_name] = inventory_export
|
||||
GetResourceState = function(candidate)
|
||||
return candidate == resource_name and "started" or "missing"
|
||||
end
|
||||
|
||||
return usable_items
|
||||
end
|
||||
|
||||
local function load_adapter(adapter_path)
|
||||
dofile("sky_phone/source/bridge/server/inventory.lua")
|
||||
dofile(adapter_path)
|
||||
dofile("sky_phone/source/bridge/server/inventory_contract.lua")
|
||||
end
|
||||
|
||||
local function assert_metadata(metadata, imei)
|
||||
assert(type(metadata) == "table" and metadata.imei == imei)
|
||||
end
|
||||
|
||||
Config = {
|
||||
Bridge = { Inventory = "auto" },
|
||||
Phone = { Unique = true },
|
||||
Sim = { Enabled = true },
|
||||
}
|
||||
Bridge = {
|
||||
Framework = {
|
||||
GetName = function()
|
||||
return "esx"
|
||||
end,
|
||||
},
|
||||
Inventory = {},
|
||||
}
|
||||
GetResourceState = function(resource_name)
|
||||
if resource_name == "ps-inventory" or resource_name == "tgiann-inventory" or resource_name == "ox_inventory" then
|
||||
return "started"
|
||||
end
|
||||
return "missing"
|
||||
end
|
||||
dofile("sky_phone/source/bridge/server/inventory.lua")
|
||||
assert(Bridge.Inventory.Name == "tgiann", "auto detection must follow the shared Sky inventory priority")
|
||||
|
||||
local ak47_items = {
|
||||
[3] = { name = "phone", slot = 3, amount = 1, info = { owner = "kept" } },
|
||||
}
|
||||
local ak47 = {}
|
||||
|
||||
function ak47:GetSlot(identifier, slot)
|
||||
assert(identifier == "player:21")
|
||||
return ak47_items[slot]
|
||||
end
|
||||
|
||||
function ak47:GetSlotsWithItem(identifier, item_name)
|
||||
assert(identifier == "player:21" and item_name == "phone")
|
||||
return ak47_items
|
||||
end
|
||||
|
||||
function ak47:SetItemInfo(identifier, slot, metadata)
|
||||
assert(identifier == "player:21")
|
||||
ak47_items[slot].info = metadata
|
||||
end
|
||||
|
||||
function ak47:CanAddItem()
|
||||
return true
|
||||
end
|
||||
|
||||
function ak47:AddItem()
|
||||
return true
|
||||
end
|
||||
|
||||
function ak47:RemoveItem()
|
||||
return true
|
||||
end
|
||||
|
||||
local ak47_usable = reset_bridge("ak47_inventory", "ak47_inventory", ak47)
|
||||
load_adapter("sky_phone/source/bridge/server/inventory/ak47.lua")
|
||||
assert(Bridge.Inventory.Name == "ak47", "resource-name aliases must resolve to adapter names")
|
||||
assert(Bridge.Inventory.SetSlotMetadata(21, 3, { owner = "kept", imei = "111111111111111" }))
|
||||
assert_metadata(Bridge.Inventory.GetSlot(21, 3).metadata, "111111111111111")
|
||||
assert(Bridge.Inventory.RegisterUsableItem("phone", function(source, item)
|
||||
assert(source == 21 and item.slot == 3)
|
||||
end))
|
||||
ak47_usable.phone(21, "phone", ak47_items[3])
|
||||
|
||||
local jaksam_items = {
|
||||
[5] = { name = "phone", slot = 5, amount = 1, metadata = {} },
|
||||
}
|
||||
local jaksam_usable = {}
|
||||
local jaksam = {}
|
||||
|
||||
function jaksam:getInventory()
|
||||
return { items = jaksam_items }
|
||||
end
|
||||
|
||||
function jaksam:setItemMetadataInSlot(_, slot, metadata)
|
||||
jaksam_items[slot].metadata = metadata
|
||||
return true
|
||||
end
|
||||
|
||||
function jaksam:canCarryItem()
|
||||
return true
|
||||
end
|
||||
|
||||
function jaksam:addItem()
|
||||
return true
|
||||
end
|
||||
|
||||
function jaksam:removeItem()
|
||||
return true
|
||||
end
|
||||
|
||||
function jaksam:registerUsableItem(item_name, callback)
|
||||
jaksam_usable[item_name] = callback
|
||||
end
|
||||
|
||||
reset_bridge("jaksam", "jaksam_inventory", jaksam)
|
||||
load_adapter("sky_phone/source/bridge/server/inventory/jaksam.lua")
|
||||
assert(Bridge.Inventory.SetSlotMetadata(22, 5, { imei = "222222222222222" }))
|
||||
assert_metadata(Bridge.Inventory.GetSlot(22, 5).metadata, "222222222222222")
|
||||
assert(Bridge.Inventory.RegisterUsableItem("phone", function(source, item)
|
||||
assert(source == 22 and item.slot == 5)
|
||||
end))
|
||||
jaksam_usable.phone(22, jaksam_items[5])
|
||||
|
||||
local one_items = {
|
||||
[7] = { name = "phone", slot = 7, count = 1, metadata = {} },
|
||||
}
|
||||
local one = {}
|
||||
|
||||
function one:GetSlot(_, slot)
|
||||
return one_items[slot]
|
||||
end
|
||||
|
||||
function one:SearchInventory()
|
||||
return one_items
|
||||
end
|
||||
|
||||
function one:SetItemMetadata(_, slot, metadata)
|
||||
one_items[slot].metadata = metadata
|
||||
return true
|
||||
end
|
||||
|
||||
function one:CanCarryItem()
|
||||
return true
|
||||
end
|
||||
|
||||
function one:AddItem()
|
||||
return true
|
||||
end
|
||||
|
||||
function one:RemoveItem()
|
||||
return true
|
||||
end
|
||||
|
||||
reset_bridge("one", "one_inventory", one)
|
||||
load_adapter("sky_phone/source/bridge/server/inventory/one.lua")
|
||||
assert(Bridge.Inventory.SetSlotMetadata(23, 7, { imei = "333333333333333" }))
|
||||
assert_metadata(Bridge.Inventory.GetSlotsWithItem(23, "phone")[1].metadata, "333333333333333")
|
||||
|
||||
local origen_items = {
|
||||
[9] = { name = "phone", slot = 9, amount = 1, metadata = {} },
|
||||
}
|
||||
local origen = {}
|
||||
|
||||
function origen:GetInventory()
|
||||
return { inventory = origen_items }
|
||||
end
|
||||
|
||||
function origen:setMetadata(_, slot, metadata)
|
||||
origen_items[slot].metadata = metadata
|
||||
end
|
||||
|
||||
function origen:canCarryItem()
|
||||
return true
|
||||
end
|
||||
|
||||
function origen:addItem()
|
||||
return true
|
||||
end
|
||||
|
||||
function origen:removeItem()
|
||||
return true
|
||||
end
|
||||
|
||||
reset_bridge("origen", "origen_inventory", origen)
|
||||
load_adapter("sky_phone/source/bridge/server/inventory/origen.lua")
|
||||
assert(Bridge.Inventory.SetSlotMetadata(24, 9, { imei = "444444444444444" }))
|
||||
assert_metadata(Bridge.Inventory.GetSlot(24, 9).metadata, "444444444444444")
|
||||
|
||||
local tgiann_items = {
|
||||
[11] = { name = "phone", slot = 11, amount = 1, info = {} },
|
||||
}
|
||||
local tgiann = {}
|
||||
|
||||
function tgiann:GetPlayerItems()
|
||||
return tgiann_items
|
||||
end
|
||||
|
||||
function tgiann:GetItemBySlot(_, slot)
|
||||
return tgiann_items[slot]
|
||||
end
|
||||
|
||||
function tgiann:UpdateItemMetadata(_, _, slot, metadata)
|
||||
tgiann_items[slot].info = metadata
|
||||
end
|
||||
|
||||
function tgiann:CanCarryItem()
|
||||
return true
|
||||
end
|
||||
|
||||
function tgiann:AddItem()
|
||||
return true
|
||||
end
|
||||
|
||||
function tgiann:RemoveItem()
|
||||
return true
|
||||
end
|
||||
|
||||
reset_bridge("tgiann", "tgiann-inventory", tgiann)
|
||||
load_adapter("sky_phone/source/bridge/server/inventory/tgiann.lua")
|
||||
assert(Bridge.Inventory.SetSlotMetadata(25, 11, { imei = "555555555555555" }))
|
||||
assert_metadata(Bridge.Inventory.GetSlot(25, 11).metadata, "555555555555555")
|
||||
|
||||
local qb_items = {
|
||||
[13] = { name = "phone", slot = 13, amount = 1, info = { owner = "kept" } },
|
||||
}
|
||||
local qb_player = { PlayerData = { items = qb_items } }
|
||||
local qb_core = {
|
||||
Functions = {
|
||||
GetPlayer = function()
|
||||
return qb_player
|
||||
end,
|
||||
},
|
||||
}
|
||||
local qb_export = {
|
||||
GetCoreObject = function()
|
||||
return qb_core
|
||||
end,
|
||||
}
|
||||
|
||||
local jpr_drop_next_metadata = true
|
||||
local jpr = {}
|
||||
|
||||
function jpr:GetItemBySlot(_, slot)
|
||||
return qb_items[slot]
|
||||
end
|
||||
|
||||
function jpr:RemoveItem(_, _, _, slot)
|
||||
qb_items[slot] = nil
|
||||
return true
|
||||
end
|
||||
|
||||
function jpr:AddItem(_, item_name, amount, slot, metadata)
|
||||
qb_items[slot] = {
|
||||
name = item_name,
|
||||
slot = slot,
|
||||
amount = amount,
|
||||
info = jpr_drop_next_metadata and {} or metadata,
|
||||
}
|
||||
jpr_drop_next_metadata = false
|
||||
return true
|
||||
end
|
||||
|
||||
reset_bridge("jpr", "jpr-inventory", jpr, "qb", { ["qb-core"] = qb_export })
|
||||
load_adapter("sky_phone/source/bridge/server/inventory/jpr.lua")
|
||||
assert(not Bridge.Inventory.SetSlotMetadata(26, 13, { owner = "kept", imei = "666666666666666" }))
|
||||
assert(qb_items[13] and qb_items[13].info.owner == "kept", "jpr metadata failure must restore the original item")
|
||||
assert(Bridge.Inventory.SetSlotMetadata(26, 13, { owner = "kept", imei = "666666666666666" }))
|
||||
assert_metadata(Bridge.Inventory.GetSlot(26, 13).metadata, "666666666666666")
|
||||
|
||||
qb_items[15] = { name = "phone", slot = 15, amount = 1, info = {} }
|
||||
local ps = {}
|
||||
|
||||
function ps:GetItemBySlot(_, slot)
|
||||
return qb_items[slot]
|
||||
end
|
||||
|
||||
function ps:RemoveItem(_, _, _, slot)
|
||||
qb_items[slot] = nil
|
||||
return true
|
||||
end
|
||||
|
||||
function ps:AddItem(_, item_name, amount, slot, metadata)
|
||||
qb_items[slot] = { name = item_name, slot = slot, amount = amount, info = metadata }
|
||||
return true
|
||||
end
|
||||
|
||||
reset_bridge("ps", "ps-inventory", ps, "qb", { ["qb-core"] = qb_export })
|
||||
load_adapter("sky_phone/source/bridge/server/inventory/ps.lua")
|
||||
assert(Bridge.Inventory.SetSlotMetadata(27, 15, { imei = "777777777777777" }))
|
||||
assert_metadata(Bridge.Inventory.GetSlot(27, 15).metadata, "777777777777777")
|
||||
|
||||
print("extended inventory bridge regression checks passed")
|
||||
@@ -25,7 +25,7 @@ Bridge = {
|
||||
Debug = function()
|
||||
end,
|
||||
Framework = {
|
||||
HasPermission = function()
|
||||
HasAdminGroup = function()
|
||||
return true
|
||||
end,
|
||||
},
|
||||
@@ -42,6 +42,7 @@ Bridge = {
|
||||
|
||||
Config = {
|
||||
AdminPanel = {
|
||||
AdminGroups = { "admin" },
|
||||
Command = "phoneadmin",
|
||||
Enabled = true,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user