Skip to content

[Discussion]: Export driven developer API in monitor script #442

@TasoOneAsia

Description

@TasoOneAsia

Scope

Developer API

Feature Description

Summary
Provide a public API for third party resources to trigger methods or fetch useful data within txAdmin.

API Scope
This export API should be limited mainly to txAdmin Game Script related functionality defined in the scripts folder. No relaying of data should be done through game scripts as a means of communicating with the txAdmin backend.

Possible Concerns

  • What limitations should we establish for exposing internal methods & data?
  • Should we tie txAdmin player state directly into a state bag, or should we prevent undefined behavior by not allowing for this data to be directly mutated by a user?

This API's structure and scope is not final and is open to feedback and comments from contributors and users.

Use Case

We encourage you share any use cases for exports that you may find useful

Additional Info

Proposed Examples:

--- An export returning whether a player has a given txAdmin permission
--- if the player has the 'all_permissions' flag, this function will always
--- return true.
--- @param playerSrc number|string The target player's server ID
--- @param permission string The permission to check against
local function doesPlayerHavePermission(playerSrc, permission)
  return PlayerHasTxPermission(playerSrc, permission)
end
exports('doesPlayerHavePermission', doesPlayerHavePermission)

--- Add an announcement using the in-game menu announcement
--- alerts.
--- @param msg string The announcement message to display
local function addAnnouncement(msg)
  TriggerClientEvent('txAdmin:receiveAnnounce', -1, msg)
end
exports('addAnnouncement', addAnnouncement)

See the following somewhat related issues #179, #436

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions