Cronoss Posted February 6, 2022 Share Posted February 6, 2022 (edited) Hello, I've been making a respawn-system, and I noticed that my script doesn't work because if the player gets critical damage ( 0 HP) , the system doesn't recognize his health under 0 and the wasted animation from the original gamemodes starts. ( I DON'T want the player to die in THIS specific function, I want to set the player frozen and start a death animation to simulate his/her death ) I don't know how to make my system to detect exactly the 1HP and stop the player's death. Is it possible? Code, serverside: function respawn() health = getElementHealth(source) if not (health>=2) then --------------- I'll add a "death animation" here. outputChatBox("", source, 255, 0, 0) setTimer(function () reanimate = 1 outputChatBox("", source, 255, 0, 0) end, 600, 1) end addEventHandler("onPlayerDamage", root, respawn) Note: I edited the code (from Spanish to English) so you can understand what I made Note 2: I don't want the full code as a answer, I want to know if is it possible to make what I say and what "commands" I could use Edited February 6, 2022 by Cronoss Link to comment
Mkl Posted February 6, 2022 Share Posted February 6, 2022 (edited) Hello, First I think you should use prefix local for health variable to make it working only in the scope of your function. I'm wondering if you could use onPlayerWasted instead, cancel the event (if it's cancellable) and set a custom animation ? Edited February 6, 2022 by Mkl Link to comment
Cronoss Posted February 6, 2022 Author Share Posted February 6, 2022 Quote I'm wondering if you could use onPlayerWasted instead, cancel the event (if it's cancellable) and set a custom animation ? I don't want the player to die instantly, I'm trying to make a system that frozen the player with the "death animation", so the player keeps in that place and can't move for indefinite time I want to use "onPlayerWasted" for respawn, because if the player gets one more hit when he gets the "death system", he respawns and doesn't follow the "death-system" rules Link to comment
marcelluss Posted February 6, 2022 Share Posted February 6, 2022 (edited) 27 minutes ago, Cronoss said: I don't want the player to die instantly, I'm trying to make a system that frozen the player with the "death animation", so the player keeps in that place and can't move for indefinite time I want to use "onPlayerWasted" for respawn, because if the player gets one more hit when he gets the "death system", he respawns and doesn't follow the "death-system" rules you can determine the state of the player's life every time in the onClientRender render and make a check if the player has less than 1 hp, then constantly install 1 hp for him and set animation for him. this is a crutch option Edited February 6, 2022 by marcelluss Link to comment
Mkl Posted February 6, 2022 Share Posted February 6, 2022 (edited) I found out you can do something like this : addEventHandler("onClientPlayerDamage", root, function(attacker, damage) local health = getElementHealth(localPlayer) if (health - damage) < 1 then cancelEvent() setElementHealth(localPlayer, 1) -- your stuff (setElementFrozen() etc...) end end ) tested in-game. When the player recieves damage, if damage set health below 1, you cancel the event and you set 1 health point to the player. After this you can freeze him and set an animation. To really kill him, just need to use setElementHealth(localPlayer, 0). Edited February 6, 2022 by Mkl 1 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