Addiction and Metabolism
An example of using twh_addiction with fred_metabolism
To make it more easy to configurate later on i recommend defining items in an list/dictionary. For example:
local cocaineItems = {"cocain"}
local alcoholItems = {"beer","whisky"}
You can also set this up in the config file ofc. For checking if an item is in the defined items you can use a simple function like this:
function Contains(table, value)
for k, v in pairs(table) do
if v == value then
return true
end
end
return false
end
Now look for the "fred_meta:useItem"
Event, where everything is defined. Before or after the definition of the animations you now can just do something like this to determine which addiction should be encountered:
if Contains(alcoholItems,Config.ItemsToUse[index]["Name"]) then
AddictAPI.itemUsed("Alcohol",1)
elseif Contains(cocaineItems,Config.ItemsToUse[index]["Name"]) then
AddictAPI.itemUsed("Cocaine",1)
end
Reminder: Don't forget to define the AddictAPI like mentioned in the Documentation.
Last updated