Jump to content

Drop Camera


iNetz

Recommended Posts

Hello - I'm currently working on a simple gamemode, and i've encountered a problem.

I want the local player's camera to drop when he dies - meaning it should remain static by the player's last coordinates, but it somehow bugs when the player dies and is in a vehicle. Somehow setCameraMatrix( getCameraMatrix() ) turns ineffective.

I've tried destroying the vehicle and setting the camera matrix when the event "onClientPlayerWasted" is triggered.. but nothing.. it still follows either the player or the vehicle, and after some time the "wasted" animation starts.

I'd really appreciate any help.

Thanks.

Link to comment
So, you are trying to make a kill-cam type of script to watch the killer?

Yes, but first I want to give it some time until the camera target is set.

Try creating your own Function for the Camera to Drop:

"function freecamFrame"

That's what I've tried to do with setCameraMatrix ( getCameraMatrix () ), what are you suggesting?

Link to comment

It's actually a quite big piece of code, but related to the camera would only be:

  
function onClientWasted () 
dropCamera () 
end 
addEventHandler ( "onClientPlayerWasted", localPlayer, onClientWasted ) 
  
function dropCamera () 
setCameraMatrix (getCameraMatrix()) 
-- I've also tried using 
-- setTimer ( setCameraMatrix, 50, 10, getCameraMatrix() ) 
end 
  

Link to comment

One little script, that makes your day ( I hope );

addEventHandler ( "onClientPlayerWasted", root, 
    function ( thePlayer ) 
        if ( isPedInVehicle ( thePlayer ) ) then 
            removePedFromVehicle ( thePlayer ); 
        end 
        local x, y, z, lookx, looky, lookz = getCameraMatrix(); 
        setCameraMatrix ( x, y, z, lookx, looky, lookz ); 
    end 
); 

Link to comment
One little script, that makes your day ( I hope );
addEventHandler ( "onClientPlayerWasted", root, 
    function ( thePlayer ) 
        if ( isPedInVehicle ( thePlayer ) ) then 
            removePedFromVehicle ( thePlayer ); 
        end 
        local x, y, z, lookx, looky, lookz = getCameraMatrix(); 
        setCameraMatrix ( x, y, z, lookx, looky, lookz ); 
    end 
); 

I've change it to:

addEventHandler ( "onClientPlayerWasted", localPlayer, -- changed to localPlayer as I only want it to take effect on the local client 
    function ( thePlayer ) 
        if ( isPedInVehicle ( source) ) then -- source because the first argument is the player's killer 
            -- removePedFromVehicle ( source); -- moved to server side since the vehicle was created server side 
        end 
        local x, y, z, lookx, looky, lookz = getCameraMatrix(); 
        setCameraMatrix ( x, y, z, lookx, looky, lookz ); 
    end 
); 

Still didn't work.

Link to comment
Sorry for the double post but I've just fixed the problem (pretty stupid of me lol)

I was still destroying the player's vehicle and that was causing it to focus the player.

I really appreciate all the help from you guys! Thank you :)

Ye it was my bad, sorry for the trouble. And thank you for being so helpful : )

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