Body Damage

Damage System API - LVS Inventory

GetPlayerDamage()

Retrieves the current damage state of the player by body parts.

Description

Returns an object containing damage data for 6 main body zones, providing a simplified structure for external use.

Syntax

local damageData = exports['lvs_inventory']:GetPlayerDamage()

Return Value

Type: table

Object with the following properties:

  • head (table): Head damage data

  • torso (table): Upper torso damage data

  • leftArm (table): Left arm damage data

  • rightArm (table): Right arm damage data

  • leftLeg (table): Left leg damage data

  • rightLeg (table): Right leg damage data

Each body part contains:

  • percent (number): Accumulated damage percentage (0-100)

  • bullets (number): Number of bullet impacts received

  • severity (boolean): Indicates if damage is severe

  • broken (boolean): Indicates broken bones

  • bleeding (boolean): Indicates if the zone is bleeding

Example


UpdatePlayerDamage()

Updates damage for a specific body part and notifies linked systems.

Description

This function allows manual modification of the damage state for a specific body zone. It registers bullet impacts, updates damage percentage, and maintains negative states (severity, fractures, bleeding).

Syntax

Parameters

Parameter
Type
Description

bodyPart

string

Body part to update. Valid values: head, torso, leftArm, rightArm, leftLeg, rightLeg

bulletCount

number

Number of bullet impacts to register (typically 1 per impact)

newPercent

number

New damage percentage (0-100)

severity

boolean

Indicates if damage is severe

broken

boolean

Indicates broken bones

bleeding

boolean

Indicates if the zone is bleeding

Behavior

  • If bodyPart is invalid, defaults to torso

  • Bullet impacts are accumulated to the existing counter

  • Damage percentage is replaced with the new value

  • Negative states are preserved if they already existed

  • Automatically saves data to the server

  • Triggers the lvs_injury:client:UpdatePlayerDamage event to notify other scripts

Example

Notes

  • This function is used internally by the system when a player takes damage

  • Can be used externally to apply custom damage or synchronize states

  • Changes are automatically persisted to the database


lvs_injury:client:UpdatePlayerDamage

Triggered whenever player damage is updated.

Parameters:

  • BodyParts (table): Complete table with all body parts state

lvs_injury:client:ResetPlayerDamage

Triggered when player damage is reset (e.g., after being revived).


Common Use Cases

Check player condition

Apply fall damage


Medical treatment system example

Last updated