Jump to content

is the "onPedDamage" event working? ?


Recommended Posts

Posted (edited)

onPedDamage

dealing damage to the ped triggers a function where if the ped is below 10 health, the ped's health returns to 100 and armor is added to 100.

but my code doesn't work that's why i ask

1 hour ago, Mr.Hugin said:

What are you working on?

You have two types of this, but what do you want to do?

I did not understand what you mean


onPedDamage 

 

onPlayerDamage

read above

Edited by TheBossCl
  • Scripting Moderators
Posted

Moving this into the Scripting section. Please use this section in the future.

onPedDamage is not registered by default. You need to use addEvent first to register it.
 

  • Thanks 1
Posted
13 hours ago, TheBossCl said:

onPedDamage

dealing damage to the ped triggers a function where if the ped is below 10 health, the ped's health returns to 100 and armor is added to 100.

but my code doesn't work that's why i ask

read above

This can be done by adding an event and onPedDamage

 

Do you want damage from the side of the weapon or the vehicle?

 

  • Thanks 1
Posted
function damageController(loss)
    local heal = getElementHealth(source) - loss
	
    if heal <= 10 then
      setElementHealth(source,100)
      setPedArmor(source,100)
    end
end
addEventHandler("onPedDamage", root, damageController)

Perhaps you need this ?

  • Thanks 1
Posted (edited)
On 5/26/2022 at 4:48 AM, xLive said:

Moving this into the Scripting section. Please use this section in the future.

onPedDamage is not registered by default. You need to use addEvent first to register it.
 

Thank you very much, works :)

On 5/26/2022 at 4:29 PM, shishani said:
function damageController(loss)
    local heal = getElementHealth(source) - loss
	
    if heal <= 10 then
      setElementHealth(source,100)
      setPedArmor(source,100)
    end
end
addEventHandler("onPedDamage", root, damageController)

Perhaps you need this ?

yeah it works :)

Edited by TheBossCl

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...