Start

Item setup

The inventory items FX Phone uses and the item definition for each supported inventory.

#Items

The images are in fx-phone/setup/items/.

Item Image Needed
phone phone.png Yes, unless Config.Item = false (then everyone has a phone)
sim_card sim_card.png With Config.Sim.Enabled = true, the shipped value
ghost_sim ghost_sim.png Only with Config.SecondSim.Enabled = true. The name is Config.SecondSim.Item
powerbank powerbank.png Only if you want power banks. The name is Config.Battery.PowerBankItem; nil turns them off
  1. Copy the images into your inventory's image folder.
  2. Paste the block for your inventory into its item file.
  3. Restart the inventory, or the server.

The image file name must match the item's image (or, for ox_inventory, the item name).

Inventory Item file Image folder
ox_inventory (QBCore, Qbox, ESX) ox_inventory/data/items.lua ox_inventory/web/images/, or the folder set by inventory:imagepath
qb-inventory, ps-inventory, lj-inventory qb-core/shared/items.lua <inventory>/html/images/
qs-inventory qs-inventory/shared/items.lua qs-inventory/html/images/

#How the phone item behaves

  • Without the item the phone does not open. The player gets a short notice instead.
  • Without the item the player does not hear ringtones or notification sounds, and confirmation requests from scripts answer false. Calls and messages still arrive and are waiting when the phone is back.
  • Losing the item (dropping it, handing it over, having it taken) closes the phone at once.
  • Using the item from the inventory opens the phone, the same as the open key.
  • One item per player is enough. The phone belongs to the character, not to the item; several phone items do not give several phones.

#ox_inventory

lua['phone'] = {
    label = 'Phone',
    weight = 190,
    stack = false,
    consume = 0,
    client = {
        event = 'fx-phone:client:openPhone',
    },
},

['sim_card'] = {
    label = 'SIM Card',
    weight = 10,
    stack = false,
    close = true,
    description = 'Insert it from Settings > SIM.',
    server = {
        export = 'fx-phone.useSimCard',
    },
},

['ghost_sim'] = {
    label = 'GhostNet SIM',
    weight = 10,
    stack = true,
    close = true,
    description = 'An off-the-books line. Insert it from Settings > SIM; it works for 3 days from then.',
    server = {
        export = 'fx-phone.useSimCard',
    },
},

['powerbank'] = {
    label = 'Power Bank',
    weight = 250,
    stack = true,
    close = true,
    description = 'Charges your phone anywhere. Single use.',
    server = {
        export = 'fx-phone.useSimCard',
    },
},

The server.export = 'fx-phone.useSimCard' line is what lets the phone see the item being used. All three items use the same export; it looks up the handler by item name.

#qb-inventory, ps-inventory, lj-inventory

QBCore already ships a phone item. Add only what is missing:

luaphone = {
    name = 'phone', label = 'Phone', weight = 700, type = 'item', image = 'phone.png',
    unique = true, useable = true, shouldClose = true, description = 'A smartphone',
},

sim_card = {
    name = 'sim_card', label = 'SIM Card', weight = 10, type = 'item', image = 'sim_card.png',
    unique = true, useable = true, shouldClose = true, description = 'Insert it from Settings > SIM.',
},

ghost_sim = {
    name = 'ghost_sim', label = 'GhostNet SIM', weight = 10, type = 'item', image = 'ghost_sim.png',
    unique = true, useable = true, shouldClose = true, description = 'An off-the-books line. Insert it from Settings > SIM; it works for 3 days from then.',
},

powerbank = {
    name = 'powerbank', label = 'Power Bank', weight = 250, type = 'item', image = 'powerbank.png',
    unique = false, useable = true, shouldClose = true, description = 'Charges your phone anywhere. Single use.',
},

On QBCore inventories FX Phone registers these as usable items itself.

#qs-inventory

lua['phone'] = {
    ['name'] = 'phone', ['label'] = 'Phone', ['weight'] = 700, ['type'] = 'item', ['image'] = 'phone.png',
    ['unique'] = true, ['useable'] = true, ['shouldClose'] = true, ['description'] = 'A smartphone',
},

['sim_card'] = {
    ['name'] = 'sim_card', ['label'] = 'SIM Card', ['weight'] = 10, ['type'] = 'item', ['image'] = 'sim_card.png',
    ['unique'] = true, ['useable'] = true, ['shouldClose'] = true, ['description'] = 'Insert it from Settings > SIM.',
},

FX Phone reads qs-inventory through QBCore player data, as it does qb-inventory.

#What using each item does

Item Effect
phone Opens the phone
sim_card, ghost_sim Opens Settings > SIM with that card ready to go into SIM 1 or SIM 2. The card can also be picked there from an empty slot
powerbank Charges the phone for Config.Battery.PowerBankMinutes minutes. The item is used up

FX Phone does not sell the power bank itself; sell it in any shop of yours.

Both cards come back. A sim_card taken out of the phone returns to the inventory with its number on it. A ghost_sim taken out with time left returns with its line id and end date on it and can be handed on (Config.SecondSim.Returnable, default true); an expired one is thrown away.

Because a used card carries its own data, ghost_sim is unique = true in the QBCore block: a non-unique item would be merged into a stack of new cards and lose that data. On ox_inventory, cards with different data do not stack, so stack = true is fine there.

Physical SIM cards need ox_inventory or a QBCore / Qbox player inventory on the server. Without either, only eSIMs are available.

#Any other inventory

  • ESX without ox_inventory: install ox_inventory, or set Config.Item = false.
  • Another inventory: set Config.Item = false, or connect it as shown on Inventory.

More about SIM cards: SIM and Owned shops. More about power banks: Battery.