🔋Battery System
This page describes how to enable and configure battery system
Installation
Add required items
Next step is to add 3 new default items powerbank_small, powerbank, powerbank_pro in your inventory.
Go to your qb-core folder.
Open the file: /shared/items.lua
Scroll to the end of the file.
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.' },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);Go to your ox_inventory folder.
open the file:
/data/items.luaScroll to the end of the file.
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
},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:
Copy all powerbank images from the
installation/imagesfolder.Paste them into the assets folder of your inventory system, for example:
/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:
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