Jump to content

Receive damage


dima3367

Recommended Posts

Hello everybody!
I did the prison system. But players can get out of it if you die.
I did this test here of the fact that the player would not receive damage:
function onDmg()
	if getElementData(source,'_inJail') == true then
		cancelEvent()
	end
end
addEventHandler('onPlayerDamage',root,onDmg)

But the player still takes damage from another player

How to fix it?

Sorry for my bad english

 
 
 
Link to comment

 

1 minute ago, dima3367 said:

One moment please

Here is a very simple way to debug your code.

-- debug 
function onDmg()
    if isPlayerInJail(localPlayer) then
        outputChatBox("Yes it's") -- if you can't see this message in your chat box then you need to check if the element data ("_inJail") exist or not.
        cancelEvent()
    end
end
addEventHandler('onClientPlayerDamage',localPlayer,onDmg)

-- check if the player is in jail
function isPlayerInJail(player)
    if player and isElement(player) then
        local returns = getElementData(player,"_inJail") and true or false
        return returns
    end 
    return false
end 

 

  • Like 1
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...