For the complete documentation index, see llms.txt. This page is also available as Markdown.

🔋Battery System

This page describes how to enable and configure battery system

Installation

1

Enable battery system in config

  1. Open configs/Config.lua

  2. Set Config.BatterySystem = true

2

Add required items

Next step is to add 3 new default items powerbank_small, powerbank, powerbank_pro in your inventory.

  1. Go to your qb-core folder.

  2. Open the file: /shared/items.lua

  3. Scroll to the end of the file.

  4. Before the closing } add the following code:

["powerbank_small"] = { name = 'powerbank_small', label = 'Small Powerbank', weight = 700, type = 'item', image = 'powerbank_small.png',  unique = true, useable = false, shouldClose = false, description = 'A compact powerbank, fits right in your pocket.' },
["powerbank"]       = { name = 'powerbank',       label = 'Powerbank',       weight = 700, type = 'item', image = 'powerbank.png',        unique = true, useable = false, shouldClose = false, description = 'A reliable powerbank to keep your devices charged on the go.' },
["powerbank_pro"]   = { name = 'powerbank_pro',   label = 'Powerbank Pro',   weight = 700, type = 'item', image = 'powerbank_pro.png',    unique = true, useable = false, shouldClose = false, description = 'High-capacity powerbank for those who never want to run out of juice.' },
  1. Run this SQL query in your database:

INSERT IGNORE INTO `items` (`name`, `label`, `weight`, `rare`, `can_remove`) VALUES
        ('powerbank_small', 'Small Powerbank', 1, 0, 1),
        ('powerbank', 'Normal Powerbank', 1, 0, 1),
        ('powerbank_pro', 'Powerbank Pro', 1, 0, 1),
        ('powerbank_small_discharged', 'Discharged Small Powerbank', 1, 0, 1),
        ('powerbank_discharged', 'Discharged Normal Powerbank', 1, 0, 1),
        ('powerbank_pro_discharged', 'Discharged Powerbank Pro', 1, 0, 1);
  1. Go to your ox_inventory folder.

  2. open the file: /data/items.lua

  3. Scroll to the end of the file.

  4. Before the closing } add the following code:

['powerbank_small'] = {
    label = 'Small Powerbank',
    weight = 150,
    client = {
        image = 'powerbank_small.png',
    },
    server = {
        export = '17mov_Phone.powerbank_small'
    },
    consume = 0,
    stack = false
},

['powerbank'] = {
    label = 'Powerbank',
    weight = 150,
    client = {
        image = 'powerbank.png',
    },
    server = {
        export = '17mov_Phone.powerbank'
    },
    consume = 0,
    stack = false
},

['powerbank_pro'] = {
    label = 'Powerbank Pro',
    weight = 150,
    client = {
        image = 'powerbank_pro.png',
    },
    server = {
        export = '17mov_Phone.powerbank_pro'
    },
    consume = 0,
    stack = false
},
3

Installing images into your inventory system

Inside the resource you will find: installation/images This folder contains example icons meant for integration with the inventory system used on your server (e.g., qb-inventory, ox_inventory, etc.).

Steps:

  1. Copy all powerbank images from the installation/images folder.

  2. Paste them into the assets folder of your inventory system, for example:

qb-inventory
ox_inventory
ps-inventory
esx_inventory

/html/images

/web/images

/html/images

/html/img/items

After these steps, battery system should be working. You can configure everything related to Battery System inside configs/Config.lua, including custom powerbanks, battery lifespan and more.

Exports

Server

ToggleCharging

Toggles charging phone with active number

params:

Argument
Type
Optional
Explanation

src

number

❌

The player's server ID (source).

state

boolean

❌

Set true to start chargingg, false to stop charging

chargeValue

number

✅

How fast phone will be charged (default 10000)

Last updated