Bully-Board

Bully Modding Section => Modding Questions/Help => Topic started by: Ming on July 05, 2021, 04:20:54 PM

Title: Hit Effect
Post by: Ming 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
Title: Re: Hit Effect
Post by: SimonBestia 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.
Title: Re: Hit Effect
Post by: Ming 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