Exports & Events
This section contains all the exports provided by the script. For best results, make changes with someone knowledgeable in Lua to prevent errors.
Exports
isPlayerDrunk
exports['mst_breathalyzer']:isPlayerDrunk(targetId)
The isPlayerDrunk export allows you to check if any player is currently drunk. This export can check both the local player and other players.
How to use?
To check if the local player is drunk, use the following code:
-- Check if specific player is drunk
local targetId = 5
local isDrunk = exports['mst_breathalyzer']:isPlayerDrunk(targetId)
if isDrunk then
print("Player " .. targetId .. " is currently drunk")
else
print("Player " .. targetId .. " is sober")
end
-- Check if local player is drunk
local isLocalDrunk = exports['mst_breathalyzer']:isPlayerDrunk()
if isLocalDrunk then
print("You are currently drunk")
else
print("You are sober")
end
Parameters:
targetId
(number, optional): Target player's server ID. If omitted, checks local player.
Return value:
Returns
true
if player is drunk (BAC > 0.50)Returns
false
if player is sober (BAC ≤ 0.50)
getPlayerBAC
exports['mst_breathalyzer']:getPlayerBAC()
The getPlayerBAC export allows you to retrieve the current BAC level of the local player from the client. This export provides real-time information about the player's alcohol consumption.
How to use?
To get the local player's current BAC level, use the following code:
-- Get BAC of specific player
local targetId = 5
local targetBAC = exports['mst_breathalyzer']:getPlayerBAC(targetId)
if targetBAC then
print("Player " .. targetId .. " BAC: " .. targetBAC)
-- Check their drunk level
if targetBAC <= 0.50 then
print("Player " .. targetId .. " is sober")
elseif targetBAC <= 1.00 then
print("Player " .. targetId .. " is impaired")
else
print("Player " .. targetId .. " is drunk")
end
else
print("Player " .. targetId .. " BAC not available")
end
-- Get local player's BAC
local localBAC = exports['mst_breathalyzer']:getPlayerBAC()
if localBAC then
print("Your BAC: " .. localBAC)
if localBAC <= 0.50 then
print("You are sober")
elseif localBAC <= 1.00 then
print("You are impaired")
else
print("You are drunk")
end
else
print("Your BAC not available")
end
Parameters:
targetId
(number, optional): Target player's server ID. If omitted, gets local player's BAC.
Return value:
Returns
number
representing current BAC level (0.0 to 4.0)Returns
nil
if BAC data is not available
setPlayerBAC
exports['mst_breathalyzer']:setPlayerBAC(source, bacLevel)
The setPlayerBAC export allows you to set a specific BAC level for a player from the server side. This export is useful for medical scripts, police interactions, or custom scenarios where you need to control a player's alcohol level programmatically.
How to use?
To set a player's BAC level, use the following code:
-- Set player's BAC to 0.5 (impaired level)
exports['mst_breathalyzer']:setPlayerBAC(source, 0.5)
-- Set player's BAC to 0.0 (completely sober)
exports['mst_breathalyzer']:setPlayerBAC(source, 0.0)
-- Set player's BAC to 2.0 (very drunk)
exports['mst_breathalyzer']:setPlayerBAC(source, 2.0)
Parameters:
source
(number): The player's server IDbacLevel
(number): The BAC level to set (0.0 to 4.0)
Return value:
Returns
number
representing current BAC level (0.0 to 4.0)Returns
nil
if BAC data is not available
Events
openUI
TriggerEvent('mst_breathalyzer:openUI')
The mst_breathalyzer:openUI event allows you to open the breathalyzer interface. This event is useful for other scripts that need to force open the breathalyzer UI.
How to use?
To open the breathalyzer UI, use the following code:
-- Add breathalyzer option to qb-radialmenu
{
id = 'breathalyzer',
title = 'Breathalyzer',
icon = 'wine-bottle',
type = 'client',
event = 'mst_breathalyzer:openUI',
shouldClose = true
}
Last updated