Exports

In this page you will find some exports and events you can use from your external scripts to interact with av_laptop.

postMessage(name,data)

Use this export to send a NUI message to your custom APP, requires to use the hook useNuiEvent() as listener.

params:

  • name:string The event name.

  • data:any Data to receive

-- EXAMPLE in the lua side
exports['av_laptop']:postMessage("updateCrypto", 99)
// EXAMPLE in the Typescript side of app
useNuiEvent('updateCrypto', (amount:number) => {
    console.log(amount)
})

openApp(name,tablet)

Open an APP directly without using the laptop item nor UI.

App name can be found in your config.lua > Config.App table > name

params:

  • name:string The app name

  • tablet:boolean Enable the tablet prop and animation

returns:

  • result:boolean

local appName = "business" -- or "cupcake" or "boosting", etc
local opened = exports['av_laptop']:openApp(appName,true)
print(opened)

showLaptop(tablet,itemCheck)

Use this export to open the laptop and set it as background while you run some other UI in front.

params:

  • tablet? boolean: Enable the tablet prop and animation.

  • itemCheck? boolean: It will check if the player has the laptop item in their inventory and use the wallpaper for the interface. If the player does not have the item, it will return false and cancel the animation.

-- Example using bl_ui minigames:
RegisterCommand("minigame", function()
    local hasLaptop = exports['av_laptop']:showLaptop(true,true)
    if hasLaptop then
        local success = exports.bl_ui:DigitDazzle(3, {
            length = 4,
            duration = 5000,
        })
        exports['av_laptop']:hideLaptop()
    else
        print("Player doesn't have laptop item")
    end
end)

Note: Your minigame UI should have a z-index of 100 otherwise it will be hidden behind laptop UI.

hideLaptop()

Use it to close laptop when opened using showLaptop() export.

exports['av_laptop']:hideLaptop()

getSerial()

Use this export to retrieve the current laptop serial.

params:

  • none

returns:

  • string or false

local serial = exports['av_laptop']:getSerial()
print(serial) -- false or string

Wifi()

Use this export to get the current WiFi network the laptop is connected to.

returns:

  • string or nil

local WiFi = exports['av_laptop']:WiFi()
print(WiFi)

Last updated