xScatta Posted May 25, 2014 Share Posted May 25, 2014 Hi. The script is not mine but i have a problem with it. Client: player = getLocalPlayer ( ) sw, sh = guiGetScreenSize ( ) mouse1_pressed = false FPS_CAMERA = false --FUNCTION MADE BY 'Doomed_Space_Marine', FIXED BY 'robhol' function findRotation ( x1, y1, x2, y2 ) local t = -math.deg ( math.atan2 ( x2 - x1, y2 - y1 ) ) if t < 0 then t = t + 360 end return t end --ALWAYS SET CAMERA POSITION IN THE PLAYER'S HEAD addEventHandler ( "onClientPreRender", getRootElement ( ), function ( ) if FPS_CAMERA then local x1, y1, z1 = getPedBonePosition ( player, 6 ) setCameraMatrix ( x1, y1, z1 ) if not getControlState ( "aim_weapon" ) then setControlState ( "aim_weapon", false ) end end end ) --MAKE SURE THE PLAYER AIMS WITH THE MOUSE addEventHandler ( "onClientCursorMove", getRootElement ( ), function ( guiy1, guiy1, guix2, guiy2, x2, y2, z2 ) if not isCursorShowing ( ) and not isChatBoxInputActive ( ) and not isMainMenuActive ( ) and FPS_CAMERA then local x1, y1, z1 = getPedBonePosition ( player, 6 ) setPedRotation ( player, findRotation ( x1, y1, x2, y2 ) ) setCameraMatrix ( x1, y1, z1, x2, y2, z2 ) end end ) --A SIMPLE WAY TO MAKE A KEY REPEATER bindKey ( "mouse1", "both", function ( k, state ) if state == "down" then mouse1_pressed = true else mouse1_pressed = false end end ) --CONTROLS PART function resetControls ( ) toggleControl ( "aim_weapon", not FPS_CAMERA ) toggleControl ( "backwards", not FPS_CAMERA ) toggleControl ( "sprint", not FPS_CAMERA ) toggleControl ( "right", not FPS_CAMERA ) toggleControl ( "left", not FPS_CAMERA ) toggleControl ( "fire", not FPS_CAMERA ) toggleControl ( "enter_vehicle", not FPS_CAMERA ) toggleControl ( "enter_passenger", not FPS_CAMERA ) if FPS_CAMERA then setElementAlpha ( player, 0 ) else setElementAlpha ( player, 255 ) end end --DRAW A BEAUTIFUL CROSSHAIR IN THE MIDDLE OF THE SCREEN addEventHandler ( "onClientRender", getRootElement ( ), function ( ) if FPS_CAMERA then dxDrawImage ( ( sw / 2 ) - 4, ( sh / 2 ) - 4, 8, 8, "crosshair.png" ) end end ) addCommandHandler ( "fp", function ( ) FPS_CAMERA = not FPS_CAMERA if not FPS_CAMERA then setCameraTarget ( player ) else resetCamera ( ) end resetControls ( ) end ) The only problem here is when i move the mouse the camera doesn't move. Fast reply please. Greetz. xScatta Link to comment
KaduRo Posted May 25, 2014 Share Posted May 25, 2014 if i'm not wrong , line17 : player is not defined Link to comment
xScatta Posted May 25, 2014 Author Share Posted May 25, 2014 First line player = getLocalPlayer ( ) Link to comment
xXMADEXx Posted May 26, 2014 Share Posted May 26, 2014 resetCamera ( ) @ line 59 isn't defined. Link to comment
#RooTs Posted May 26, 2014 Share Posted May 26, 2014 IMAGE 01 IMAGE 02 Meta.xml "YOGA" name="Primeirapessoa" version="1.0.0" type="script"/> Client.lua checking = 0 carchecking = 0 wright = false wleft = false wback = false function FPSStart (startedresource) if startedresource == getThisResource() then local skin = engineLoadTXD ( "160.txd" ) -- arm skin engineImportTXD ( skin, 160 ) local x,y,z = getElementPosition( getLocalPlayer() ) Body = createObject (991, x, y, z ) setElementParent(Body, getLocalPlayer()) attachElements ( Body, getLocalPlayer(), 0, -0.1, 0.45, 0, 90, 0) setElementAlpha( Body, 0) setElementData ( getLocalPlayer(), "blocker", Body ) realskin = getElementModel(getLocalPlayer()) if realskin == 160 then realskin = 200 end realvoice1, realvoice2 = getPedVoice (getLocalPlayer()) setElementModel ( getLocalPlayer(), 160 ) setPedVoice (getLocalPlayer(),realvoice1,realvoice2) local allcars = getElementsByType ( "vehicle", getRootElement(), false) for theKey,theVehicle in ipairs(allcars) do setElementCollidableWith ( Body, theVehicle, false ) end bindKey ( "left", "both", sidewalking ) bindKey ( "right", "both", sidewalking ) bindKey ( "backwards", "both", sidewalking ) bindKey ( "fire", "both", autoAimMode ) end end addEventHandler ( "onClientResourceStart", getRootElement(), FPSStart) function clearcars() if getElementType(source) == "vehicle" then setElementCollidableWith ( Body, source, false ) end end addEventHandler( "onClientElementStreamIn", getRootElement(),clearcars) function invisOnSpawn() realskin = getElementModel(getLocalPlayer()) if realskin == 160 then realskin = 200 end realvoice1, realvoice2 = getPedVoice (getLocalPlayer()) setElementModel ( getLocalPlayer(), 160 ) setPedVoice (getLocalPlayer(),realvoice1,realvoice2) end addEventHandler ( "onClientPlayerSpawn", getLocalPlayer(), invisOnSpawn ) function climbcheck() if isPlayerDead(getLocalPlayer())== false and getControlState("aim_weapon") == false then setElementCollisionsEnabled(Body, false) if checking == 0 then checking = 1 stopclimbcheck = setTimer ( stopCcheck, 1200, 1 ) addEventHandler ("onClientPreRender", getRootElement(), areyouclimbing) elseif checking == 1 then if isTimer(stopclimbcheck) then killTimer(stopclimbcheck) end stopclimbcheck = setTimer ( stopCcheck, 1200, 1 ) end end end bindKey ("jump", "down", climbcheck ) function stopCcheck() local currentmode = getElementModel ( getLocalPlayer()) if currentmode == 160 then setElementCollisionsEnabled(Body, true) end removeEventHandler("onClientPreRender", getRootElement(), areyouclimbing) setCameraTarget (getLocalPlayer()) checking = 0 end function areyouclimbing() hx,hy,hz = getPedBonePosition ( getLocalPlayer(), 8 ) local rot = getPedRotation (getLocalPlayer()) radRot = math.rad ( rot ) local radius = .5 local tx = hx + radius * math.sin(radRot) local ty = hy + -(radius) * math.cos(radRot) local tz = hz setCameraMatrix(tx,ty,tz,hx,hy,hz) if ( isPedDoingTask ( getLocalPlayer(), "TASK_SIMPLE_CLIMB" ) ) then if isTimer(stopclimbcheck) then killTimer(stopclimbcheck) doneclimbyet = setTimer ( finishCcheck, 400, 1 ) end end end function finishCcheck() if ( isPedDoingTask ( getLocalPlayer(), "TASK_SIMPLE_CLIMB" ) ) then doneclimbyet = setTimer ( finishCcheck, 400, 1 ) else finishedclimbing() end end function finishedclimbing() checking = 0 removeEventHandler("onClientPreRender", getRootElement(), areyouclimbing) local currentmode = getElementModel ( getLocalPlayer()) if currentmode == 160 then setElementCollisionsEnabled(Body, true) end setCameraTarget (getLocalPlayer()) end function FPSStop (startedresource) if startedresource == getThisResource() then setElementModel ( getLocalPlayer(), realskin ) setPedVoice (getLocalPlayer(),realvoice1,realvoice2) setCameraTarget (getLocalPlayer()) end end addEventHandler ( "onClientResourceStop", getRootElement(), FPSStop) function shakeCamera(weapon) x,y,z = getPedBonePosition ( getLocalPlayer(), 26 ) if weapon == 24 then createExplosion ( x,y,z + 10,12,false,0.4,false) elseif weapon == 25 then createExplosion ( x,y,z + 10,12,false,0.5,false) elseif weapon == 26 then createExplosion ( x,y,z + 10,12,false,0.7,false) elseif weapon == 27 then createExplosion ( x,y,z + 10,12,false,0.5,false) elseif weapon == 29 then createExplosion ( x,y,z + 10,12,false,0.2,false) elseif weapon == 30 then createExplosion ( x,y,z+10,12,false,0.2,false) elseif weapon == 31 then createExplosion ( x,y,z + 10,12,false,0.3,false) elseif weapon == 33 then createExplosion ( x,y,z + 10,12,false,0.3,false) elseif weapon == 34 then createExplosion ( x,y,z + 10,12,false,0.3,false) end end addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer(), shakeCamera ) function carcheck(player) if player == getLocalPlayer() then if carchecking ~= 1 then carchecking = 1 local currentmode = getElementModel ( getLocalPlayer()) if currentmode == 160 then abortCarEnterCheck = setTimer ( checkCarTask, 100, 1 ) setElementCollisionsEnabled(Body, false) addEventHandler ("onClientPreRender", getRootElement(), areyougettingin) end end end end addEventHandler ( "onClientVehicleStartEnter", getRootElement(), carcheck ) addEventHandler ( "onClientVehicleEnter", getRootElement(), carcheck ) function carfollowupcheck() if (isPedInVehicle(getLocalPlayer()) == true) then -- if player is in car setElementModel ( getLocalPlayer(), realskin ) setElementCollisionsEnabled(Body, false) setPedVoice (getLocalPlayer(),realvoice1,realvoice2) setCameraTarget (getLocalPlayer()) -- setCameraView(0) else setElementCollisionsEnabled(Body, true) setPedVoice (getLocalPlayer(),realvoice1,realvoice2) setElementModel ( getLocalPlayer(), 160 ) setCameraTarget (getLocalPlayer()) end end function areyougettingin() hx,hy,hz = getPedBonePosition ( getLocalPlayer(), 8 ) local rot = getPedRotation (getLocalPlayer()) radRot = math.rad ( rot ) local radius = .5 local tx = hx + radius * math.sin(radRot) local ty = hy + -(radius) * math.cos(radRot) local tz = hz setCameraMatrix(tx,ty,tz,hx,hy,hz) end function checkCarTask() local stask = getPedSimplestTask(getLocalPlayer()) if (isPedInVehicle(getLocalPlayer()) == true) then -- if player is in car removeEventHandler("onClientPreRender", getRootElement(), areyougettingin) carchecking = 0 CarFollowUp = setTimer ( carfollowupcheck, 100, 1 ) setElementModel ( getLocalPlayer(), realskin ) setPedVoice (getLocalPlayer(),realvoice1,realvoice2) setCameraTarget (getLocalPlayer()) -- setCameraView(0) elseif (stask == "TASK_SIMPLE_CAR_GET_IN") or (stask == "TASK_SIMPLE_GO_TO_POINT") or (stask == "TASK_SIMPLE_CAR_OPEN_DOOR_FROM_OUTSIDE") or (stask == "TASK_SIMPLE_CAR_ALIGN") or (stask == "TASK_SIMPLE_CAR_CLOSE_DOOR_FROM_INSIDE") or (stask == "TASK_SIMPLE_CAR_SHUFFLE") or (stask == "TASK_SIMPLE_CAR_DRIVE") or (stask == "TASK_SIMPLE_ACHIEVE_HEADING") then -- if player is still getting in abortCarEnterCheck = setTimer ( checkCarTask, 100, 1 ) elseif (isPedInVehicle(getLocalPlayer()) == false) then --enter vehicle was aborted setElementCollisionsEnabled(Body, true) removeEventHandler("onClientPreRender", getRootElement(), areyougettingin) carchecking = 0 setCameraTarget (getLocalPlayer()) CarFollowUp = setTimer ( carfollowupcheck, 100, 1 ) end end function carexit(player) if player == getLocalPlayer() then setElementCollisionsEnabled(Body, true) setTimer ( setElementModel, 500, 1, getLocalPlayer(), 160 ) setTimer ( setPedVoice, 500, 1, getLocalPlayer(), realvoice1,realvoice2 ) end end addEventHandler ( "onClientVehicleStartExit", getRootElement(), carexit ) addEventHandler ( "onClientVehicleExit", getRootElement(), carexit ) function changestatus (dataName) if source == getLocalPlayer() and dataName == "usemode" then if (isPedInVehicle(source) == false) and (isPlayerDead(getLocalPlayer())== false) then if (getElementData ( source, "usemode" ) == true ) then setElementCollisionsEnabled(Body, false) setElementModel ( getLocalPlayer(), realskin ) setPedVoice (getLocalPlayer(),realvoice1,realvoice2) setCameraTarget(getLocalPlayer()) elseif (getElementData ( source, "usemode" ) == false ) then setElementCollisionsEnabled(Body, true) setElementModel ( getLocalPlayer(), 160 ) setPedVoice (getLocalPlayer(),realvoice1,realvoice2) end end end end addEventHandler( "onClientElementDataChange", getRootElement(), changestatus ) function zwasted ( killer, weapon, bodypart ) local x,y,z = getElementPosition( getLocalPlayer()) setCameraMatrix(x, y, z-.8, x, y, z+1) end addEventHandler ( "onClientPlayerWasted", getLocalPlayer(), zwasted ) function updateCamera() if checking == 0 and carchecking == 0 and wright == false and wleft == false or wback == true then x,y,z,tx,ty,tz = Link to comment
xScatta Posted May 26, 2014 Author Share Posted May 26, 2014 @xXMADEXx player = getLocalPlayer ( ) sw, sh = guiGetScreenSize ( ) mouse1_pressed = false FPS_CAMERA = false --FUNCTION MADE BY 'Doomed_Space_Marine', FIXED BY 'robhol' function findRotation ( x1, y1, x2, y2 ) local t = -math.deg ( math.atan2 ( x2 - x1, y2 - y1 ) ) if t < 0 then t = t + 360 end return t end --ALWAYS SET CAMERA POSITION IN THE PLAYER'S HEAD addEventHandler ( "onClientPreRender", getRootElement ( ), function ( ) if FPS_CAMERA then local x1, y1, z1 = getPedBonePosition ( player, 6 ) setCameraMatrix ( x1, y1, z1 ) if not getControlState ( "aim_weapon" ) then setControlState ( "aim_weapon", false ) end end end ) --MAKE SURE THE PLAYER AIMS WITH THE MOUSE addEventHandler ( "onClientCursorMove", getRootElement ( ), function ( guiy1, guiy1, guix2, guiy2, x2, y2, z2 ) if not isChatBoxInputActive ( ) and FPS_CAMERA then local x1, y1, z1 = getPedBonePosition ( player, 6 ) setPedRotation ( player, findRotation ( x1, y1, x2, y2 ) ) setCameraMatrix ( x1, y1, z1, x2, y2, z2 ) end end ) --A SIMPLE WAY TO MAKE A KEY REPEATER bindKey ( "mouse1", "both", function ( k, state ) if state == "down" then mouse1_pressed = true else mouse1_pressed = false end end ) --CONTROLS PART function resetControls ( ) toggleControl ( "aim_weapon", not FPS_CAMERA ) toggleControl ( "backwards", not FPS_CAMERA ) toggleControl ( "sprint", not FPS_CAMERA ) toggleControl ( "right", not FPS_CAMERA ) toggleControl ( "left", not FPS_CAMERA ) toggleControl ( "fire", not FPS_CAMERA ) toggleControl ( "enter_vehicle", not FPS_CAMERA ) toggleControl ( "enter_passenger", not FPS_CAMERA ) if FPS_CAMERA then setElementAlpha ( player, 0 ) else setElementAlpha ( player, 255 ) end end --DRAW A BEAUTIFUL CROSSHAIR IN THE MIDDLE OF THE SCREEN addEventHandler ( "onClientRender", getRootElement ( ), function ( ) if FPS_CAMERA then dxDrawImage ( ( sw / 2 ) - 4, ( sh / 2 ) - 4, 8, 8, "crosshair.png" ) end end ) addCommandHandler ( "fp", function ( ) FPS_CAMERA = not FPS_CAMERA if not FPS_CAMERA then setCameraTarget ( player ) else end resetControls ( ) end ) Why don't it work now? @YOGA I want this script not yours... I came here to repair this script. Link to comment
xXMADEXx Posted May 26, 2014 Share Posted May 26, 2014 (edited) IMAGE 01 IMAGE 02 Meta.xml "YOGA" name="Primeirapessoa" version="1.0.0" type="script"/> Client.lua checking = 0 carchecking = 0 wright = false wleft = false wback = false function FPSStart (startedresource) if startedresource == getThisResource() then local skin = engineLoadTXD ( "160.txd" ) -- arm skin engineImportTXD ( skin, 160 ) local x,y,z = getElementPosition( getLocalPlayer() ) Body = createObject (991, x, y, z ) setElementParent(Body, getLocalPlayer()) attachElements ( Body, getLocalPlayer(), 0, -0.1, 0.45, 0, 90, 0) setElementAlpha( Body, 0) setElementData ( getLocalPlayer(), "blocker", Body ) realskin = getElementModel(getLocalPlayer()) if realskin == 160 then realskin = 200 end realvoice1, realvoice2 = getPedVoice (getLocalPlayer()) setElementModel ( getLocalPlayer(), 160 ) setPedVoice (getLocalPlayer(),realvoice1,realvoice2) local allcars = getElementsByType ( "vehicle", getRootElement(), false) for theKey,theVehicle in ipairs(allcars) do setElementCollidableWith ( Body, theVehicle, false ) end bindKey ( "left", "both", sidewalking ) bindKey ( "right", "both", sidewalking ) bindKey ( "backwards", "both", sidewalking ) bindKey ( "fire", "both", autoAimMode ) end end addEventHandler ( "onClientResourceStart", getRootElement(), FPSStart) function clearcars() if getElementType(source) == "vehicle" then setElementCollidableWith ( Body, source, false ) end end addEventHandler( "onClientElementStreamIn", getRootElement(),clearcars) function invisOnSpawn() realskin = getElementModel(getLocalPlayer()) if realskin == 160 then realskin = 200 end realvoice1, realvoice2 = getPedVoice (getLocalPlayer()) setElementModel ( getLocalPlayer(), 160 ) setPedVoice (getLocalPlayer(),realvoice1,realvoice2) end addEventHandler ( "onClientPlayerSpawn", getLocalPlayer(), invisOnSpawn ) function climbcheck() if isPlayerDead(getLocalPlayer())== false and getControlState("aim_weapon") == false then setElementCollisionsEnabled(Body, false) if checking == 0 then checking = 1 stopclimbcheck = setTimer ( stopCcheck, 1200, 1 ) addEventHandler ("onClientPreRender", getRootElement(), areyouclimbing) elseif checking == 1 then if isTimer(stopclimbcheck) then killTimer(stopclimbcheck) end stopclimbcheck = setTimer ( stopCcheck, 1200, 1 ) end end end bindKey ("jump", "down", climbcheck ) function stopCcheck() local currentmode = getElementModel ( getLocalPlayer()) if currentmode == 160 then setElementCollisionsEnabled(Body, true) end removeEventHandler("onClientPreRender", getRootElement(), areyouclimbing) setCameraTarget (getLocalPlayer()) checking = 0 end function areyouclimbing() hx,hy,hz = getPedBonePosition ( getLocalPlayer(), 8 ) local rot = getPedRotation (getLocalPlayer()) radRot = math.rad ( rot ) local radius = .5 local tx = hx + radius * math.sin(radRot) local ty = hy + -(radius) * math.cos(radRot) local tz = hz setCameraMatrix(tx,ty,tz,hx,hy,hz) if ( isPedDoingTask ( getLocalPlayer(), "TASK_SIMPLE_CLIMB" ) ) then if isTimer(stopclimbcheck) then killTimer(stopclimbcheck) doneclimbyet = setTimer ( finishCcheck, 400, 1 ) end end end function finishCcheck() if ( isPedDoingTask ( getLocalPlayer(), "TASK_SIMPLE_CLIMB" ) ) then doneclimbyet = setTimer ( finishCcheck, 400, 1 ) else finishedclimbing() end end function finishedclimbing() checking = 0 removeEventHandler("onClientPreRender", getRootElement(), areyouclimbing) local currentmode = getElementModel ( getLocalPlayer()) if currentmode == 160 then setElementCollisionsEnabled(Body, true) end setCameraTarget (getLocalPlayer()) end function FPSStop (startedresource) if startedresource == getThisResource() then setElementModel ( getLocalPlayer(), realskin ) setPedVoice (getLocalPlayer(),realvoice1,realvoice2) setCameraTarget (getLocalPlayer()) end end addEventHandler ( "onClientResourceStop", getRootElement(), FPSStop) function shakeCamera(weapon) x,y,z = getPedBonePosition ( getLocalPlayer(), 26 ) if weapon == 24 then createExplosion ( x,y,z + 10,12,false,0.4,false) elseif weapon == 25 then createExplosion ( x,y,z + 10,12,false,0.5,false) elseif weapon == 26 then createExplosion ( x,y,z + 10,12,false,0.7,false) elseif weapon == 27 then createExplosion ( x,y,z + 10,12,false,0.5,false) elseif weapon == 29 then createExplosion ( x,y,z + 10,12,false,0.2,false) elseif weapon == 30 then createExplosion ( x,y,z+10,12,false,0.2,false) elseif weapon == 31 then createExplosion ( x,y,z + 10,12,false,0.3,false) elseif weapon == 33 then createExplosion ( x,y,z + 10,12,false,0.3,false) elseif weapon == 34 then createExplosion ( x,y,z + 10,12,false,0.3,false) end end addEventHandler ( "onClientPlayerWeaponFire", getLocalPlayer(), shakeCamera ) function carcheck(player) if player == getLocalPlayer() then if carchecking ~= 1 then carchecking = 1 local currentmode = getElementModel ( getLocalPlayer()) if currentmode == 160 then abortCarEnterCheck = setTimer ( checkCarTask, 100, 1 ) setElementCollisionsEnabled(Body, false) addEventHandler ("onClientPreRender", getRootElement(), areyougettingin) end end end end addEventHandler ( "onClientVehicleStartEnter", getRootElement(), carcheck ) addEventHandler ( "onClientVehicleEnter", getRootElement(), carcheck ) function carfollowupcheck() if (isPedInVehicle(getLocalPlayer()) == true) then -- if player is in car setElementModel ( getLocalPlayer(), realskin ) setElementCollisionsEnabled(Body, false) setPedVoice (getLocalPlayer(),realvoice1,realvoice2) setCameraTarget (getLocalPlayer()) -- setCameraView(0) else setElementCollisionsEnabled(Body, true) setPedVoice (getLocalPlayer(),realvoice1,realvoice2) setElementModel ( getLocalPlayer(), 160 ) setCameraTarget (getLocalPlayer()) end end function areyougettingin() hx,hy,hz = getPedBonePosition ( getLocalPlayer(), 8 ) local rot = getPedRotation (getLocalPlayer()) radRot = math.rad ( rot ) local radius = .5 local tx = hx + radius * math.sin(radRot) local ty = hy + -(radius) * math.cos(radRot) local tz = hz setCameraMatrix(tx,ty,tz,hx,hy,hz) end function checkCarTask() local stask = getPedSimplestTask(getLocalPlayer()) if (isPedInVehicle(getLocalPlayer()) == true) then -- if player is in car removeEventHandler("onClientPreRender", getRootElement(), areyougettingin) carchecking = 0 CarFollowUp = setTimer ( carfollowupcheck, 100, 1 ) setElementModel ( getLocalPlayer(), realskin ) setPedVoice (getLocalPlayer(),realvoice1,realvoice2) setCameraTarget (getLocalPlayer()) -- setCameraView(0) elseif (stask == "TASK_SIMPLE_CAR_GET_IN") or (stask == "TASK_SIMPLE_GO_TO_POINT") or (stask == "TASK_SIMPLE_CAR_OPEN_DOOR_FROM_OUTSIDE") or (stask == "TASK_SIMPLE_CAR_ALIGN") or (stask == "TASK_SIMPLE_CAR_CLOSE_DOOR_FROM_INSIDE") or (stask == "TASK_SIMPLE_CAR_SHUFFLE") or (stask == "TASK_SIMPLE_CAR_DRIVE") or (stask == "TASK_SIMPLE_ACHIEVE_HEADING") then -- if player is still getting in abortCarEnterCheck = setTimer ( checkCarTask, 100, 1 ) elseif (isPedInVehicle(getLocalPlayer()) == false) then --enter vehicle was aborted setElementCollisionsEnabled(Body, true) removeEventHandler("onClientPreRender", getRootElement(), areyougettingin) carchecking = 0 setCameraTarget (getLocalPlayer()) CarFollowUp = setTimer ( carfollowupcheck, 100, 1 ) end end function carexit(player) if player == getLocalPlayer() then setElementCollisionsEnabled(Body, true) setTimer ( setElementModel, 500, 1, getLocalPlayer(), 160 ) setTimer ( setPedVoice, 500, 1, getLocalPlayer(), realvoice1,realvoice2 ) end end addEventHandler ( "onClientVehicleStartExit", getRootElement(), carexit ) addEventHandler ( "onClientVehicleExit", getRootElement(), carexit ) function changestatus (dataName) if source == getLocalPlayer() and dataName == "usemode" then if (isPedInVehicle(source) == false) and (isPlayerDead(getLocalPlayer())== false) then if (getElementData ( source, "usemode" ) == true ) then setElementCollisionsEnabled(Body, false) setElementModel ( getLocalPlayer(), realskin ) setPedVoice (getLocalPlayer(),realvoice1,realvoice2) setCameraTarget(getLocalPlayer()) elseif (getElementData ( source, "usemode" ) == false ) then setElementCollisionsEnabled(Body, true) setElementModel ( getLocalPlayer(), 160 ) setPedVoice (getLocalPlayer(),realvoice1,realvoice2) end end end end addEventHandler( "onClientElementDataChange", getRootElement(), changestatus ) function zwasted ( killer, weapon, bodypart ) local x,y,z = getElementPosition( getLocalPlayer()) setCameraMatrix(x, y, z-.8, x, y, z+1) end addEventHandler ( "onClientPlayerWasted", getLocalPlayer(), zwasted ) function updateCamera() Edited May 26, 2014 by Guest Link to comment
xScatta Posted May 26, 2014 Author Share Posted May 26, 2014 (edited) I never steal... Look at my first post in this topic Hi. The script is not mine but i have a problem with it. Edit: I was thinking you are talking about me Edited May 26, 2014 by Guest Link to comment
Karuzo Posted May 26, 2014 Share Posted May 26, 2014 Madex are you blind? I never steal...Look at my first post in this topic Hi. The script is not mine but i have a problem with it. He was talking to YOGA . Link to comment
xScatta Posted May 26, 2014 Author Share Posted May 26, 2014 Edited code... Still the same player = getLocalPlayer ( ) sw, sh = guiGetScreenSize ( ) mouse1_pressed = false FPS_CAMERA = false --FUNCTION MADE BY 'Doomed_Space_Marine', FIXED BY 'robhol' function findRotation ( x1, y1, x2, y2 ) local t = -math.deg ( math.atan2 ( x2 - x1, y2 - y1 ) ) if t < 0 then t = t + 360 end return t end --ALWAYS SET CAMERA POSITION IN THE PLAYER'S HEAD addEventHandler ( "onClientPreRender", getRootElement ( ), function ( ) if FPS_CAMERA then local x1, y1, z1 = getPedBonePosition ( player, 6 ) setCameraMatrix ( x1, y1, z1 ) if not getControlState ( "aim_weapon" ) then setControlState ( "aim_weapon", false ) end end end ) --MAKE SURE THE PLAYER AIMS WITH THE MOUSE addEventHandler ( "onClientCursorMove", getRootElement ( ), function ( guiy1, guiy1, guix2, guiy2, x2, y2, z2 ) if FPS_CAMERA then local x1, y1, z1 = getPedBonePosition ( player, 6 ) setCameraMatrix ( x1, y1, z1, x2, y2, z2 ) setElementRotation ( player, findRotation ( x1, y1, x2, y2 ),0,0 ) --setCursorPosition(sw/2,sh/2) end end ) --A SIMPLE WAY TO MAKE A KEY REPEATER bindKey ( "mouse1", "both", function ( k, state ) if state == "down" then mouse1_pressed = true else mouse1_pressed = false end end ) --CONTROLS PART function resetControls ( ) toggleControl ( "aim_weapon", not FPS_CAMERA ) toggleControl ( "backwards", not FPS_CAMERA ) toggleControl ( "sprint", not FPS_CAMERA ) toggleControl ( "right", not FPS_CAMERA ) toggleControl ( "left", not FPS_CAMERA ) toggleControl ( "fire", not FPS_CAMERA ) toggleControl ( "enter_vehicle", not FPS_CAMERA ) toggleControl ( "enter_passenger", not FPS_CAMERA ) if FPS_CAMERA then setElementAlpha ( player, 0 ) else setElementAlpha ( player, 255 ) end end --DRAW A BEAUTIFUL CROSSHAIR IN THE MIDDLE OF THE SCREEN addEventHandler ( "onClientRender", getRootElement ( ), function ( ) if FPS_CAMERA then dxDrawImage ( ( sw / 2 ) - 4, ( sh / 2 ) - 4, 8, 8, "crosshair.png" ) end end ) addCommandHandler ( "fp", function ( ) FPS_CAMERA = not FPS_CAMERA if not FPS_CAMERA then setCameraTarget ( player ) end resetControls ( ) end ) Is strange because in previous versions it was working but now nope. And the camera matrix direction is 0, 0, 0 position and its relative to player position so when i move then the camera direction is the 0, 0, 0 position. Link to comment
Recommended Posts