roaddog Posted May 4, 2014 Share Posted May 4, 2014 Hi all I got a problem with this medic job script, I want to make that medic will stop getting money from healing players when players already have 100% of health. so here the script edit : if i hit player who has 100% health. first hit I aint getting money, second hit the player lost hp, and third hit the player get healed again. function healPlayerOnHit_Handler(theAttacker, theWeapon, theBodyPart, theLoss) if(getElementType(theAttacker) == "player") then if(theWeapon == 14) and (getElementHealth(source) < 95) then cancelEvent() local targetCurrentHealth = getElementHealth(source) local newHealth = targetCurrentHealth+15 setElementHealth(source, newHealth) givePlayerMoney(theAttacker, 1.7*newHealth) end end end addEventHandler("onPlayerDamage", getRootElement(), healPlayerOnHit_Handler) I hope you understand what I wanna do, Thank you. Link to comment
LonelyRoad Posted May 4, 2014 Share Posted May 4, 2014 Doing cancelEvent() on the server-side event onPlayerDamage has no effect, see the wiki page. Read the 'Cancel Effect' section of OnClientPlayerDamage. What you probably want to do is set element data on 'theAttacker' to indicate he is a medic when they accept the medic job, then on the client side you should do your cancelEvent() and call the server function with your own event using addEvent and addEventHandler. 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