Jump to content

Ac130 camera bug PLS HELP!


Xwad

Recommended Posts

hi i donwloaded a script but the camera switches back to the plane without reason. How can i fix it?? Recently i saw a post and there they sad: change setCameraMatrix function. Please help its very important:(

what are you talking about try to explane your problem better or just post some screenshots.

Link to comment

This is that part:

  
function cammera(screenX, screenY, absoluteX, absoluteY, vx,vy,vz)   
    local x,y,z = getElementPosition(getPedOccupiedVehicle(getLocalPlayer())) 
         
    local rx, ry, rz = getElementRotation(getPedOccupiedVehicle(getLocalPlayer())) 
     
    rz = rz +180 
     
    local cx = x + math.cos(math.rad(rz)) * 3 
    local cy = y + math.sin(math.rad(rz)) * 3 
     
    setCameraMatrix ( cx, cy, z, vx,vy,vz) 
    drawHud() 
end 
  
  
function keepCamAtAc130() 
    local x,y,z = getElementPosition(getPedOccupiedVehicle(getLocalPlayer())) 
     
    local rx, ry, rz = getElementRotation(getPedOccupiedVehicle(getLocalPlayer())) 
     
    rz = rz +180 
     
    local cx = x + math.cos(math.rad(rz)) * 3 
    local cy = y + math.sin(math.rad(rz)) * 3 
     
    setCameraMatrix(cx, cy, z) 
    drawHud() 
end 
  

Link to comment

i wrote donw my problem.. My problem is that when i type /ac130 and enter the plane and press space then i cant look around with the camera becaouse it always get back to the normal position. Please just try it out download the script and test it. You will see the problem. There must be a way to fix it.

you mean need i try use this function?: setPedLookAt()

Link to comment

client.lua

--------------------------- 
--(c) by MazzMan/Maxim
---------------------------
canDriverUseGun = true
 
ammo = {}
ammo.small = false
ammo.middle = false
ammo.big = true
 
ammo.smallShots = 50
ammo.middleShots = 6
 
ammo.smallCanShoot = true
ammo.middleCanShoot = true
 
ammo.smallReloading = false
ammo.middleReloading = false
ammo.bigReloading = false
 
setElementData(getLocalPlayer(), "ac130KeysBound", false)
 
addEventHandler("onClientVehicleEnter", getRootElement(), function(thePlayer, seat)
    if(getLocalPlayer() == thePlayer and getElementModel(source) == 592 and getElementData(source, "ac130"))then
        if(canDriverUseGun)then
            bindKey("space", "down", setBinds)
        elseif(seat == 1)then
            bindKey("space", "down", setBinds)
        end
    end
end)
 
function removeAllGunControls()
    unbindKey("space", "down", setBinds)
    setCameraGoggleEffect("normal")
   
    setElementData(getLocalPlayer(), "ac130KeysBound", false)
    removeEventHandler("onClientRender", getRootElement(), keepCamAtAc130)
    removeEventHandler("onClientCursorMove", getRootElement(), cammera)
    unbindKey("mouse1", "down", shoot)
    setCameraTarget(getLocalPlayer())
    unbindKey("mouse_wheel_up", "down", changeAmmo)
    unbindKey("mouse_wheel_down", "down", changeAmmo)
    unbindKey("v", "down", setVisionMode)
end
addEventHandler("onClientVehicleExit", getRootElement(), removeAllGunControls)
addEventHandler("onClientResourceStop", getRootElement(), removeAllGunControls)
 
addEventHandler("onClientPlayerWasted", getRootElement(), function()
    if(source == getLocalPlayer())then
        removeAllGunControls()
    end
end)
 
local windowX, windowY = guiGetScreenSize()
 
function cammera(screenX, screenY, absoluteX, absoluteY, vx,vy,vz) 
    local x,y,z = getElementPosition(getPedOccupiedVehicle(getLocalPlayer()))
       
    local rx, ry, rz = getElementRotation(getPedOccupiedVehicle(getLocalPlayer()))
   
    rz = rz +180
   
    local cx = x + math.cos(math.rad(rz)) * 3
    local cy = y + math.sin(math.rad(rz)) * 3
   
    setCameraMatrix ( cx, cy, z, vx, vy, vz )
    drawHud()
end
 
 
function keepCamAtAc130()
    local x,y,z = getElementPosition(getPedOccupiedVehicle(getLocalPlayer()))
   
    local rx, ry, rz = getElementRotation(getPedOccupiedVehicle(getLocalPlayer()))
   
    rz = rz +180
   
    local cx = x + math.cos(math.rad(rz)) * 3
    local cy = y + math.sin(math.rad(rz)) * 3
   
    setCameraMatrix(cx, cy, z)
end
 
function setBinds()
    if(getElementData(getLocalPlayer(), "ac130KeysBound") == false)then
        setElementData(getLocalPlayer(), "ac130KeysBound", true)
        keepCamAtAc130 ( )
        addEventHandler("onClientCursorMove", getRootElement(), cammera)
        addEventHandler ( "onClientRender", root, drawHud )
        bindKey("mouse1", "down", shoot)
        bindKey("mouse_wheel_up", "down", changeAmmo)
        bindKey("mouse_wheel_down", "down", changeAmmo)
        bindKey("v", "down", setVisionMode)
    else
        setElementData(getLocalPlayer(), "ac130KeysBound", false)
        removeEventHandler("onClientCursorMove", getRootElement(), cammera)
        removeEventHandler ( "onClientRender", root, drawHud )
        unbindKey("mouse1", "down", shoot)
        setCameraTarget(getLocalPlayer())
        unbindKey("mouse_wheel_up", "down", changeAmmo)
        unbindKey("mouse_wheel_down", "down", changeAmmo)
        unbindKey("v", "down", setVisionMode)
        setCameraGoggleEffect("normal")
    end
end
 
function shoot()
    local cx, cy, cz = getCameraMatrix()
    local wX,wY,wZ = getWorldFromScreenPosition(windowX/2, windowY/2, 2000) 
    local hit, x, y, z = processLineOfSight(cx, cy, cz, wX,wY,wZ)
   
    if(hit)then
        local distance = getDistanceBetweenPoints3D(x, y, z, cx, cy, cz)
        local time = distance/0.5
       
        local ammoType
        if(ammo.small)then
            if(time >= 50)then
                if(ammo.smallCanShoot and ammo.smallReloading == false)then
                    --im using a timer, becaus a while loop will cause to crash the game
                    shootTimer = setTimer(function()
                        if(getKeyState("mouse1"))then
                            cx, cy, cz = getCameraMatrix()
                            wX,wY,wZ = getWorldFromScreenPosition(windowX/2, windowY/2, 2000)   
                            hit, x, y, z = processLineOfSight(cx, cy, cz, wX,wY,wZ)
                            if(hit)then
                                playSound("sounds/shot_small.wav")
                                ammoType = "small"
                                           
                                ammo.smallShots = ammo.smallShots - 1
                                if(ammo.smallShots == 0)then
                                    setReloading("small")
                                    killTimer(shootTimer)
                                end 
                                ammo.smallCanShoot = false
                                setTimer(function()
                                    ammo.smallCanShoot = true
                                end, 200, 1)
                                triggerServerEvent("onAc130Shoot", getRootElement(),cx, cy, cz, x, y, z, time, ammoType)
                            end
                        else
                            killTimer(shootTimer)
                        end
                    end, 50, 0)
                else
                    return false
                end
            else
                return false
            end
        elseif(ammo.middle)then
            if(time >= 50)then
                if(ammo.middleCanShoot and ammo.middleReloading == false)then
                    ammoType = "middle"
                    ammo.middleShots = ammo.middleShots - 1
                    if(ammo.middleShots == 0)then
                        setReloading("middle")
                    end            
                    ammo.middleCanShoot = false
                    playSound("sounds/shot_middle.wav")
                    setTimer(function()
                        ammo.middleCanShoot = true
                    end, 500, 1)
                else
                    return false
                end
            else
                return false
            end
        elseif(ammo.big)then
            if(ammo.bigReloading == false)then
                if(time >= 50)then
                    ammoType = "big"
                    playSound("sounds/shot_middle.wav")
               
                    setReloading("big")
                else
                    return false
                end
            else
                return false
            end
        end
        triggerServerEvent("onAc130Shoot", getRootElement(),cx, cy, cz, x, y, z, time, ammoType)
    end
end
 
function changeAmmo(key)
    if(key == "mouse_wheel_up")then
        if(ammo.small)then
            ammo.small = false
            ammo.big = true
        elseif(ammo.middle)then
            ammo.middle = false
            ammo.small = true
        elseif(ammo.big)then
            ammo.big = false
            ammo.middle = true
        end
    else
        if(ammo.small)then
            ammo.small = false
            ammo.middle = true
        elseif(ammo.middle)then
            ammo.middle = false
            ammo.big = true
        elseif(ammo.big)then
            ammo.big = false
            ammo.small = true
        end
    end
end
 
function setReloading(ammoType)
    if(ammoType == "small")then
        ammo.smallReloading = true
        setTimer(function()
            ammo.smallReloading = false    
            ammo.smallShots = 50
        end, 3000, 1)
    elseif(ammoType == "middle")then
        ammo.middleReloading = true
        setTimer(function()
            ammo.middleReloading = false       
            ammo.middleShots = 6
        end, 3000, 1)
    elseif(ammoType == "big")then
        ammo.bigReloading = true
        setTimer(function()
            ammo.bigReloading = false      
        end, 3000, 1)
    end
end
 
function setVisionMode()
    if(getCameraGoggleEffect() == "normal")then
        setCameraGoggleEffect("nightvision")
    elseif(getCameraGoggleEffect() == "nightvision")then
        setCameraGoggleEffect("thermalvision")
    elseif(getCameraGoggleEffect() == "thermalvision")then
        setCameraGoggleEffect("normal")
    end
end
 
addEvent("onClientCreateEffect", true)
addEventHandler("onClientCreateEffect", getRootElement(), function(x,y,z, lx, ly, lz, type, time)
    if(type ~= "small")then
        --playSound3D("sounds/shot_middle.wav", x,y,z)
        --local num = math.random(1, 3)
        --local projectileSound = playSound3D("sounds/projectile_"..num..".wav", lx, ly, lz)
       
Link to comment

Now the bug is that the camera dosent attach to the plane. I mean when i enter the plane then there is no camera bug it dosent switches back to the normal position but there is a bug. When i start going with the plane then the camera stays in one position. I mean the camera stays there where i spawned the ac130:/ the camera only attaches to the plane when i move the mause and if i dont move the mouse then the camera stays again.

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