BorderLine Posted November 26, 2011 Share Posted November 26, 2011 hi all well more than a code i want know why when i active godmode zombies can hitme and low my health i mean he cause damage i need other fuction? like canceldamage? thanks so much Link to comment
Castillo Posted November 26, 2011 Share Posted November 26, 2011 That's because zombies use setElementHealth, that cannot be canceled, so you have to do this: addEventHandler("onClientPlayerDamage",root, function () setElementHealth(source,100) end) Link to comment
BorderLine Posted November 26, 2011 Author Share Posted November 26, 2011 ah.. ok.. but if my health is for example 50 health if i toogle AFK my health will be 100 again? Link to comment
BorderLine Posted November 26, 2011 Author Share Posted November 26, 2011 and exist some fuction for freeze your health. i mean.. if some player have 1 health just he will be afk and his health will be 100 again . i was searching but i found nothing Link to comment
12p Posted November 26, 2011 Share Posted November 26, 2011 onClientPlayerDamage ==> cancelEvent Link to comment
Castillo Posted November 26, 2011 Share Posted November 26, 2011 Benxamix, onClientPlayerDamage doesn't cancel the setElementHealth function. Link to comment
AGENT_STEELMEAT Posted November 26, 2011 Share Posted November 26, 2011 Em, yes it does... Link to comment
12p Posted November 26, 2011 Share Posted November 26, 2011 Yes it does. Tested with "zombies" resource (do you remember I told you a long time ago about "AC#1" kicking me when a zombie was punching me? It was cancelEvent() applied to onClientPlayerDamage ) Link to comment
Castillo Posted November 26, 2011 Share Posted November 26, 2011 (edited) If it does, then why is a zombie taking my health when I executed this via runcode: addEventHandler("onClientPlayerDamage",getRootElement(), function () cancelEvent() end) Edited November 26, 2011 by Guest Link to comment
AGENT_STEELMEAT Posted November 26, 2011 Share Posted November 26, 2011 I just did the same and it cancelled just fine 0.o Link to comment
12p Posted November 26, 2011 Share Posted November 26, 2011 (edited) "runcode" works client-side too? Didn't know it, damnit. Edited November 26, 2011 by Guest Link to comment
Castillo Posted November 26, 2011 Share Posted November 26, 2011 Yes, it does, /crun /run /srun. P.S: How is possible to work for one but not for other? , what version of MTA are you using John? Link to comment
12p Posted November 26, 2011 Share Posted November 26, 2011 (edited) Edit: onPlayerDamage is triggered when you do setElementHealth though. onPlayerDamage cannot be cancelled. You edited wrong lol (or maybe you used onPlayerDamage at runcode and failed?) Edited November 26, 2011 by Guest Link to comment
AGENT_STEELMEAT Posted November 26, 2011 Share Posted November 26, 2011 I think its just when the zombies punch normally, that can be cancelled, but manual calls on setElementHealth aren't. Link to comment
12p Posted November 26, 2011 Share Posted November 26, 2011 (edited) It did at MTA 1.0.4. The effect cancel of setElementHealth made my player to be kicked out due to AntiCheat #1 So I say "IT SHOULD WORK WITH setElementHealth". Cannot try zombies resource atm, I'll do later (in about 11 hours ) Edited November 26, 2011 by Guest Link to comment
Castillo Posted November 26, 2011 Share Posted November 26, 2011 Edit: onPlayerDamage is triggered when you do setElementHealth though. onPlayerDamage cannot be cancelled. You edited wrong lol (or maybe you used onPlayerDamage at runcode and failed?) I just said that onPlayerDamage is triggered with setElementHealth, I know that it cannot be cancelled. Link to comment
12p Posted November 26, 2011 Share Posted November 26, 2011 I just said that onPlayerDamage is triggered with setElementHealth, I know that it cannot be cancelled. What the... You first spoke about onClientPlayerDamage, then about onPlayerDamage. For me it doesn't make much sense... Nvm. Link to comment
Castillo Posted November 26, 2011 Share Posted November 26, 2011 Look, I'm just saying that when a zombie punchs me it still takes my health, even when I've cancelled it. Forget about onPlayerDamage. Link to comment
AGENT_STEELMEAT Posted November 26, 2011 Share Posted November 26, 2011 There is a bug with onClientPlayerDamage anyways, it seems sometimes cancelEvent() works, and other times it doesn't. Link to comment
Spanish4Life Posted November 26, 2011 Share Posted November 26, 2011 (edited) (error) Edited November 26, 2011 by Guest Link to comment
Spanish4Life Posted November 26, 2011 Share Posted November 26, 2011 addEventHandler("onClientPlayerDamage",root, function () local health = getElementHealth(source) setElementHealth(source,health) end) Link to comment
AGENT_STEELMEAT Posted November 26, 2011 Share Posted November 26, 2011 What the hell is that? Link to comment
Jaysds1 Posted November 26, 2011 Share Posted November 26, 2011 if the player is afk, then when they get shot or hit at, it sets their health back to what it was before. Link to comment
AGENT_STEELMEAT Posted November 26, 2011 Share Posted November 26, 2011 No, it just sets it to the current health (nothing is cancelled). 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