Jump to content

the Right x, y, z Position


ikzelf

Recommended Posts

Hey,

i tryed to get the Right Position 100 Meters Infront of mine Helicopter, but it doesnt get the right position wenn mine Heli is at 45 degrees

i tryed this but it only get the right X, Y and not the Z

             
setTimer( 
                function () 
                    local x, y, z = getElementPosition(veh) 
                    local rx, ry, rz = getElementRotation(veh) 
                    local x = x+100*math.cos(math.rad(rz+90)) 
                    local y = y+100*math.sin(math.rad(rz+90)) 
                    setPedAimTarget ( ped, x, y, z ) 
                end 
                , 50, 0) 
  

anyone got a trick for it?

-ikzelf

Link to comment

ye i will post the whole script didnt though it was needed

client:

addEvent("setFiring", true) 
addEventHandler("setFiring", getRootElement(),  
    function (ped, veh) 
        if ped then 
            setTimer( 
                function () 
                    local x, y, z = getElementPosition(veh) 
                    local rx, ry, rz = getElementRotation(veh) 
                    local x = x+100*math.cos(math.rad(rz+90)) 
                    local y = y+100*math.sin(math.rad(rz+90)) 
                    setPedAimTarget ( ped, x, y, z ) 
                end 
                , 50, 0) 
            setPedControlState ( ped, "fire", true )  
        end 
    end 
) 

server:

rain = createVehicle(563, 0, 0, 3, 0, 0, 45) 
  
ped1 = createPed(28, 0, 0, 10) 
attachElements(ped1, rain, 0, 5, 0) 
setTimer( 
    function () 
        if ped1 then 
            giveWeapon ( ped1, 38, 5009, true) 
        end 
    end 
    , 1000, 1) 
setTimer( 
    function () 
        if ped1 then 
            local rx, ry, rz = getElementRotation(rain) 
            setElementRotation(ped1, rx, ry, rz) 
        end 
    end 
    , 50, 0) 
  
function setFire(play) 
    triggerClientEvent("setFiring", play, ped1, getPedOccupiedVehicle(play)) 
end 
addCommandHandler("fire", setFire) 

Link to comment

try this:

Server

rain = createVehicle(563, 0, 0, 3, 0, 0, 45) 
  
ped1 = createPed(28, 0, 0, 10) 
attachElements(ped1, rain, 0, 5, 0) 
setTimer( 
    function () 
        if ped1 then 
            giveWeapon ( ped1, 38, 5009, true) 
        end 
    end 
    , 1000, 1) 
setTimer( 
    function() 
        if ped1 then 
            local rx, ry, rz = getElementRotation(rain) 
            setElementRotation(ped1, rx, ry, rz) 
        end 
    end 
    , 50, 0) 
  
function setFire(play) 
    local veh = getPedOccupiedVehicle(play) 
    triggerClientEvent(play"setFiring",root, ped1, veh) 
end 
addCommandHandler("fire", setFire) 

Client:

addEvent("setFiring", true) 
addEventHandler("setFiring",root, 
    function(ped, veh) 
        if ped then 
            setTimer( 
                function() 
                    local x, y, z = getElementPosition(veh) 
                    local rx, ry, rz = getElementRotation(veh) 
                    local x = x+100*math.cos(math.rad(rz+90)) 
                    local y = y+100*math.sin(math.rad(rz+90)) 
                    setPedAimTarget ( ped, x, y, z ) 
                end 
                , 50, 0) 
            setPedControlState ( ped, "fire", true ) 
        end 
    end 
) 

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