Jump to content

onClientObjectDamage


kasya85

Recommended Posts

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
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

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

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...