Skip to content

Developer Exports

Programmatically interact with MonoAdmin from your own FiveM resources for anti-cheat, custom scripts, and automated moderation.

MonoAdmin provides exports that allow you to programmatically interact with the admin system from your own FiveM resources. This enables integration with anti-cheat systems, custom scripts, and automated moderation tools.

  • MonoAdmin resource must be running and connected to the cloud
  • Players must be online and tracked by MonoAdmin before punishments can be issued

Create a punishment for a player programmatically. Punishments created via this export are logged with fivem_server as the actor type in audit logs.

exports['monoadmin']:CreatePunishment(data, callback)
ParameterTypeRequiredDescription
datatablePunishment configuration (see below)
callbackfunctionCalled when punishment is created or fails
FieldTypeRequiredDescription
sourcenumberServer ID of the player to punish
punishment_typestringType of punishment (see valid values below)
reasonstringReason for the punishment
duration_minutesnumberDuration in minutes. nil = permanent
enforcement_modestring'sticky' (default) or 'non_sticky'
targeted_identifierstableRequired for non_sticky mode
kick_if_onlinebooleanKick player immediately if issuing a ban
community_service_totalnumberTotal hours for community_service type
TypeDescription
banBan the player from the server
warnIssue a warning to the player
kickKick the player from the server
community_serviceAssign community service hours
ModeDescription
stickyPunishment applies to all player identifiers (default)
non_stickyPunishment only applies to specified identifiers

The callback function receives three parameters:

function(success, punishmentId, error)
ParameterTypeDescription
successbooleantrue if punishment was created successfully
punishmentIdnumberThe ID of the created punishment (only if successful)
errorstringError message (only if failed)
-- success = true, punishmentId = 12345, error = nil
-- success = false, punishmentId = nil, error = "Player not found in active players"

exports['monoadmin']:CreatePunishment({
source = playerSource,
punishment_type = 'ban',
reason = 'Cheating detected by anti-cheat',
kick_if_online = true
}, function(success, punishmentId, error)
if success then
print('Player banned with ID: ' .. punishmentId)
else
print('Failed to ban player: ' .. error)
end
end)
exports['monoadmin']:CreatePunishment({
source = playerSource,
punishment_type = 'ban',
reason = 'Toxic behavior - 24 hour ban',
duration_minutes = 1440, -- 24 hours
kick_if_online = true
})
exports['monoadmin']:CreatePunishment({
source = playerSource,
punishment_type = 'warn',
reason = 'First offense - breaking server rules'
})
exports['monoadmin']:CreatePunishment({
source = playerSource,
punishment_type = 'kick',
reason = 'AFK for too long'
})
exports['monoadmin']:CreatePunishment({
source = playerSource,
punishment_type = 'community_service',
reason = 'Minor rule violation - 10 hours community service',
community_service_total = 10
})
local function punishPlayer(source, punishmentType, reason, durationMinutes)
-- Validate inputs
if not source or source <= 0 then
print('[MyResource] Invalid player source')
return false
end
-- Check if MonoAdmin is available
if not exports['monoadmin']:IsConnected() then
print('[MyResource] MonoAdmin is not connected to cloud')
return false
end
-- Create punishment
local success = exports['monoadmin']:CreatePunishment({
source = source,
punishment_type = punishmentType,
reason = reason,
duration_minutes = durationMinutes,
kick_if_online = punishmentType == 'ban'
}, function(success, punishmentId, error)
if success then
print(('[MyResource] Punishment created: %s (ID: %d)'):format(punishmentType, punishmentId))
-- Optionally log to Discord, database, etc.
else
print(('[MyResource] Failed to create punishment: %s'):format(error))
-- Handle error (retry, notify admin, etc.)
end
end)
return success
end
-- Usage
punishPlayer(source, 'ban', 'Cheating detected', nil) -- Permanent ban
punishPlayer(source, 'warn', 'Breaking rules', nil) -- Issue warning

ErrorCauseSolution
Missing required field: sourcesource not providedEnsure player source is passed
Missing required field: punishment_typepunishment_type not providedSpecify a valid punishment type
Missing required field: reasonreason not provided or emptyProvide a reason string
Invalid punishment_typeUnknown punishment typeUse one of the valid types listed above
Not connected to MonoAdmin cloudMonoAdmin not connectedWait for connection or check config
Player not found in active playersPlayer not trackedPlayer must be online and tracked by MonoAdmin
Player does not have a player_idPlayer ID not assignedPlayer needs to be fully registered
community_service_total is requiredMissing hours for CSProvide community_service_total for community_service type
  1. Always provide a callback to handle success/failure scenarios
  2. Check connection status with exports['monoadmin']:IsConnected() before calling
  3. Validate player source before attempting to create a punishment
  4. Log failures for debugging and audit purposes
  5. Handle async nature — the export returns immediately, callback fires later

  1. Player Must Be Online: The target player must be currently online and tracked by MonoAdmin. You cannot punish offline players via this export.

  2. Async Operation: CreatePunishment returns true immediately if the request was sent successfully. The actual result comes through the callback.

  3. Audit Logging: All punishments created via this export are logged with:

    • actor_type = 'fivem_server'
    • issued_by = NULL (system-issued)
    • created_via = 'developer_export'
  4. Dashboard Visibility: Punishments appear in the MonoAdmin dashboard immediately after creation, showing “System” as the issuer.


MonoAdmin provides additional exports for various purposes:

ExportDescription
IsConnected()Check if connected to MonoAdmin cloud
GetProjectInfo()Get current project information
HasPermission(roleId, slug)Check if a role has a permission
IsPlayerBanned(identifiers)Check if identifiers match a ban
GetPunishmentStatus(identifiers)Get full punishment status for identifiers
UpdateCommunityService(serverId, amount)Update community service progress