News: Welcome back to Bullworth! If you haven't already, you will need to reset your password..


Author Topic: check Ped is hit or not  (Read 670 times)

0 Members and 1 Guest are viewing this topic.

Offline Ming

  • Full Member
  • ***
  • Posts: 154
  • Gender: Male
  • 抽刀斷水水更流,舉杯消愁愁更愁
    • View Profile
check Ped is hit or not
« on: May 11, 2022, 11:28:47 PM »
Code: [Select]

Check = function()
  while true do
    if FrontPedIsHitByPlayer() then
      PedApplyDamage(PlayerHitPed, 10000000)
    end
    Wait (0)
  end
end

HealthRecords = function()
  while true do
    if IsInTable(AllPedHealth, Ped) then
      AllPedHealth[InTableIndex(AllPedHealth, Ped) + 1] = PedGetHealth(Ped)
    else
      table.insert(Ped)
      table.insert(PedGetHealth(Ped))
    end
    Wait(0)
  end
end

FrontPedIsHitByPlayer = function()
  for NPC, Ped in {PedFindInAreaXYZ(0, 0, 0, 99999)} do
    if IsInTable(AllPedHealth, Ped) and PedGetHealth(Ped) ~= AllPedHealth[InTableIndex(AllPedHealth, Ped) + 1] and PedGetWhoHitMeLast(Ped) == gPlayer and Ped ~= gPlayer then
      PlayerHitPed = Ped
      return true
    end
  end
  return false
end
I want to check ped is hit by player or not, but it doesn't work, I use PedIsHit(), but after the Ped is grabbed, PedIsHit is invalid