Exports and Commands
๐ฅ๏ธ Server-Side Exports
AddAddiction
AddAddiction
Purpose: Add addiction points to a player from server-side scripts.
Usage:
exports['envi-addictions']:AddAddiction(source, addictionType, points)
Parameters:
source
(number): Player's server IDaddictionType
(string): Type of addiction (must exist in config)points
(number): Amount of addiction points to add
Returns: boolean
- Success status
Example:
-- Add 50 gambling addiction points to player
exports['envi-addictions']:AddAddiction(source, 'gambling', 50)
RemoveAddiction
RemoveAddiction
Purpose: Remove addiction points from a player.
Usage:
exports['envi-addictions']:RemoveAddiction(source, addictionType, points)
Parameters:
source
(number): Player's server IDaddictionType
(string): Type of addictionpoints
(number): Amount of points to remove (-1 to remove all)
Returns: boolean
- Success status
Example:
-- Remove 25 alcohol addiction points
exports['envi-addictions']:RemoveAddiction(source, 'alcohol', 25)
-- Remove all cocaine addiction points
exports['envi-addictions']:RemoveAddiction(source, 'cocaine', -1)
CureAddiction
CureAddiction
Purpose: Completely cure a specific addiction (convenience function).
Usage:
exports['envi-addictions']:CureAddiction(source, addictionType)
Parameters:
source
(number): Player's server IDaddictionType
(string): Type of addiction to cure
Returns: boolean
- Success status
Example:
-- Completely cure meth addiction
exports['envi-addictions']:CureAddiction(source, 'meth')
GiveMaxAddiction
GiveMaxAddiction
Purpose: Give maximum addiction level to a player.
Usage:
exports['envi-addictions']:GiveMaxAddiction(source, addictionType)
Parameters:
source
(number): Player's server IDaddictionType
(string): Type of addiction
Returns: boolean
- Success status
Example:
-- Give maximum heroin addiction
exports['envi-addictions']:GiveMaxAddiction(source, 'heroin')
UsedItem
UsedItem
Purpose: Trigger addiction effects when a player uses an item. - NOTE: IF YOU ARE USING OX_INVENTORY - YOU DO NOT NEED THIS!
Usage:
exports['envi-addictions']:UsedItem(source, itemName)
Parameters:
source
(number): Player's server IDitemName
(string): Name of the item used
Returns: void
Example:
-- Trigger when player uses beer
exports['envi-addictions']:UsedItem(source, 'beer')
๐ป Client-Side Exports
AddAddiction
AddAddiction
Purpose: Add addiction points from client-side scripts.
Usage:
exports['envi-addictions']:AddAddiction(addictionType, points)
Parameters:
addictionType
(string): Type of addictionpoints
(number): Amount of addiction points to add
Returns: boolean
- Success status
Example:
-- Add 30 gambling addiction points
exports['envi-addictions']:AddAddiction('gambling', 30)
GiveMaxAddiction
GiveMaxAddiction
Purpose: Give maximum addiction level from client.
Usage:
exports['envi-addictions']:GiveMaxAddiction(addictionType)
Parameters:
addictionType
(string): Type of addiction
Returns: boolean
- Success status
Example:
-- Give maximum meth addiction
exports['envi-addictions']:GiveMaxAddiction('meth')
UpdatePlayerBlemishes
UpdatePlayerBlemishes
Purpose: Update player's visual effects based on current addictions.
Usage:
exports['envi-addictions']:UpdatePlayerBlemishes()
Parameters: None
Returns: void
Example:
-- Update visual effects
exports['envi-addictions']:UpdatePlayerBlemishes()
ClearAllVisualEffects
ClearAllVisualEffects
Purpose: Clear all addiction-related visual effects.
Usage:
exports['envi-addictions']:ClearAllVisualEffects()
Parameters: None
Returns: void
Example:
-- Clear all visual effects
exports['envi-addictions']:ClearAllVisualEffects()
๐งช Test Mode Settings
Config.SelfTestMode - Allows you to run Blood Tests / Stomach Pumping / Commit To Rehab on yourself for testing purposes
Config.TestCommands
Note: These commands are only available when Config.TestCommands = true
Server Test Mode Commands
/testaddiction
Test addiction level calculations.
Usage: /testaddiction
/giveaddiction
Give addiction points to yourself.
Usage: /giveaddiction <addiction_type> <points>
Example: /giveaddiction alcohol 50
/giveAllAddictions
Give all available addictions to yourself.
Usage: /giveAllAddictions
Client Test Mode Commands
/addcraving
Add craving points to a specific addiction.
Usage: /addcraving <addiction_type> [points]
Example: /addcraving meth 25
/takeBloodFromSelf
(when Config.SelfTestMode is true and on Authorised Job)
Take a blood sample from yourself.
Usage: /takeBloodFromSelf
/addAddiction
Test the AddAddiction export function.
Usage: /addiction <addiction_type> <points>
Example: /addiction gambling 100
/removeAddiction
Test the RemoveAddiction export function.
Usage: /removeAddiction <addiction_type> [points]
Example: /removeAddiction gambling 50
/cureAddiction
Test the CureAddiction export function.
Usage: /cureAddiction <addiction_type>
Example: /cureAddiction gambling
/maxAddiction
Test the GiveMaxAddiction export function.
Usage: /maxAddiction <addiction_type>
Example: /maxAddiction gambling
/updateBlemishes
Test the blemish system and update visual effects.
Usage: /updateBlemishes
/clearBlemishes
Clear all visual effects manually.
Usage: /clearBlemishes
/toggleFocus
Toggle NUI focus (bound to Left Alt by default).
Usage: /toggleFocus
Key Binding: LMENU (Left Alt)
Yoga Commands (if enabled in config)
Start yoga activity for time reduction in rehab.
Usage: /<yoga_command> (configured in Config.InvoluntaryRehab.timeReduction.Yoga.command)
Stop: /stopYoga (bound to X key)
๐ Usage Examples
Adding Gambling Addiction After Casino Activity
-- Server-side in casino script
RegisterNetEvent('casino:playerGambled', function(amount)
local src = source
local addictionPoints = math.floor(amount / 1000) -- 1 point per $1000 gambled
-- Add gambling addiction points
exports['envi-addictions']:AddAddiction(src, 'gambling', addictionPoints)
end)
Drug Taking Consequences
-- Server-side in drug script
RegisterNetEvent('drugs:tookDrugs', function(drugType)
local src = source
-- Add addiction risk
if drugType == 'cocaine' or 'crack' then
exports['envi-addictions']:AddAddiction(src, 'cocaine', 5)
elseif drugType == 'meth' then
exports['envi-addictions']:AddAddiction(src, 'meth', 8)
end
end)
Medical Treatment Script
-- Server-side medical script
RegisterNetEvent('medical:cureAddiction', function(targetId, addictionType)
local src = source
-- Check if player is authorized medical professional
if IsAuthorizedMedic(src) then
exports['envi-addictions']:CureAddiction(targetId, addictionType)
end
end)
Client-side Integration
-- Client-side in another script
RegisterNetEvent('myScript:triggerAddiction', function(addictionType, points)
-- Trigger addiction from client side
exports['envi-addictions']:AddAddiction(addictionType, points)
-- Update visual effects
exports['envi-addictions']:UpdatePlayerBlemishes()
end)
Last updated