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


Author Topic: Hit Effect  (Read 1071 times)

0 Members and 1 Guest are viewing this topic.

Offline Ming

  • Full Member
  • ***
  • Posts: 154
  • Gender: Male
  • 抽刀斷水水更流,舉杯消愁愁更愁
    • View Profile
Hit Effect
« on: July 05, 2021, 04:20:54 PM »
Code: [Select]
HitEffect = function()
 for NPC,Ped in {PedFindInAreaXYZ(0, 0, 0, 99999)} do
  if PedIsHit(Ped) and PedIsValid(Ped) then
   local hX, hY, hZ = PedGetHeadPos(Ped)
   local Effect1 = EffectCreate("GymLightSmash", hX, hY, hZ)
   EffectSlowKill(Effect1, 0.7)
  end
  Wait(0)
 end
end
Why sometimes there is no trigger effect when Ped is attacked
« Last Edit: July 05, 2021, 04:24:04 PM by Ming »

Offline SimonBestia

  • Full Member
  • ***
  • Posts: 293
  • Gender: Male
  • Bully-Board's Best Weeb
    • View Profile
    • Youtube Channel
Re: Hit Effect
« Reply #1 on: July 06, 2021, 05:55:05 AM »
Your code as-is doesn't work at all for me.
It just runs once and then stops working.

You want to put it in a loop and remove that "Wait(0)" from the for statement. I've never seen it used there.
Code: [Select]
while true do
for NPC,Ped in {PedFindInAreaXYZ(0, 0, 0, 99999)} do
if PedIsHit(Ped) and PedIsValid(Ped) then
local hX, hY, hZ = PedGetHeadPos(Ped)
local Effect1 = EffectCreate("GymLightSmash", hX, hY, hZ)
EffectSlowKill(Effect1, 0.7)
end
end
Wait(0)
end
This works fine.

Offline Ming

  • Full Member
  • ***
  • Posts: 154
  • Gender: Male
  • 抽刀斷水水更流,舉杯消愁愁更愁
    • View Profile
Re: Hit Effect
« Reply #2 on: July 07, 2021, 09:12:21 AM »
Your code as-is doesn't work at all for me.
It just runs once and then stops working.

You want to put it in a loop and remove that "Wait(0)" from the for statement. I've never seen it used there.
Code: [Select]
while true do
for NPC,Ped in {PedFindInAreaXYZ(0, 0, 0, 99999)} do
if PedIsHit(Ped) and PedIsValid(Ped) then
local hX, hY, hZ = PedGetHeadPos(Ped)
local Effect1 = EffectCreate("GymLightSmash", hX, hY, hZ)
EffectSlowKill(Effect1, 0.7)
end
end
Wait(0)
end
This works fine.
Thank you so much