Skip to content

Configuration

Every config option for pixel-consumables, with examples.

On this page9

Basic explanation

lua
--Administration--
Config.AdminCommands = true -- Set to false if you don't want admins to be able to set players hunger and thirst.
Config.UIKey = 'F7' -- The keybind that opens up the in-game UI. Set to false for no keybind.
Config.Command = 'consumables' -- The command that opens the in-game UI. Set to false and it falls back to /consumables; the command cannot be removed entirely.
 
Config.UpdateChecker = true -- Set to false if you don't want to check for resource update on server startup.
Config.Debug = false -- Set to false if you don't want debug logs printing in client and server consoles
 
Config.Translations = {
    NotifyCancelled = {
        title = ' ',
        text = 'You have cancelled!',
        texttype = 'error',
        duration = 5,
        icon = 'fa-solid fa-utensils',
    },
    MaxUses = {
        title = ' ',
        text = 'You have reached max uses.',
        texttype = 'error',
        duration = 5,
        icon = 'fa-solid fa-utensils',
    },
}
 
Config.ConsumablesCustom = {
    ['pixelsandwich'] = {
        -- Item removal and receiving
        ['item'] = {
            remove = {
                { item = 'pixelsandwich', amount = 1 } -- Item and amount to remove upon consumable use
            },
            receive = {
                { item = nil, amount = nil } -- Item and amount to receive upon consumable use (set to nil for no item)
            },
            maxuses = nil, -- The max amount of times the item can be used per player, per server restart.
        },
        -- Notification settings
        ['notify'] = {
            title = nil, -- Title for the notification (optional)
            text = 'You have finished eating!', -- Text to display in the notification
            texttype = 'success', -- Type of notification (success, error, etc.)
            duration = 5, -- Duration of the notification (1 = 1 second)
            icon = 'fa-solid fa-utensils', -- Icon for the notification (optional)
        },
        -- Progressbar settings
        ['progress'] = {
            title = nil, -- Title for the progress bar (optional)
            text = 'Eating', -- Text for the progress bar
            duration = 5, -- Duration of the progress (1 = 1 second)
            icon = 'fa-solid fa-utensils', -- Icon for the progress bar (optional)
            useWhileDead = false, -- Whether the progress bar can be used while dead
            canCancel = false, -- Whether the progress bar can be canceled. Only a literal false disables it; omitting the key means true
        },
        -- Control restrictions during consumable use.
        ['controlDisables'] = {
            disableMovement = false, -- Disable movement
            disableCarMovement = false, -- Disable car movement
            disableMouse = false, -- Disable mouse control
            disableCombat = true, -- Disable combat
        },
        -- Animation settings during consumable use.
        ['animation'] = {
            scene = nil, -- A scenario name played instead of animDict/anim. Not present in the shipped pixelsandwich block; see pixeljoint for a live example
            animDict = "mp_player_inteat@burger", -- Animation dictionary
            anim = "mp_player_int_eat_burger", -- Animation name
            duration = 5, -- Not read by the resource; the animation runs for progress.duration. Kept in sync by convention
            flags = 49, -- Animation flags (optional)
        },
        -- Custom prop settings for consumable use.
        ['prop'] = {
            model = "bv_sw_blackforestham", -- Model of the prop
            bone = 18905, -- The bone of the prop (18905 = left hand, 57005 = right hand)
            coords = vec3(0.13, 0.05, 0.03), -- Position of the prop
            rotation = vec3(-60.0, 150.0, -10.0), -- Rotation of the prop
        },
        -- Second custom prop settings for consumable use.
        ['prop2'] = {
            model = nil,
            bone = nil,
            coords = nil,
            rotation = nil,
        },
        -- Replenish settings (Hunger/Thirst)
        ['replenish'] = {
            type = 'Hunger', -- 'Hunger', 'Thirst' or { 'Hunger', 'Thirst' } for both.
            amount = 25, -- Amount to replenish
            max = nil, -- The max threshold to replenish to
        },
        -- Deplete settings (Hunger/Thirst)
        ['deplete'] = {
            type = nil, -- 'Hunger', 'Thirst' or { 'Hunger', 'Thirst' } for both.
            amount = nil, -- Amount to deplete (optional)
            min = nil, -- The min threshold to deplete to
        },
        -- Stress settings
        ['stress'] = {
            type = nil, -- 'relieve' or 'gain' (optional)
            amount = nil, -- Amount to modify stress (optional)
        },
        -- Alcohol-related settings
        ['alcohol'] = {
            lightalcohol = nil, -- Amount drank where light alcohol effects start
            heavyalcohol = nil, -- Amount drank where heavy alcohol effects start
            duration = nil, -- Duration of alcohol effects (1 = 1 second)
        },
        -- Drug-related effects
        ['drug'] = {
            drugeffect = nil, -- A list of effects, e.g. { 'psychedelic', 'dizzy' }
            duration = nil, -- Duration of drug effects (1 = 1 second)
        },
        -- Buff settings (With or without values)
        ['buffs'] = {
            novaluebuff = nil, -- A list of buffs without a value, e.g. { 'superjump' }
            valuebuff = nil, -- A table of buffs with values, e.g. { running = 1.2 }
            duration = nil, -- Duration of the buffs (1 = 1 second), shared by both lists
        }
    }
}

The in-game editor

/consumables, or Config.UIKey, opens an editor for Config.ConsumablesCustom. It is gated behind the same pixel.admin ace, on every action rather than only on opening, and it can add, rename, delete and edit items.

Prop aligner

coords and rotation are meant to be found in-world rather than typed in. The prop and prop2 blocks each have an align button in the editor, which spawns the prop on the bone you picked, plays the item's animation, freezes the player and puts you on a script camera until you leave. The button only does anything once the block has a model and the item has an animDict and anim.

KeyDoes
MOUSE_LEFTGrab the gizmo
WMove mode
RRotate mode
QToggle between local and world axes
SPACEPause the animation on the current frame, and resume it
CFreecam, to look from somewhere other than the orbit camera. WASD orbits, Q and E change height, the mouse wheel zooms, C leaves
ENTERSave and return to the editor
ESC or BACKSPACECancel and return to the editor

Saving hands the coords and rotation back to the item's form. They reach config.lua when you save the item itself, on the same rewrite the callout above describes.

Examples and lists

lua
-- Below is an example of removing a cola and receiving back an empty can.
['item'] = {
    remove = {
        { item = 'pixelcola', amount = 1 }, -- Item and amount to remove upon consumable use
    },
    receive = {
        { item = 'emptycan', amount = 1 }, -- Item and amount to receive upon consumable use (set to nil for no item)
    },
},

Both are lists, so an item can remove or hand back more than one thing. They are also the security allowlist: on startup the server reads every remove and receive in the config and will not remove an item no remove names, or hand out an item no receive names.

lua
-- Below is an example of one item raising both needs by the same amount.
['replenish'] = {
    type = { 'Hunger', 'Thirst' },
    amount = 10, -- Amount to replenish
    max = nil, -- The max threshold to replenish to
},
lua
-- Below is an example of raising both needs by different amounts.
['replenish'] = {
    { type = 'Hunger', amount = 20, max = nil },
    { type = 'Thirst', amount = 5, max = nil },
},

'Hunger' and 'Thirst' are the only two values, capitalisation included, and anything else is ignored. deplete takes both of the same forms with min in place of max. The two blocks are merged into one write, so a single item can raise thirst and lower hunger.

lua
-- Below is an example of drinking 5 to get light effects and 7 for heavy effects.
['alcohol'] = {
    lightalcohol = 5, -- Amount drank where light alcohol effects start
    heavyalcohol = 7, -- Amount drank where heavy alcohol effects start
    duration = 120, -- Duration of alcohol effects (1 = 1 second)
},

Set both values. The count is drinks taken this session, shared across every alcoholic item rather than tracked per item, and it resets to zero once an effect has run its course.

lua
-- Below is a list of all possible drug effects.
['drug'] = {
    drugeffect = {
        'psychedelic',
        'brightpsychedelic',
        'foggy',
        'flicker',
        'dizzy',
        'shaking',
        'hallucination',
        'focus'
    },
    duration = 120, -- Duration of drug effects (1 = 1 second)
},

Every effect on the list shares the one duration.

hallucination re-dresses nearby peds into appearances read from Config.HallucinationAppearances, and puts them back exactly as they were when the effect ends. config.lua ships six placeholder entries so the effect works out of the box.

Peds are re-dressed, not remodelled. Changing a ped's model means deleting and respawning it, which is not safe to do to networked world entities. So an entry only applies to peds already wearing its model. In practice that means other players and freemode NPCs; stock ambient peds (a_m_y_hipster_01 and friends) are left alone unless you add entries for their models.

Writing appearances

Do not write these by hand. Dress up in-game, run /copyped from pixel-utils, and paste the block it prints:

lua
Config.HallucinationAppearances = {
    ['suit_m'] = {
        model = 'mp_m_freemode_01',
        components = {
            { component_id = 4, drawable = 10, texture = 0 },
            { component_id = 11, drawable = 4, texture = 0 },
        },
        props = {
            { prop_id = 1, drawable = 5, texture = 0 },
        },
        hair = { style = 4, texture = 0, color = 0, highlight = 0 },
        eyeColor = 2,
    },
}

Capture and playback both go through pixel-utils' appearance module, so anything /copyped emits is understood here: headBlend, faceFeatures, headOverlays, hair, eyeColor, tattoos, components and props.

A capture records clothing as a collection name plus a local index, which survives you adding, removing or reordering DLC clothing packs later. Plain numbers written by hand are treated as legacy global indices and still work, but they shift when your pack list changes. That is another reason to capture rather than type.

FieldNotes
componentsRequired. An entry without it is skipped
modelPool key. Defaults to mp_m_freemode_01. Only peds already using this model are affected
propsOptional. drawable = -1 clears that slot instead of setting it
everything elseOptional

Keys are cosmetic: both a named table and a plain list work.

The in-game editor regenerates config.lua on every save, and it rewrites Config.HallucinationAppearances verbatim, so captures you paste in survive editing items. Comments you add around them do not.

lua
-- Below is a list of all possible buff effects with and without values
['buffs'] = {
    novaluebuff = {
        'nostress', -- No stress will be received from this resource.
        'stamina', -- No stamina will be drained.
        'superjump', -- Will be able to do super jumps.
        'energy' -- Sets a flag for the exports to read, no game effect of its own.
    },
    valuebuff = {
        strength = 2.0, -- Melee damage multiplier, applied while unarmed.
        running = 1.2, -- Sprint multiplier. The game ignores anything above 1.49.
        swimming = 1.2, -- Swim multiplier. The game ignores anything above 1.49.
        health = 2, -- Health added every 2 seconds
        armor = 2 -- Armour added every 2 seconds
    },
    duration = 120, -- Duration of the buffs (1 = 1 second)
}

duration is shared by both lists, and it is required. nostress only suppresses the stress this resource applies while it is running, so stress from other resources still lands.

Integration with other scripts

Below is a guide with everything needed to add or change for integration with r14-evidence.

  • You will need to download the latest version of our consumables in order for this to work.
  • You must replace the specified lines in the specified files with the code below.

pixel-consumables:alcohol and pixel-consumables:drugs are declared in client/editable.lua and fire on the client with the item name as their only argument, which is what alcoholArgPos and drugArgPos point at. An item fires the alcohol event when its alcohol block sets either value, and the drug event when its drug block sets drugeffect.

Config.Breathalyzer

In r14-evidence/config.lua, around line 210.

lua
Config.Breathalyzer = {
    Enabled = true,
    UsingESX = false,
    EventTriggers = {
        [1] = {
            event = 'pixel-consumables:alcohol',
            type = 'client',
            alcoholArgPos = 1,
            alcoholArgValue = {
                ['pixelbeer'] = 10,
                ['pixelwhiskey'] = 300,
                ['pixelvodka'] = 300,
                ['pixelchampagne'] = 120,
                ['pixeltequilla'] = 300,
                ['pixelwine'] = 150,
            },
        },
    },
}

Config.DrugTesting

In r14-evidence/config.lua, around line 256.

lua
Config.DrugTesting = {
    Enabled = true,
    UsingQBSR = false,
    DefaultPositiveTime = 3,
    Drugs = {
        ['pixeljoint'] = {
            label = 'Marijuana'
        },
        ['pixelcocaine'] = {
            label = 'Cocaine',
        },
        ['pixelmeth'] = {
            label = "Methamphetamine",
        },
        ['pixelshrooms'] = {
            label = 'Shrooms',
        },
        ['pixelecstasy'] = {
            label = 'Ecstasy',
        },
        ['pixeloxy'] = {
            label = 'Oxycodone',
        },
    },
    EventTriggers = {
        [1] = {
            event = 'pixel-consumables:drugs',
            type = 'client',
            drugArgPos = 1,
            drugArgValue = {
                ['pixeljoint'] = 'pixeljoint',
                ['pixelcocaine'] = 'pixelcocaine',
                ['pixelmeth'] = 'pixelmeth',
                ['pixelshrooms'] = 'pixelshrooms',
                ['pixelecstasy'] = 'pixelecstasy',
                ['pixeloxy'] = 'pixeloxy',
            }
        },
    }
}

Drug status trigger

In r14-evidence/client/main.lua, around line 1217.

lua
local drugType = checkValue[checkArg]
local positiveTime = v.positiveTime or Config.DrugTesting.DefaultPositiveTime
 
TriggerServerEvent('evidence:server:SetDrugStatus', {drug = drugType, hours = positiveTime})