crazyde21 Posted March 7, 2014 Posted March 7, 2014 When the player hurt myself , Then how cancel event? Was someone else kill you!
xXMADEXx Posted March 7, 2014 Posted March 7, 2014 Use onClientPlayerDamage, and cancelEvent() The Ultimate Lua Tutorial! | MTA PHP SDK
crazyde21 Posted March 7, 2014 Author Posted March 7, 2014 onClientPlayerDamage when i Fall down, I always death!
WASSIm. Posted March 7, 2014 Posted March 7, 2014 addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), function (attacker) if (not attacker) or ( attacker and not attacker == source) then cancelEvent() end end)
crazyde21 Posted March 7, 2014 Author Posted March 7, 2014 function stopDamage ( att ) target = getPedTarget ( att ) local typename =getElementType(target) if typename == "player" then cancelEvent() end end addEventHandler ( "onClientPlayerDamage", getRootElement(), stopDamage ) Have hurt,too!
crazyde21 Posted March 7, 2014 Author Posted March 7, 2014 function stopDamage () if getElementType(source) == "player" then cancelEvent() end end addEventHandler ( "onClientPlayerDamage", getLocalPlayer(), stopDamage ) this ok!
Moderators IIYAMA Posted March 7, 2014 Moderators Posted March 7, 2014 Why are you checking a player it's element-type, when you already know it is a player? "onClientPlayerDamage" Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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