Skip to content

Commit

Permalink
Prop drilling attacker and weapon data to event triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
JHansen2000 committed Jul 24, 2024
1 parent 8095703 commit 838b064
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
11 changes: 5 additions & 6 deletions client/dead.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ end
exports('PlayDeadAnimation', playDeadAnimation)

---put player in death animation and make invincible
function OnDeath()
function OnDeath(attacker, weapon)
SetDeathState(sharedConfig.deathState.DEAD)
TriggerEvent('qbx_medical:client:onPlayerDied')
TriggerServerEvent('qbx_medical:server:onPlayerDied')
TriggerEvent('qbx_medical:client:onPlayerDied', attacker, weapon)
TriggerServerEvent('qbx_medical:server:onPlayerDied', attacker, weapon)
TriggerServerEvent('InteractSound_SV:PlayOnSource', 'demo', 0.1)

WaitForPlayerToStopMoving()
Expand Down Expand Up @@ -118,14 +118,13 @@ AddEventHandler('gameEventTriggered', function(event, data)
if not IsEntityAPed(victim) or not victimDied or NetworkGetPlayerIndexFromPed(victim) ~= cache.playerId or not IsEntityDead(cache.ped) then return end
if DeathState == sharedConfig.deathState.ALIVE then
Wait(1000)
StartLastStand()
StartLastStand(attacker, weapon)
elseif DeathState == sharedConfig.deathState.LAST_STAND then
EndLastStand()
logDeath(victim, attacker, weapon)
DeathTime = config.deathTime
OnDeath()
OnDeath(attacker, weapon)
end
TriggerEvent('qbx_medical:client:attackerData', attacker, weapon)
end)

function DisableControls()
Expand Down
6 changes: 3 additions & 3 deletions client/laststand.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ local function countdownLastStand()
end

---put player in last stand mode and notify EMS.
function StartLastStand()
function StartLastStand(attacker, weapon)
TriggerEvent('ox_inventory:disarm', cache.playerId, true)
WaitForPlayerToStopMoving()
TriggerServerEvent('InteractSound_SV:PlayOnSource', 'demo', 0.1)
LaststandTime = config.laststandReviveInterval
ResurrectPlayer()
SetEntityHealth(cache.ped, 150)
SetDeathState(sharedConfig.deathState.LAST_STAND)
TriggerEvent('qbx_medical:client:onPlayerLaststand')
TriggerServerEvent('qbx_medical:server:onPlayerLaststand')
TriggerEvent('qbx_medical:client:onPlayerLaststand', attacker, weapon)
TriggerServerEvent('qbx_medical:server:onPlayerLaststand', attacker, weapon)
CreateThread(function()
while DeathState == sharedConfig.deathState.LAST_STAND do
countdownLastStand()
Expand Down

0 comments on commit 838b064

Please sign in to comment.