diff --git a/client/main.lua b/client/main.lua index 3803462..2e87e52 100644 --- a/client/main.lua +++ b/client/main.lua @@ -8,8 +8,6 @@ local playerState = LocalPlayer.state ---@type table Injuries = {} -local BODY_PART_STATE_BAG_PREFIX = 'qbx_medical:injuries:' - for bodyPartKey in pairs(Config.BodyParts) do local bodyPartStateBag = BODY_PART_STATE_BAG_PREFIX .. bodyPartKey Injuries[bodyPartKey] = playerState[bodyPartStateBag] @@ -22,14 +20,14 @@ function SetInjury(bodyPartKey, severity) playerState:set(BODY_PART_STATE_BAG_PREFIX .. bodyPartKey, severity, true) end -BleedLevel = playerState['qbx_medical:bleedLevel'] or 0 +BleedLevel = playerState[BLEED_LEVEL_STATE_BAG] or 0 -AddStateBagChangeHandler('qbx_medical:bleedLevel', ('player:%s'):format(cache.serverId), function(_, _, value) +AddStateBagChangeHandler(BLEED_LEVEL_STATE_BAG, ('player:%s'):format(cache.serverId), function(_, _, value) BleedLevel = value end) function SetBleedLevel(level) - playerState:set('qbx_medical:bleedLevel', level, true) + playerState:set(BLEED_LEVEL_STATE_BAG, level, true) end BleedTickTimer, AdvanceBleedTimer = 0, 0 diff --git a/fxmanifest.lua b/fxmanifest.lua index e945d03..7364d79 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -11,7 +11,8 @@ shared_scripts { '@qbx_core/shared/locale.lua', 'locales/en.lua', 'locales/*.lua', - 'config.lua' + 'config.lua', + 'shared/**/*.lua', } client_scripts { diff --git a/server/main.lua b/server/main.lua index 2e3c37c..03b4512 100644 --- a/server/main.lua +++ b/server/main.lua @@ -16,9 +16,9 @@ local playerState AddEventHandler('QBCore:Server:OnPlayerLoaded', function() playerState = Player(source).state - playerState:set('qbx_medical:bleedLevel', 0, true) + playerState:set(BLEED_LEVEL_STATE_BAG, 0, true) for bodyPartKey in pairs(Config.BodyParts) do - playerState:set('qbx_medical:injuries:' .. bodyPartKey, nil, true) + playerState:set(BODY_PART_STATE_BAG_PREFIX .. bodyPartKey, nil, true) end end) diff --git a/shared/main.lua b/shared/main.lua new file mode 100644 index 0000000..992a9bf --- /dev/null +++ b/shared/main.lua @@ -0,0 +1,2 @@ +BODY_PART_STATE_BAG_PREFIX = 'qbx_medical:injuries:' +BLEED_LEVEL_STATE_BAG = 'qbx_medical:bleedLevel' \ No newline at end of file