dima3367 Posted November 4, 2016 Share Posted November 4, 2016 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
iPrestege Posted November 4, 2016 Share Posted November 4, 2016 (edited) You can't cancel 'onPlayerDamage' Event so use : onClientPlayerDamage and check the data and use the attacker parameter to check the attacker if you want only players. Edited November 4, 2016 by FaHaD 1 Link to comment
Walid Posted November 4, 2016 Share Posted November 4, 2016 (edited) function onDmg() if getElementData(localPlayer,'_inJail') == true then cancelEvent() end end addEventHandler('onClientPlayerDamage',localPlayer,onDmg) Edited November 4, 2016 by Walid 2 Link to comment
dima3367 Posted November 4, 2016 Author Share Posted November 4, 2016 15 minutes ago, Walid said: function onDmg() if getElementData(localPlayer,'_inJail') == true then cancelEvent() end end addEventHandler('onClientPlayerDamage',localPlayer,onDmg) <div id="inner-editor"></div> the player will still take damage Link to comment
iPrestege Posted November 4, 2016 Share Posted November 4, 2016 2 minutes ago, dima3367 said: <div id="inner-editor"></div> the player will still take damage Are you sure it's a client side ? and the player have data? 1 Link to comment
dima3367 Posted November 4, 2016 Author Share Posted November 4, 2016 One moment please Link to comment
Walid Posted November 4, 2016 Share Posted November 4, 2016 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 1 Link to comment
dima3367 Posted November 4, 2016 Author Share Posted November 4, 2016 Thank you very much for your help, everything turned out! Keep my likes to your posts! Link to comment
Walid Posted November 4, 2016 Share Posted November 4, 2016 1 minute ago, dima3367 said: Thank you very much for your help, everything turned out! Keep my likes to your posts! You're welcome. 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