kasya85 Posted July 10, 2017 Share Posted July 10, 2017 onClientObjectDamage is the client-side event, but for some reason when a player damage the object it is triggered for all players WHY? my code: function outputLoss(loss, attaker) if getPedWeapon (attaker ) == 0 and getElementType ( source ) == "object" and getElementModel ( source ) == 1985 then --action end end addEventHandler("onClientObjectDamage",root, outputLoss) Link to comment
Amine#TN Posted July 10, 2017 Share Posted July 10, 2017 post the full code we cant help you like that we need that "action" Link to comment
Gordon_G Posted July 10, 2017 Share Posted July 10, 2017 function outputLoss(loss, attaker) if getPedWeapon ( localPlayer ) == 0 and getElementType ( source ) == "object" and getElementModel ( source ) == 1985 then --action end end addEventHandler("onClientObjectDamage", localPlayer, outputLoss) Try this Link to comment
pa3ck Posted July 11, 2017 Share Posted July 11, 2017 There are good few client side events that will be triggered to every client, not just one. Most of the time, there's an element coming from source or a parameter which let's you restrict the event to a single client. function outputLoss(loss, attaker) -- check if the 'attaker' is the localPlayer, it will only run for the attacker, AKA the client who is damaging the object if attaker == localPlayer and getPedWeapon (attaker ) == 0 and getElementType ( source ) == "object" and getElementModel ( source ) == 1985 then --action end end addEventHandler("onClientObjectDamage",root, outputLoss) Link to comment
Gordon_G Posted July 11, 2017 Share Posted July 11, 2017 Oh, yes, I was wrong. I've written that because I added the event "onClientObjectDamage" by triggering from server. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now