API

All exports and events that script provides for developers.

Example DoorObject

local door: DoorObject = {
    id = 1,
    label = 'Hall 1',
    group = 'Mission Row PD',
    model = 'v_ilev_ph_door01',
    coords = vector4(0.0, 0.0, 0.0, 0.0),
    distance = 2.0,
    defaultState = 1,
    soundFiles = {
        lock = 'rcore_basic_lock',
        unlock = 'rcore_basic_unlock'
    },
    hash = ...
    access = {
        pin = {
            enabled = true,
            type = 'pin',
            name = '123456',
        }

        ...
    },
    associated = 2,
    automaticRate = 10.0,
    createdBy = 'admin'

    -- server side only
    currentState = 1
}

Exports

Client

openDoorsManagement

  • Open doors management UI with doors

  • Return:

    • : void

exports.rcore_doorlock:openDoorsManagement()

refreshBusinessBlips

  • Refreshes business blips on map, when parameter is nil, blips are wiped

  • Parameters:

    • businessName: string | nil

  • Return:

    • : void

exports.rcore_doorlock:refreshBusinessBlips()

exports.rcore_doorlock:refreshBusinessBlips('locksmith')

getDoorsCreatedBy

  • Get all doors by creator (business / admin)

  • Parameters:

    • createdBy: string

  • Return:

    • doors: table<string, DoorObject>

local createdBy = 'admin'
-- local grade, createdBy = exports.rcore_doorlock:getGrade()

local doors = exports.rcore_doorlock:getDoorsCreatedBy(createdBy)

openCrafting

  • Opens crafting for associated business (still restricted if player is not in correct business)

  • Parameters:

    • businessName: string

  • Return:

    • : void

exports.rcore_doorlock:openCrafting('locksmith')

openBossActions

  • Opens boss actions for associated business (still restricted if player is not in correct business and is not boss)

  • Parameters:

    • businessName: string

  • Return:

    • : void

exports.rcore_doorlock:openBossActions('locksmith')

getBusinessGrade

  • Get player's grade info in business and busienss name

  • Return:

    • grade: table<string, any> | nil

    • businessName: string | nil

local grade, businessName = exports.rcore_doorlock:getBusinessGrade()
if grade == nil then return end

local jobNum = grade.grade
local label = grade.label
local name = grade.name
local permissions = grade.permissions

hasPlayerBusinessPermision

  • Get if player has specific permission in his grade

  • Parameters:

    • permission: Business.Permissions (string)

  • Return:

    • result: boolean

local result = exports.rcore_doorlock:hasPlayerBusinessPermision(Business.Permissions.CREATE_DOOR)

startBusinessPreview

  • Starts business preview cinematic with camera

  • Return:

    • : void

exports.rcore_doorlock:startBusinessPreview()

changeDoorStateLocalNotPersist

  • Change door state locally on client, but won't persist. If anyone interact with doors, doors will be locked / unlocked depends on new state and local state will be overrided

  • Parameters:

    • doorId: string

    • state: number - 0 > unlocked, 1 > locked

  • Return:

    • success: boolean

local doorId = 200
local state = 1

local success = exports.rcore_doorlock:changeDoorStateLocalNotPersist(doorId, state)
if success then
    print('Doors succesfully locally locked')
end

getObjectsByDoorId

  • Get objects assigned to door

  • Parameters:

    • doorId: string

  • Return:

    • objects: table<string, table>

local doorId = 200
local doorObjects = exports.rcore_doorlock:getObjectsByDoorId(doorId)

Server

refreshBusinessBlips

  • Refreshes business blips on map for player

  • Parameters:

    • playerId: string

  • Return:

    • : void

exports.rcore_doorlock:refreshBusinessBlips(playerId)

getPlayerBusiness

  • Get player's business

  • Parameters:

    • playerId: string

  • Return:

    • businessName: string | nil

    • business: table<string, any> | nil

    • job: table<string, string | number> | nil

local businessName, business, job = exports.rcore_doorlock:getPlayerBusiness(playerId)

hasPlayerBusinessPermision

  • Get if player has specific permission in business

  • Parameters:

    • playerId: string

    • permission: Business.Permissions (string)

  • Return:

    • result: boolean

    • businessName: string | nil

    • business: table<string, any> | nil

    • job: table<string, string | number> | nil

local playerId = source
local result, businessName, business, job = exports.rcore_doorlock:hasPlayerBusinessPermision(playerId, Business.Permissions.CREATE_DOOR)

addDoor

  • Add door into database and load it on every client

  • Parameters:

    • door: DoorObject

    • client: string | nil - if used, Framework.isAdmin check will be runned

  • Return:

    • success: boolean

local door = { ... }
local success = exports.rcore_doorlock:addDoor(door)

local playerId = source
success = exports.rcore_doorlock:addDoor(door, playerId)

addObject

  • Add object into database and load it on every client

  • Parameters:

    • object: table

    • client: string | nil - if used, Framework.isAdmin check will be runned

  • Return:

    • success: boolean

local object = { ... }
local success = exports.rcore_doorlock:addObject(door)

local playerId = source
success = exports.rcore_doorlock:addObject(door, playerId)

changeDoorState

  • Change door state, specified state persist and will be changed on all clients

  • Parameters:

    • doorId: string

    • state: number - 0 > unlocked, 1 > locked

  • Return:

    • success: boolean

local doorId = 200
local state = 1

local success = exports.rcore_doorlock:changeDoorState(doorId, state)
if success then
    print('Door', doorId, 'is locked for all players')
end

setPresetLoaded

  • Set preset loaded toggle into KVP

  • Parameters:

    • preset: string

    • loaded: boolean

  • Return:

    • : void

local preset = 'assets/presets/main.json'
exports.rcore_doorlock:setPresetLoaded(preset, false)

isPresetLoaded

  • Is preset loaded

  • Parameters:

    • preset: string

  • Return:

    • result: boolean

local preset = 'assets/presets/main.json'
local result = exports.rcore_doorlock:isPresetLoaded(preset)
if result then
    print('Preset is already loaded')
end

getSqlDoors

  • Get all doors synchronously from database (executes sql queries)

  • Return:

    • doors: table<string, DoorObject>

local doors = exports.rcore_doorlock:getSqlDoors()

getSqlObjects

  • Get all objects synchronously from database (executes sql queries)

  • Return:

    • objects: table<string, table>

local objects = exports.rcore_doorlock:getSqlObjects()

Shared

getBridgeInfo

  • Get informations about bridge

  • Return:

    • bridge: table<string, string | boolean

local bridge = exports.rcore_doorlock:getBridge()
print(bridge.isLoaded)

print(bridge.Framework)
print(bridge.Inventory)
...

translate

  • Get locale translation

  • Parameters:

    • localeKey: string,

    • ...: vararg<any>

  • Return:

    • locale: string

local playerId = 1
local permission = Business.Permissions.CREATE_ITEM
local text = exports.rcore_doorlock:translate('NO_PERMISSION', playerId, permission)
print(text)

-- Output: Player 1 has not permission for create_item!

getBusinesses

  • Get all businesses from config.business.lua

  • Return:

    • businesses: table<string, any>

local businesses = exports.rcore_doorlock:getBusinesses()

getLoadedDoors

  • Get all loaded doors

  • Return:

    • doors: table<string, DoorObject>

local doors = exports.rcore_doorlock:getLoadedDoors()

getLoadedObjects

  • Get all loaded objects

  • Return:

    • objects: table<string, table>

local objects = exports.rcore_doorlock:getLoadedObjects()

Last updated