Refactor unique-phones SIM tray and active-phone reachability - #82
Open
Im-Kayun wants to merge 5 commits into
Open
Refactor unique-phones SIM tray and active-phone reachability#82Im-Kayun wants to merge 5 commits into
Im-Kayun wants to merge 5 commits into
Conversation
Replace ox nested containers (use opened the tray) with per-device stashes so using a phone opens the UI and an inventory SIM Tray button swaps cards. Persist last-opened device in phone_player_equipment, add getDevice/setPhoneDevice metadata helpers, and wire ox client/server exports for phone and SIM activation.
Pocketed SIMs stay unreachable and silent until equipped (ng-phone style), while stored data still catches up on next open.
Keeps reference copy-paste defs out of configs and leaves room for future docs.
Restore Enabled/UseContainers and phone_black so local test toggles are not shipped.
Im-Kayun
force-pushed
the
refactor/unique-phones-sim-tray
branch
from
July 22, 2026 16:39
90067e2 to
2a01951
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hardens unique phones so the phone you open is the only live line, and with ox tray mode using the phone opens the UI instead of the SIM container.
Root cause / design. With
UseContainers = true, ox_inventory treatsmetadata.containeras a nested inventory and intercepts USE before sd-phone exports, so players opened the SIM tray instead of the phone. The "active" phone also lived only in memory (prefsin session), so reconnects/restarts forgot which device you were acting as. Live traffic (calls, SMS banners, notifications) could still reach pocketed SIMs viagetAnySourceByIdentifier/ pocket-buzz banners.(a) SIM tray UX (ox only). Drop nested phone containers. Each device gets a 1-slot stash
sd_phone_sim_<deviceId>. USE always runssd-phone.usePhone(opens UI + marks active). Inventory button "SIM Tray" callsopenSimTray. Legacy nested containers migrate onto the stash on resolve/tray open. Item defs live indocs/ox_inventory_items.lua— SECTION A (tray button) whenUseContainers = true, SECTION B when false; ox cannot toggle buttons at runtime. Blanksim_cardwires client/server exports so first USE activates a number, then tray-insert (A) or use-again install (B).(b) Active device persistence. Last-opened device is stored in
phone_player_equipmentand restored on session resolve (session.setActive/ensurePref). Phone metadata helpersgetDevice/setPhoneDevice(deviceId,deviceOwner) back device identity so resolve no longer hits nil on missing getters.(c) Active-phone-only reachability. Dial/payphone/LB-compat resolve with
getSourceByIdentifieronly.getAnySourceByIdentifieris an alias of the active resolver under unique phones. Incoming no longer auto-switches to the dialed pocketed phone.notifications.notifyCidis silent unless that identity is active (pocket buzz removed). Messages still persist for pocketed identities but skip live thread push / banner until that phone is equipped. README documents the new behaviour.(d) Docs + defaults.
configs/ox_inventory_items.lua→docs/(reference only, not loaded). Upstream defaults stayEnabled = false/UseContainers = falseso opt-in servers are unchanged until they flip the flags and copy the matching item defs.Type of Change
Related Issues
n/a (unique-phones tray + active-phone reachability)
Testing
Enable unique phones +
UseContainers = truewith SECTION A ox defs: USE phone opens UI; SIM Tray opens stash; blank SIM activates then inserts; eject by dragging out.Metadata mode (
UseContainers = false, SECTION B): usesim_cardto install; eject from Settings → SIM & Backup.Two phones on one character: call/SMS/notif to the pocketed number is unavailable/silent; open that phone → traffic works; stored SMS catch up on open.
Restart / relog: last-opened device remains active.
Defaults on a fresh config remain off (no behaviour change for servers that never enable unique phones).
Tested locally
Tested with latest sd-phone
Tested with latest ox_lib
Tested with latest ox_inventory
Multiplayer tested
Breaking Changes
Behavioural (only when unique phones are enabled): pocketed numbers are no longer reachable for live calls/SMS banners/notifications — previously any carried SIM rang/buzzed. Data is still stored and surfaces when that phone is opened. Servers that relied on multi-phone simultaneous reachability need to treat the last-opened phone as the only live line.
ox item defs: tray mode requires SECTION A (SIM Tray button) in ox_inventory; nested
containermetadata on phones is obsolete and migrates on first resolve. Copy fromdocs/ox_inventory_items.lua.No schema change for servers with unique phones already off. With unique phones on,
phone_player_equipmentis created/used for active-device persistence.Checklist