Cronoss Posted March 28, 2022 Share Posted March 28, 2022 I want to make a "damage system", but I just realized that I'm triggering a serverEvent everytime the player """"dies"""", the event only contains setPedAnimation So... i don't know if this is necessary, I know I could make the same system on server side using "onPlayerDamage"(that way I'm not triggering an event just for animation), but i want to optimize this as much as i can. function playerWasted(attacker, damage) local health = getElementHealth(localPlayer) or 1 if health - damage <= 1 then if getElementData(localPlayer, "wasted.player") ~= 1 then cancelEvent() setElementData(localPlayer, "wasted.player", 1, false) setElementFrozen(localPlayer, true) triggerServerEvent("wastedEvent", localPlayer, localPlayer) -- necessary? -- The final question is; I should make the script again on server side, or keep it like this?(client-side) ^ Link to comment
βurak Posted March 28, 2022 Share Posted March 28, 2022 actually everything looks right here, if you want to cancel this event, I say go to the client side, but the onPlayerDamage event cannot be canceled and will be ineffective when you animate the player, so your code looks correct, but you can delete the second localPlayer parameter in the triggerServerEvent, instead use the source inside the server event triggerServerEvent("wastedEvent", localPlayer) --use source on server side so no second localPlayer parameter is required 1 Link to comment
Cronoss Posted March 28, 2022 Author Share Posted March 28, 2022 In this case, I made the animation part in server-side so all the players can see the animation but for some reason the player can "cancel" the animation even if I set FALSE the interruptable part. What's the problem in this? setPedAnimation(source, "crack", "crckdeth1", -1, false, false, false, true) --should make it interruptable Link to comment
βurak Posted March 28, 2022 Share Posted March 28, 2022 try making the loop true --this setPedAnimation(source, "crack", "crckdeth1", -1, true, false, false, true) Link to comment
Cronoss Posted March 28, 2022 Author Share Posted March 28, 2022 Doesn't work, the animation still can be interrupted Link to comment
βurak Posted March 29, 2022 Share Posted March 29, 2022 (edited) what do you mean by interrupted? Edited March 29, 2022 by Burak5312 Link to comment
Cronoss Posted March 29, 2022 Author Share Posted March 29, 2022 If the player presses "shift" he can stop the animation and start moving, I want to freeze the player with that animation Link to comment
βurak Posted March 30, 2022 Share Posted March 30, 2022 (edited) I tested the code, as you said, it breaks the animation when the shift key is pressed, I'm not sure, but this may be a bug. Edited March 30, 2022 by Burak5312 Link to comment
Ayush Rathore Posted April 1, 2022 Share Posted April 1, 2022 (edited) What you can do is: On server side Make a temporary ped using event "wastedEvent". Make this ped have the same features of the player dieing (skin, rotation) etc. Make ped collison disabled. (makes ped free from damage from other elements) Set the alpha of player to 0 and make him froze. Perform the animation on the ped. Afterwards destroy ped and reset alpha on player respawn. Edited April 1, 2022 by Ayush Rathore 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