Zum Inhalt

Farming-System (cv_farming)

Ressourcen-Sammel-, Verarbeitungs- und Verkaufssystem mit Feldern, Prozessoren, NPCs und Fahrzeug-Verkaufszonen.


Konzept

Feld (field)           →   Rohstoff in Inventar
  └─ Prozessor (processor) →   Verarbeitetes Produkt
       └─ Verkäufer (seller) →  Geld (Cash)

Jede Material-Kategorie kann einen oder mehrere dieser Schritte definieren. Nicht jede Kategorie hat alle drei.


Konfiguration

Globale Einstellungen

Config.Farming = {
    defaultInteractRadius = 2.25,  -- Standard-Interaktionsradius für Felder
    maxUseDistance        = 4.5,   -- Max. Entfernung für Nutzung

    field = {
        durationMs = 7000,         -- Sammel-Dauer in ms
        scenario   = 'world_human_gardener_plant',  -- Animations-Szenario
    },

    npcs = {
        processorModel    = 's_m_m_dockwork_01',
        sellerModel       = 'a_m_m_business_01',
        processorScenario = 'WORLD_HUMAN_CLIPBOARD',
        sellerScenario    = 'WORLD_HUMAN_STAND_IMPATIENT'
    },

    inventory = {
        containerType = 'stash',
        maxWeight     = 400.0,
        maxSlots      = 40,
        persistent    = true,     -- Processor-Inventar bleibt über Restarts
    },

    sellerVehicleSell = {
        enabled          = true,
        maxDistance      = 18.0,    -- Fahrzeug-Verkaufszone Radius
        unloadDurationMs = 2200,    -- Basis-Entladezeit
        unloadPerItemMs  = 120,     -- Zeit pro Item beim Entladen
        unloadMaxDurationMs = 5000, -- Maximale Entladezeit
    }
}

Material-Eintrag

Config.Farming.materials = {
    holz = {
        label = 'Holz',

        -- Feld: Spieler sammelt Rohstoff
        field = {
            coords  = vec4(x, y, z, heading),
            radius  = 6.0,
            rewards = {
                { name = 'log', min = 2, max = 4, chance = 1.0 }
            }
        },

        -- Prozessoren: Rohstoff → Produkt
        processors = {
            {
                id         = 'wood_processor',
                label      = 'Holz Verarbeiter',
                coords     = vec4(x, y, z, heading),
                intervalMs = 10000,  -- 10 Sekunden pro Item
                -- optional: maxWeight, slotCount (überschreibt global)
                recipes = {
                    {
                        id           = 'wood_to_planks',
                        requirements = { { name = 'log', amount = 2, consume = true } },
                        output       = { name = 'wood_plank', amount = 1 }
                    }
                }
            }
        },

        -- Verkäufer: Produkt → Geld
        sellers = {
            {
                id        = 'wood_seller',
                label     = 'Holz-Händler',
                coords    = vec4(x, y, z, heading),
                npcModel  = 'a_m_m_business_01',         -- optional, überschreibt global
                vehicleSellZone = {                       -- optional: Fahrzeug-Verkaufszone
                    coords = vec4(x, y, z, heading),
                    radius = 22.0
                },
                sellItems = {
                    { name = 'wood_plank', price = 120 }
                }
            }
        }
    }
}

Vordefinierte Materialien

Material Feld Prozessoren Verkäufer
Sand ✅ (sand)
Holzkohle ✅ (charcoal) charcoal → black_powder Munitionshandlung
Holz ✅ (log) log × 2 → wood_plank
Steine ✅ (cobblestone)
Zement cobblestone × 2 + sand × 2 → cement Baumarkt
Eisen ✅ (iron_ore, +15% gold_ore) iron_ore × 3 → iron_ingot
Stahl iron_ingot × 2 → steel_ingot
Gold gold_ore × 3 → gold_ingot
Weintrauben ✅ (grape) grape × 4 → wine Davis Mega Mall
Kokain ✅ (cocaine_leaf) leaf × 3 → cocaine_paste 14 zufällige Dealer
Öl ✅ (oil_barrel) barrel × 2 → plastic
Glas sand × 3 → glass
Speed ✅ (ephedra) ephedra × 3 → ephedrine → speed_pills
Westen ✅ (aramid_fiber) kevlar_fiber × 4 → vest
Waffenteile steel × 3 + plank × 1 → weapon_parts
Cook Equipment steel × 2 + plastic × 2 → cook_equipment
Luftfilter plastic × 2 + black_powder → air_filter
Kisten wood_plank × 2 → crate

Verkauf per Fahrzeug

Wenn vehicleSellZone konfiguriert ist, kann der Spieler Items aus dem Fahrzeug-Kofferraum direkt an den NPC verkaufen, indem er in die Zone fährt:

  • System sucht das nächste Fahrzeug des Spielers innerhalb des maxDistance-Radius
  • Entladezeit berechnet sich aus: min(unloadPerItemMs × Anzahl + unloadDurationMs, unloadMaxDurationMs)
  • Items werden aus dem Kofferraum-Container entfernt und Geld (Cash) gutgeschrieben

Prozessor-Inventar

Jeder Prozessor hat ein eigenes Container-Inventar (gespeichert in cv_framework):

  • Container-ID: farming_processor_{id}
  • Persistent: Items bleiben bei Server-Restart erhalten
  • Spieler legen Rohstoffe ein → Prozessor verarbeitet automatisch im intervalMs-Takt
  • Fertige Produkte bleiben im Container bis der Spieler sie herausnimmt