Jump to content

Canceling camera shake effect onPlayerWasted, and reanimating the player when SetElementHealth() hp.


Pirulax

Recommended Posts

No, SetCameraTarget only sets a target for the camera, SetCameraMatrix will set the position of the camera, this giving the possibility to stop swaying when you die, have a look at this tutorial I found on YouTube, it is for a login panel, but much the same idea, instead just get the players x, y and z when he dies :) 

Link to comment
  • Discord Moderators
20 minutes ago, kieran said:

No, SetCameraTarget only sets a target for the camera, SetCameraMatrix will set the position of the camera, this giving the possibility to stop swaying when you die, have a look at this tutorial I found on YouTube, it is for a login panel, but much the same idea, instead just get the players x, y and z when he dies :) 

are you talking about canceling the shake effect, or the dead thing?

 

  • Like 1
Link to comment

:/ so how can it already be on a event?  The way I understand it is that if you set the camera matrix of a player and put the onPlayerWasted handler on the function your camera will be set to that exact position as it would (in theory) over ride the original respawnPlayer....  Just try it and see what happens, kinda hard with no script or explanation to how you made the script. :P 

Link to comment
  • Discord Moderators
7 hours ago, kieran said:

:/ so how can it already be on a event?  The way I understand it is that if you set the camera matrix of a player and put the onPlayerWasted handler on the function your camera will be set to that exact position as it would (in theory) over ride the original respawnPlayer....  Just try it and see what happens, kinda hard with no script or explanation to how you made the script. :P 

I said that the original respawnPlayer camera shake is on onClientPreRender..and setCameraMatrix will work only for 1 frame.

Link to comment
2 hours ago, Pirulax said:

I said that the original respawnPlayer camera shake is on onClientPreRender..and setCameraMatrix will work only for 1 frame.

What are you talking about? Nowhere on the wiki does it say that it lasts for only one frame. Even the example is done with onPlayerJoin and not onClientRender :)

And you can try to make a different function which sets the camera matrix how you want it and then just do 'addEventHandler("onPlayerWasted", root, cameraFunc)' in the preRender function. Worth a try, give code xD it's hard like this...

Edited by koragg
Link to comment
  • Discord Moderators

Did u read what i said?The original camera shaking is handled with onClientPreRender, and if i use setCameraMatrix than the camera will look at the position for only 1 frame...And then the original camera shaking will overwrite the position.

Edited by Pirulax
Link to comment

https://wiki.multitheftauto.com/wiki/OnClientPreRender

The example says it follows the player in a GTA2 way, so doesn't that mean that it's called every frame? Anyway here's an idea:

function setNewCameraTarget()
	setCameraMatrix(1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316)
	-- obviosly change the numbers to the position you want^
end


function onPlayerWasted() -- default shake camera function
	--blablabla
	addEventHandler("onClientRender", root, setNewCameraTarget) -- you force it to use your camera spot on every frame
end
addEventHandler("onClientPreRender", root, onPlayerWasted)

 

Edited by koragg
Link to comment
  • Discord Moderators
1 minute ago, Uknown. said:

What about using fadeCamera so the player cannot see anything? :P

Off topic.. i want to cancel the camera shake, and not to fade the players camera.

Link to comment
local deathX, deathY, deathZ

function onPWasted()
  if source == localPlayer then
    deathX, deathY, deatZ = getElementPosition(localPlayer)
    addEventHandler("onClientPreRender", root, renderPedWasted)
  end
end
addEventHandler("onClientPedWasted", root, onPWasted)

function renderPedWasted()
  setCameraMatrix(deathX + 2, deathY + 2, deathZ + 15, deathX, deathY, deathZ)
end

function onPSpawned()
  if source == localPlayer and deathX then
    removeEventHandler("onClientPreRender", root, renderPedWasted)
    deathX, deathY, deathZ = nil, nil, nil
  end
end
addEventHandler("onClientPlayerSpawn", root, onPSpawned)

Try this, not tested.. use debugscript to fix any problems that might occur, if you can't fix it, come back with the results / errors.

 

Never use setElementHealth to spawn a player after death.

Edited by pa3ck
Link to comment
  • Discord Moderators
11 hours ago, pa3ck said:

You just realized that you'll need to create a script? Wow, you thought if you concentrate really hard MTA will be able to do it for you without any code?

Yey, off topic... you are so funny....

Link to comment
12 minutes ago, Pirulax said:

Yey, off topic... you are so funny....

You're one of those guys who want everything done by somebody else. Read the rules of the section, take a course in good manners and maybe try to make something yourself. Good luck. 

  • Like 1
Link to comment
  • Discord Moderators
4 minutes ago, koragg said:

You're one of those guys who want everything done by somebody else. Read the rules of the section, take a course in good manners and maybe try to make something yourself. Good luck. 

Did i mention somehwere that i want done scripts?I dont think so, i  just wanted a function, a freaking in-built MTA function for it.. if theres no in-built function, than okey, i will write a lua one, and thats it... i didnt mention that i want a full script... omg

21 hours ago, Uknown. said:

There's no way to do it with 0 health. Just make a client render and check if health goes under 1 make it 1 and when it's one put the wasted animation and done.

Lol, good idea :D And freeze the player + anim, and thats it.

Link to comment
1 hour ago, Pirulax said:

Did i mention somehwere that i want done scripts?I dont think so, i  just wanted a function, a freaking in-built MTA function for it.. if theres no in-built function, than okey, i will write a lua one, and thats it... i didnt mention that i want a full script... omg

Lol, good idea :D And freeze the player + anim, and thats it.

No like to my reply then :v?

  • Like 1
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...