-
-
Notifications
You must be signed in to change notification settings - Fork 410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adding "onElementHealthChange" event #3136
Comments
There is no need for that. U can overwrite lua defined function to trigger your own event. Just like this: _setElementHealth = setElementHealth
-- wrapper
function setElementHealth(element,newHealth)
_setElementHealth(element,newHealth)
triggerEvent("yourCustomEvent",element,newHealth)
end
--event somewhere else
local function handleElementHealthChange(newHealth)
--stub
end
addEvent("yourCustomEvent",true)
addEventHandler("yourCustomEvent",root,handleElementHealthChange) Each call to setElementHealth will result firing an event. |
or just call |
This is a wrong idea, events and exports are slower (and degrades performance more) compared to implementing it directly into MTA:SA. |
In this case is not much computing on Lua VM side but reaching to MTA API, exports can be slow by the manner of how their work but events used properly are not slow and its better to use them instead. Measure performance by yourself and u will find it out. |
Is your feature request related to a problem? Please describe.
When we
setElementHealth
to an element we should handle the eventonElementHealthChange
, but this event is not exist!we have problems with this when we're using
onPlayerDamage
oronPlayerWasted
on some features like respawn panel on player wasted, but when you use setElementHealth from another resource or a command you cant handle this with youre featureDescribe the solution you'd like
adding an event named
onElementHealthChange
(shared) handlingsetElementHealth
function.Describe alternatives you've considered
No response
Additional context
No response
Security Policy
The text was updated successfully, but these errors were encountered: