Jump to content

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


Pirulax

Recommended Posts

  • Discord Moderators
Posted

So, i want to create a dead system, and i need 1 thing, and that is: cancelling the camera shake effect when the player dies..

And i want to reanimate the player when i use SetElementHealth(...) 

I already tried setCameraTarget() but not worked..

Thanks in advance.

Posted

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 :) 

  • Discord Moderators
Posted
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
Posted

shake effect, so you'll be able to set your own camera, make it zoom out, or make it zoom in :3 also if you want no screen at all you can just fadeCamera :) 

  • Discord Moderators
Posted
Just now, kieran said:

Have you made your own script?

Will made it tomorrow..

Posted

:/ 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 

  • Discord Moderators
Posted
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.

Posted (edited)
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
  • Discord Moderators
Posted (edited)

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
Posted (edited)

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
  • Discord Moderators
Posted
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.

Posted

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.

  • Like 2
Posted (edited)
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
  • Discord Moderators
Posted

Figured anything out, the topic can be closed.Need to create a script.Btw i want to use it for RP server

 

Posted

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?

  • Like 1
  • Discord Moderators
Posted
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....

Posted
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
  • Discord Moderators
Posted
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.

Posted
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

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...