Zum Inhalt springen
ATY ScriptsDokuHousingLiving

Living

aty_housing: Living

Overview · Installation · Configuration · Features and commands · Living · Home security · Economy, upgrades and the player market · Furniture, lighting and yards · Apartments, buildings and motels · Exports and events · Webhooks and migration · Troubleshooting

Living: cooking, needs, hygiene and rest

Furniture does something real. All amounts are decided on the server; the client only shows them.

Furniture What it does
Stove, oven, microwave, gas cooker, fitted kitchen, barbecue Opens the recipe panel: pick a recipe and an amount, cook with a progress bar and attention checks (press E when "Stir!" shows). Missed checks can burn the food. The ingredients are taken and the food is given only when the cooking finishes; stopping, leaving or a power cut takes nothing
Coffee maker, kettle, teapot Recipe panel for drinks (coffee, espresso)
Sink E washes hands (hygiene). G opens the tap: drink water (thirst) or fill a glass (water item, a few per hour)
Shower, bath Hygiene, and less stress
Bed Every 30 s less stress and a little health. Sleeping 5 minutes in one go makes the player rested for an hour (faster health regeneration, stress relief now and then)
Sofa, chair (+ a TV that is on nearby) Stress goes down slowly, faster with a TV on
Fridge Storage (see Fridges)

Pressing E on a piece first walks the player to it: in front of a chair, sofa or toilet, beside a bed or bath (on the player's side), in front of a sink, stove or mirror. The action starts on arrival, so the server checks the distance from where the player stands. Chairs, sofas and baths play their sit-down clip from the clip's own starting spot (the player walks there first), and chairs, sofas, baths and toilets play a stand-up clip when the player gets up; a bed is left with a short blend. Moving (W A S D), ESC, taking damage or E again cancels the walk; nothing happens then. A walk that gets stuck or takes too long places the player directly, as before. Config.Living.walkTo.enabled = false turns walking off.

Hunger, thirst and stress are written to the framework through aty_lib (AddPlayerNeeds: qb-core metadata + qb-hud events, ESX esx_status). Update and restart aty_lib for this; with an older aty_lib the effects only go out as events and hooks (one console line says so). Hygiene and "rested" are kept by aty_housing (table aty_housing_living_stats).

Stations and recipes

Every stove in the catalog has a station, and a station cooks with some methods (Config.Living.cooking.stations):

Station Methods Catalog models
kitchen oven, hob, counter apa_mp_h_kit_kitchen_01_a, apa_mp_h_kit_kitchen_01_b
cooker oven, hob v_res_ovenhobmod, prop_cooker_03
oven oven v_res_int_oven
microwave microwave (half the time) prop_microwave_1
bbq grill (needs no power) prop_bbq_1, prop_bbq_5, prop_beach_bbq
coffee brew coffee machines, coffee pot, teapot, kettle

Default recipes (qb-core item names; Config.Living.cooking.recipes):

Recipe Makes Ingredients Methods
Grilled cheese tosti bread, cheese hob, grill, oven
Sandwich sandwich sandwichbread, lettuce, tomato counter
Burger burger burger_bun, raw_patty, lettuce hob, grill (burns to burnt_meat)
Steak steak raw_meat, salt grill, hob (burns to burnt_meat)
French fries frenchfries raw_potato x2, oil hob
Tomato soup tomato_soup tomato x2, salt, water_bottle hob
Vegetable ramen vegetable_ramen noodles, lettuce, water_bottle hob, microwave
Oven pizza cooked_frozen_pizza frozen_pizza oven, microwave
Mac & cheese cooked_macncheese frozen_macncheese microwave, oven
Lasagna cooked_lasagna frozen_lasagna oven, microwave
Grilled sausage cooked_sausage raw_sausage grill, hob (burns to burnt_meat)
Hot dog hotdog raw_sausage, bread grill (burns to burnt_meat)
Coffee coffee coffee_beans, water_bottle brew
Espresso espresso coffee_beans x2 brew

Eating or drinking the product is the item's own use (qb-smallresources consumables, your inventory's item effects or a food script); aty_housing adds no food effect. At start every recipe is checked against the framework item list (qb-core): a recipe with an unknown item is switched off with a console line. On a non-qb-core framework the check is skipped.

Configuration

All in Config.Living (shared/config.lua, commented there):

Key Default Description
effects all true stress, hunger, thirst, health, hygiene: false switches one effect off everywhere
needs.framework true Write hunger / thirst / stress to the framework through aty_lib
caps { stress = 60, health = 150, thirst = 80, hunger = 80, hygiene = 0 } Most one character gets from living per hour (helpful direction only; 0 = no cap)
actions[use].tick seat, bed, bath { every, effects, tv? }: effects over time while sitting / lying / bathing
hygiene decayPerHour = 4, dirty = 35, filthy = 15, ... Drops while online; reminders when dirty, a little stress when filthy
rested sleepMinutes = 5, minutes = 60, healthRegen = 1.5 The rested bonus
tap.fill { item = 'water', perHour = 4, input = false, guests = false } Filling at the sink (input = an item it takes, for example 'glass')
walkTo enabled = true, maxDistance = 8.0, timeoutMs = 8000, stuckMs = 1000, snapTolerance = 0.05, ... Walk to the piece before an action (navmesh path in IPL / MLO interiors, a straight line in shells). Farther than maxDistance, stuck for stuckMs twice or past the time limit (baseMs + metres x msPerMetre, at most timeoutMs): placed directly. approach picks 'front' or 'side' per seat / bed / bath / toilet, edgeGap is the distance from the piece, enterAnims = false skips the sit-down clips, exitAnims = false skips the stand-up clips (cleared at once as before)
cooking maxBatch = 5, perHour = 40, windowMs = 1800, burnBase = 0.03, burnPerMiss = 0.3, qualityMetadata = true, ... Cooking rules; enabled = false makes stoves work as before (animation only). Config.Living.cook.event / cook.export still hands the stove to another crafting script instead

Fridges

A placed fridge is a storage stash. aty_inventory computes freshness from each item's own timestamp, so food still spoils inside a fridge. An inventory that wants cold storage can ask exports.aty_housing:IsFridgeStash(stashId) (returns true, propertyId) or GetFridgeStashes(propertyId).

Integration (exports, events, hooks)

Server exports (who = server id or character id):

Export Returns
GetHygiene(who) 0-100 or nil
SetHygiene(who, value, reason?) / AddHygiene(who, delta, reason?) New value or nil (online players)
GetRested(who) { rested, untilTime, secondsLeft } or nil
SetRested(who, minutes) Until time (0 = cleared) or nil
ApplyLivingEffects(src, effects, tag?) The applied effects (same rules as a shower: switches, hooks, caps) or nil. Keys stress, hunger, thirst, health, hygiene, whole numbers -100..100
RegisterRecipe(def) / RemoveRecipe(id) / GetRecipes(station?) Add your own recipes (same shape as the config; items must exist). Removed when your resource stops
RegisterLivingAction(name, def) / RemoveLivingAction(name) Add an action to a furniture use, e.g. { label = 'Brush teeth', uses = { 'sink' }, seconds = 5, effects = { hygiene = 5 }, anim = { dict, clip }, canUse = fn, onComplete = fn }
IsFridgeStash(stashId) / GetFridgeStashes(propertyId) Fridge stash lookups
IsLivingBusy(src) The action the player is doing, or nil

Client exports: GetHygiene(), GetHygieneState() (clean/dirty/filthy), GetRested(), IsLivingBusy(), StartLivingAction(name, target?) (a registered action on the nearest fitting furniture, or { kind, id }).

Server events (AddEventHandler only):

Event Arguments
aty_housing:livingStart / livingFinish / livingCancel (source, data): data = { charId, propertyId, use, act, kind, id, guest, seconds, loop, recipe?, count?, complete?, reason?, effects?, result? }. Exactly one of finish (completed) / cancel (ended early) per action
aty_housing:livingEffect (source, charId, propertyId, use, effects, meta): every applied effect; `meta = { act, phase = 'complete'
aty_housing:cooked (source, { charId, propertyId, recipe, output, count, burnt, quality, method, station, misses, checks, guest })
aty_housing:hygieneChanged (source, charId, value, old, reason)
aty_housing:restedChanged (source, charId, untilTime, reason)

Hooks (RegisterHook): canLivingAction(data) (return false, message to refuse an action or a cook), modifyLivingEffect(data) (return false to cancel the effects or a table to replace them; keep it short, the effect waits for it), onLivingEffect(data) and onCooked(data) (follow-ups). Client-local events: aty_housing:client:livingStarted, livingFinished, livingCancelled, effectApplied, hygiene, rested.

-- A needs script that wants hygiene to matter at work:
AddEventHandler('aty_housing:hygieneChanged', function(src, charId, value)
    if value < 15 then exports['my_jobs']:BlockCustomerJobs(src, 'You need a shower first.') end
end)

-- Your own recipe (after aty_housing started):
exports.aty_housing:RegisterRecipe({
    id = 'pancakes', output = 'sandwich', ingredients = { flour = 1, egg = 2, milk = 1 },
    methods = { 'hob' }, seconds = 25,
})

-- Double sleep benefits for VIPs:
exports.aty_housing:RegisterHook('modifyLivingEffect', function(data)
    if data.phase == 'tick' and data.act == 'bed' and exports['my_vip']:IsVip(data.source) then
        local e = data.effects
        return { stress = (e.stress or 0) * 2, health = (e.health or 0) * 2 }
    end
end)