Greenie0101 Posted July 24, 2012 Share Posted July 24, 2012 function firstPerson(player) x,y,z = getElementPosition(player) rx,ry,rz = getElementPosition(player) setCameraMatrix(player1,x,y,z + 1,rx + 1,ry,rz) resetTime = setTimer (firstPerson, 100, 0, player) end addCommandHandler("fp", firstPerson) Made this script to make a first person camera but i cant make the camera follow the player as the console has a seizure and gives me lots of errors. How to fix? Also after this ill have the problem of needing to move the players vision with the mouse. How can i make that work? And how to make it so that the camera is facing ahead of the player. Link to comment
Castillo Posted July 24, 2012 Share Posted July 24, 2012 This is a server sided script? You should make a client side script which updates camera onClientPreRender. Link to comment
Jaysds1 Posted July 24, 2012 Share Posted July 24, 2012 You should make a client side script which updates camera onClientPreRender. Try this: function firstPerson() x,y,z = getElementPosition(localPlayer) rx,ry,rz = getElementPosition(localPlayer) setCameraMatrix(x,y,z + 1,rx + 1,ry,rz) end addCommandHandler("fp", function() addEventHandler("onClientPreRender",root,firstPerson) end) BTW, I suggest getting the player's bone position: getPedBonePosition Link to comment
Greenie0101 Posted July 25, 2012 Author Share Posted July 25, 2012 awesome, that worked well. now i need to figure out how i can make the head turn with the mouse Link to comment
qaisjp Posted July 25, 2012 Share Posted July 25, 2012 setPedLookAt Instead, create a object, move it on prerender, moving the mouse moves the object. and have the lookat (ped and camera) point towards the object. Link to comment
Greenie0101 Posted July 25, 2012 Author Share Posted July 25, 2012 setPedLookAtInstead, create a object, move it on prerender, moving the mouse moves the object. and have the lookat (ped and camera) point towards the object. i have got it to work now but its sketchy as! Instead of making an object ive just been using the cursors position. I think making an object would work much better, how do i do this though? (not the making the object, the making it move with the mouse) heres what ive got. function firstPerson() x,y,z = getPedBonePosition(localPlayer, 7) showCursor(true, false) s1,s2,cx,cy,cz = getCursorPosition(localPlayer) setCameraMatrix(x,y,z,cx,cy,cz) setPedLookAt(localPlayer,cx,cy,cz,-1) end addCommandHandler("fp", function() addEventHandler("onClientPreRender",root,firstPerson) end) Link to comment
qaisjp Posted July 25, 2012 Share Posted July 25, 2012 onClientMouseMove, move the object. Then in the onClientPreRender, do this: local ox, oy, oz = getElementPosition(object) setCameraMatrix(x,y,z, ox, oy, oz) Link to comment
Greenie0101 Posted July 26, 2012 Author Share Posted July 26, 2012 function firstPerson() rx,ry,rz = getElementRotation(localPlayer) screenX, screenY = guiGetScreenSize () x,y,z = getPedBonePosition(localPlayer, 7) showCursor(true, false) s1,s2,cx,cy,cz = getCursorPosition(localPlayer) setCameraMatrix(x,y,z,cx,cy,cz,ry,180) setPedLookAt(localPlayer,cx,cy,cz,-1) if s1>0.55 then setCursorPosition(screenX/2 + 20, screenY/2) end if s1<0.45 then setCursorPosition(screenX/2 - 20, screenY/2) end if s2>0.55 then setCursorPosition(screenX/2, screenY/2 + 20) end if s2<0.45 then setCursorPosition(screenX/2, screenY/2 - 20) end end addCommandHandler("fp", function() addEventHandler("onClientPreRender",root,firstPerson) end) this works but i need to make a function so i can go back to normal camera by typing /tp i also would like to know how to make the cross hairs appear when i right click Link to comment
Al3grab Posted July 26, 2012 Share Posted July 26, 2012 addCommandHandler("tp", function() removeEventHandler("onClientPreRender",root,firstPerson) setCameraTarget(localPlayer,localPlayer) end) You can't use gta crosshair while using setCameraMatrix , you will need to make your own Link to comment
Greenie0101 Posted July 26, 2012 Author Share Posted July 26, 2012 addCommandHandler("tp", function() removeEventHandler("onClientPreRender",root,firstPerson) setCameraTarget(localPlayer,localPlayer) end) You can't use gta crosshair while using setCameraMatrix , you will need to make your own thanks mate,works fine now. I'll figure out something for cross hairs. If anyone can help me there though would be appreciated Link to comment
qaisjp Posted July 26, 2012 Share Posted July 26, 2012 Find a image on the internet. Create the crosshair using gui image functions (easier) or dxDrawImage (more expansible) 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