Project: Survival Core - A Modular FiveM Survival Framework
Project Goal: To create a comprehensive and modular survival framework for FiveM, allowing for detailed and interconnected survival mechanics, a customizable player experience, and easier future development and maintenance. The project emphasizes a refactored core, specialized modules for different survival aspects, and integration with modern libraries like ox_lib
and ox_target
.
I. Core Framework: sc_core
(Refactored)
- Primary Responsibilities:
- Central Player Data Management: Handles loading, saving, and caching core player anagrafics and essential survival statuses (health, hunger, thirst, stamina, temperature, sleep, stress, immunity, etc.) through a
player_survival_data
database table. - Core Status Effect System: Provides foundational functions for applying, clearing, checking, and ticking down the duration of generic status effects. Specific effect logic is delegated to relevant modules.
- Spawn & Death Management:
- Manages initial player spawning (new player, default location) and subsequent respawns (e.g., at hospitals after death).
- Handles “Last Location” spawning by saving/loading player coordinates.
- Implements an “Incapacitated State” (bleedout timer) before true death, allowing for potential revival.
- Manages consequences of “True Death” (triggering item/skill loss via other modules, applying post-death trauma effects).
- Orchestration Tick: A main server-side loop that calls
Tick()
functions of other specialized modules at configured intervals, passing necessary player data. - Event Hub & Configuration: Manages core server/client events and provides access to global configuration values for other modules.
- Central Player Data Management: Handles loading, saving, and caching core player anagrafics and essential survival statuses (health, hunger, thirst, stamina, temperature, sleep, stress, immunity, etc.) through a
- Key Files:
sh_survival_core.lua
,sv_survival_core.lua
,cl_survival_core.lua
. - Dependencies:
oxmysql
,sc_identity
(or other character framework),ox_lib
.
II. Core Gameplay Modules:
1. sc_inventory
(Inventory & Item System)
- Responsibilities: Manages all player and external inventories (player main, equipment, pockets, stashes, vehicle storage, item containers).
Handles item definitions, properties (weight, stackability, metadata), and all item interactions (add, remove, move, use).
Includes a hotbar and player-to-player trading system.
The UI is built with HTML/CSS/JS. - Item Degradation & Repair: This module is now responsible for the entire item condition system.
- Manages durability loss for all item types (clothing, tools, weapons) via its own
ReportItemUsage
export. - Includes a server-side tick for clothing wear.
- Handles item repair logic, requiring the “maintenance” skill from
sc_skill
. - Relevant configuration (
ItemConditionSystem
) moved tosc_inventory
’s shared config. - Key Interactions:
- Called by
sc_core
(and other modules) for item manipulations. - Calls
sc_skill
for maintenance skill during repairs. - Calls exports of
sc_supply
,sc_injury
,sc_disease
when specific items are “used”. - Integrates with
ox_target
for vehicle inventory access. - Dependencies:
sc_core
,sc_skill
,ox_lib
,ox_target
.
2. sc_appearance
(Character Appearance Customization)
- Responsibilities: Manages detailed physical character appearance customization (excluding clothing).
Features a new fullscreen UI with a “Wasteland/Military/Modern/Sleek” theme. - UI Features: * Categories: Head & Face (including Gender), Hair & Facial, Markings (Scars, Tattoos, Makeup, Blemishes), Physique.
- Dynamic option population, sliders, icon grids, and planned RGB color pickers.
- Uses Google Material Symbols for icons.
- Logic: Client-side (
cl_appearance.lua
) applies changes to the ped using game natives and manages the customization camera. Server-side (sv_appearance.lua
) validates and saves appearance data viasc_identity
. - Dependencies:
sc_core
,sc_identity
,ox_lib
(planned for future UI elements).
3. sc_skill
(Player Skills System)
- Responsibilities: Defines available skills (e.g., Firemaking, Foraging, First Aid, Maintenance, Resilience, Construction, Endurance, Cold Resistance, Cooking). Manages XP gain, leveling mechanics, and skill data persistence (skill table stored by
sc_core
). - Key Interactions: Provides exports for other modules to query skill levels (
GetPlayerSkillLevel
) and add XP (AddSkillXP
). - Dependencies:
sc_core
.
III. Specialized Survival Modules:
These modules will handle specific survival mechanics, each with its own config, server, and client logic.
They will heavily rely on sc_core
for player data and status effect management, sc_inventory
for item interactions, and sc_skill
for skill checks/XP.
ox_lib
will be used for UI/utility, and ox_target
for world interactions.
4. sc_environment
- Weather system, environmental zones (radiation, humidity, toxic), radiation accumulation, and player wetness system.
5. sc_temperature
- Player body temperature calculation considering ambient temperature (from
sc_environment
), clothing (fromsc_inventory
), heat sources (fromsc_fire
/sc_construction
), wetness, and wind.
Applies temperature-related status effects.
6. sc_stamina
- Manages player stamina (drain/regeneration) and the fatigue system (sleep level decay, tiredness/exhaustion effects, microsleeps, forced rest, and the resting action).
7. sc_disease
- Handles sicknesses (causes, types, symptoms, immunity), stress and mental well-being (stress factors, panic, hallucinations), and the use of cure items.
8. sc_injury
- Manages all types of injuries (fall damage, combat damage), a limb-specific effects system, bleeding, pain points, and first aid treatment. Will trigger the “Incapacitated” state.
9. sc_fire
- Fire starting (requires items, skill, considers weather), fuel management, heat/light generation, and extinguishing. Will be interactive via
ox_target
.
10. sc_supply
- Manages hunger/thirst/urination/defecation needs.
- Handles food/water consumption (spoilage, purity), cooking/boiling (interfacing with
sc_fire
), and water collection.
Includes the Foraging system withox_target
interaction and tool usage (degrading tools viasc_inventory
).
11. sc_construction
- Manages the placement and persistence of basic player-made structures (e.g., campfires, tents, storage boxes, fences, spike strips) using kit items.
Includesox_target
interactions for dismantle, rest, and opening storage (interfacing withsc_inventory
for external storage andsc_fire
for placeable fire pits).
IV. Overall Architecture & Flow:
- Modularity: The primary goal is a highly modular system where each script has a clear responsibility.
- Central Core (
sc_core
): Acts as the backbone for player data, core status effects, and orchestrates the main update ticks for other modules. It also handles the player spawn and death lifecycle. - Dependencies: Modules declare dependencies in their
fxmanifest.lua
.sc_core
is a central dependency for most. - Communication: Primarily through exports and some core events.
- Modules request data or trigger core actions (like updating status) via
sc_core
exports. - Modules provide their own specialized data/functionality to other modules via their own exports.
- Core events (e.g.,
PLAYER_DATA_LOADED
,PLAYER_TRUE_DEATH_EVENT
) allow modules to react to significant lifecycle changes.
- Modules request data or trigger core actions (like updating status) via
- Libraries:
ox_lib
will be leveraged across all modules for UI (notifications, progress bars, inputs), utilities, and logging.ox_target
will be used for world interactions. - Player Lifecycle:
- Player Connect →
sc_identity
(Character Selection/Creation). sc_identity
informssc_core
to initiate spawn.sc_core
(Spawn Logic) determines spawn point (New, Default, or Last Location after data load) and instructs client to spawn.sc_core
client spawns ped, informs server.sc_core
server loads all core survival data (player_survival_data
), then triggersPLAYER_DATA_LOADED
.- Other server modules (skills, inventory sections, etc.) load their specific data upon
PLAYER_DATA_LOADED
. sc_core
’s orchestration tick begins calling individual module ticks.- Player interacts with world (
ox_target
) → relevant client module → relevant server module → updates player data viasc_core
, item data viasc_inventory
, skills viasc_skill
. - Player Health <= 0 →
sc_core
(orsc_injury
) initiates “Incapacitated” state. Bleedout timer starts. - If not revived and timer expires (or player gives up) →
sc_core
triggersPLAYER_TRUE_DEATH_EVENT
. sc_core
handles item/skill loss (viasc_inventory
/sc_skill
) and initiates respawn at a hospital via its Spawn Logic.
- Player Connect →
I want to know is my project need anything else to complete?