Action Customization
Customize MonoAdmin's default behaviors for bans, kicks, heals, and revives using the customizable/ directory.
MonoAdmin allows developers to override default behaviors for specific actions. This is useful for integrating with custom frameworks, anti-cheat systems, or specialized server logic.
These customizations are handled via the customizable/ directory within the monoAdmin resource.
Server-Side Customization
Section titled “Server-Side Customization”Server-side overrides are located in customizable/server.lua. These functions allow you to control what happens when a player is banned or kicked.
customizable/server.lua
Section titled “customizable/server.lua”local internalName = "Sevent"CustomizableAction = CustomizableAction or {}CustomizableAction[internalName] = {}local intTable = CustomizableAction[internalName]
-- playerId, reason, duration in seconds; 0 = permanentintTable.onPlayerPunishmentBan = function(player, reason, duration) -- Default behavior: DropPlayer(player, reason) DropPlayer(player, reason) return true, nilend
intTable.onPlayerPunishmentKick = function(player, reason) -- Default behavior: DropPlayer(player, reason) DropPlayer(player, reason) return true, nilendAvailable Overrides
Section titled “Available Overrides”| Function | Parameters | Description |
|---|---|---|
onPlayerPunishmentBan | player, reason, duration | Triggered when a player is banned. |
onPlayerPunishmentKick | player, reason | Triggered when a player is kicked. |
Client-Side Customization
Section titled “Client-Side Customization”Client-side overrides are located in customizable/client.lua. These allow you to hook into actions like healing and reviving, which is essential if your server uses a custom ambulance or health system.
customizable/client.lua
Section titled “customizable/client.lua”local internalName = "events"CustomizableAction = CustomizableAction or {}CustomizableAction[internalName] = {}
local intTable = CustomizableAction[internalName]
intTable.revive = function() if Config.Framework == 'esx' then TriggerEvent('esx_ambulancejob:revive') else local ped = MonoAdmin.State.ped local coords = GetEntityCoords(ped)
NetworkResurrectLocalPlayer(coords.x, coords.y, coords.z, GetEntityHeading(ped), true, false) SetEntityHealth(ped, GetEntityMaxHealth(ped)) ClearPedBloodDamage(ped) ResetPedVisibleDamage(ped) ClearPedTasksImmediately(ped) end return trueend
intTable.heal = function() if Config.Framework == 'esx' then TriggerEvent('esx_ambulancejob:heal', 'big', true) else local ped = MonoAdmin.State.ped SetEntityHealth(ped, GetEntityMaxHealth(ped)) SetPedArmour(ped, 100) ClearPedBloodDamage(ped) ResetPedVisibleDamage(ped) end return trueendAvailable Overrides
Section titled “Available Overrides”| Function | Description |
|---|---|
revive | Overrides the behavior when an admin revives a player. |
heal | Overrides the behavior when an admin heals a player. |
Best Practices
Section titled “Best Practices”- Return Values: Ensure your functions return
true(andnilfor error if applicable) to signify a successful override. - Framework Checks: Use
Config.Frameworkto tailor logic for ESX, QB-Core, or Standalone environments. - State Management: Access local player state via
MonoAdmin.State.pedon the client side for optimized performance.