Skip to content

Commit

Permalink
refactor: logDeath
Browse files Browse the repository at this point in the history
* refactor: logDeath

* fix: logging

* fix: placement

* fix: making berkie happy
  • Loading branch information
mafewtm authored Feb 12, 2024
1 parent e57c31c commit a6e4de9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
8 changes: 4 additions & 4 deletions client/dead.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ function OnDeath()
TriggerEvent('qbx_medical:client:onPlayerDied')
TriggerServerEvent('qbx_medical:server:onPlayerDied')
TriggerServerEvent('InteractSound_SV:PlayOnSource', 'demo', 0.1)
local player = cache.ped

WaitForPlayerToStopMoving()

Expand All @@ -42,8 +41,8 @@ function OnDeath()

ResurrectPlayer()
playDeadAnimation()
SetEntityInvincible(player, true)
SetEntityHealth(player, GetEntityMaxHealth(player))
SetEntityInvincible(cache.ped, true)
SetEntityHealth(cache.ped, GetEntityMaxHealth(cache.ped))
end

exports('killPlayer', OnDeath)
Expand Down Expand Up @@ -98,7 +97,8 @@ local function logDeath(victim, attacker, weapon)
local killerName = GetPlayerName(killerId) .. ' ' .. '(' .. GetPlayerServerId(killerId) .. ')' or Lang:t('info.self_death')
local weaponLabel = WEAPONS[weapon].label or 'Unknown'
local weaponName = WEAPONS[weapon].name or 'Unknown'
TriggerServerEvent('qb-log:server:CreateLog', 'death', Lang:t('logs.death_log_title', { playername = playerName, playerid = GetPlayerServerId(playerId) }), 'red', Lang:t('logs.death_log_message', { killername = killerName, playername = playerName, weaponlabel = weaponLabel, weaponname = weaponName }))
local message = Lang:t('logs.death_log_message', { killername = killerName, playername = playerName, weaponlabel = weaponLabel, weaponname = weaponName })
lib.callback.await('qbx_medical:server:logDeath', false, message)
end

---when player is killed by another player, set last stand mode, or if already in last stand mode, set player to dead mode.
Expand Down
2 changes: 1 addition & 1 deletion config/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ return {
[weaponClasses.CUTTING] = true,
[weaponClasses.WILDLIFE] = false,
},

alwaysBleedChance = 70, -- Set the chance out of 100 that if a player is hit with a weapon, that also has a random chance, it will cause bleeding

---@type table<number, string>
Expand Down
5 changes: 5 additions & 0 deletions server/main.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local sharedConfig = require 'config.shared'
local logger = require '@qbx_core.modules.logger'

---@class Injury
---@field severity integer
Expand Down Expand Up @@ -183,3 +184,7 @@ lib.callback.register('qbx_medical:server:respawn', function(source)
TriggerEvent('qbx_medical:server:playerRespawned', source)
return true
end)

lib.callback.register('qbx_medical:server:logDeath', function(_, message)
logger.log({source = 'qbx_medical', event = 'logDeath', message = message})
end)

0 comments on commit a6e4de9

Please sign in to comment.