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

βš™οΈIntegration

Information about how to integrate our tablet system with your server's resources.

πŸ“‚ Tablet opening

1️⃣ Opening with an item

The resource configuration is pre-set for the tablet to open with an item by default. To make this feature work, you also need to create an item in your inventory with the ID of app_tablet.

Add this section to ox_inventory/data/items.lua

['app_tablet'] = {
    label = 'Tablet',
    weight = 0,
    description = 'You can install different applications onto this.',
    stack = false,
    client = {
        export = 'rahe-tablet.tablet'
    }
}

Add the following image file as ox_inventory/web/images/app_tablet.png

https://media.rahe.dev/img/app_tablet.png

Add the following line to qb-core/shared/items.lua

['app_tablet'] = { ['name'] = 'app_tablet', ['label'] = 'Tablet', ['weight'] = 1000, ['type'] = 'item', ['image'] = 'app_tablet.png', ['unique'] = true, ['useable'] = true, ['shouldClose'] = true, ['combinable'] = nil, ['description'] = 'You can install different applications onto this.' },

Add the following image file as qb-inventory/html/images/app_tablet.png

https://media.rahe.dev/img/app_tablet.png

Create the item app_tablet in your inventory system and make it usable.

If you are using qs-inventory or core_inventory, you don't have to do anything extra.

If you are using any other inventory system, then on item use trigger:

exports['rahe-tablet']:tablet()

If you didn't name the item app_tablet, adjust the itemId in resource config accordingly.


2️⃣ Opening with a command

If you don't wish the tablet to be an item, then in resource/config/shared.lua, change the openMethod option from inventory to command. Use the command /tablet in-game to open the application tablet.

πŸ“‘ Enabling application installs

By default, application installations are disabled, meaning all applications are visible on the tablet. However, you have the option to enable them:

  • Navigate to /resource/config/shared.lua and set installEnabled to true.

  • In config/client.lua set requireInstall to true for applications you want to require installation.

If you wish to configure options for RAHE resources, then head to /resource/client/integrations.lua. In the default resource, all of our applications have requireInstall set to true, meaning they will need to be installed if you enable installations.

πŸ’Ώ Application installation

To install applications, you need to trigger the following server-side export:

exports['rahe-tablet']:installApplication(playerId, appId, slot)

This export will mark the application as installed, indicated by a progress circle. For example, to install our boosting application for player ID 1, who has a tablet in his inventory slot 4, you would use:

exports['rahe-tablet']:installApplication(1, 'rahe-boosting', 4)

You might wonder about the purpose of the slot variable. This variable is necessary only when you've configured the appInstallTarget in /resource/config/shared.lua to metadata (which is only applicable when using ox_inventory!). In this case, the slot variable is used retrieve the item in that specific slot and save the installed application ID into the metadata of that item.

Code example for ox_inventory

To install the application rahe-racing from a USB stick, follow these steps:

  1. Add the installation USB item to ox_inventory/data/items.lua:

  1. Add the usb_install export to a client-side file in rahe-tablet, such as the end of /resource/client/integrations.lua:

  1. Create the server-side event to handle installation. Register the event as follows at the end of /resource/server/installation.lua:

(it's in the same file as the export function, so we are using the installApplication function directly)

Last updated