Jump to content

Shooting plane script


delta1337

Recommended Posts

Hello, I'll made a script which shoots with a bullets, but it dont want work, can somebody help me? 

Quote

function getPositionFromElementOffset(element,offX,offY,offZ)
    local m = getElementMatrix ( element )  -- Get the matrix
    local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1]  -- Apply transform
    local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2]
    local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3]
    return x, y, z                               -- Return the transformed point
end


function getPointFromDistanceRotation(x, y, dist, angle)

    local a = math.rad(90 - angle);
 
    local dx = math.cos(a) * dist;
    local dy = math.sin(a) * dist;
 
    return x+dx, y+dy;
 
end
function getPointFromDistanceRotationa(x, dist, angle)

    local a = math.rad(90 - angle);
 
    local dx = math.cos(a) * dist;

 
    return x+dx;
 
end
local time=getTickCount()

addEventHandler('onClientRender',root,function()
local veh=getPedOccupiedVehicle(localPlayer)
if veh and getElementModel(veh)==519 and getPedOccupiedVehicleSeat(localPlayer)==0 then


local sx,sy,sz=getPositionFromElementOffset(veh,0,3,-1)

local vxr,_,vr=getElementRotation(veh)
local vx,vy,vz=getElementPosition(veh)

local vz= getPointFromDistanceRotationa(vz,120,vxr)
local vx,vy= getPointFromDistanceRotation(vx,vy, 120, -vr)

dxDrawLine3D(sx,sy,sz,vx,vy,vz,tocolor(255,0,0,255),3)

if getKeyState('lctrl') then
 if getTickCount()-time>=150 then

 local h,hx,hy,hz,he=  processLineOfSight (sx,sy,sz,vx,vy,vz,true,true,true,true,true,false,false,false,getPedOccupiedVehicle(localPlayer))
triggerServerEvent('fire',localPlayer,sx,sy,sz,vx,vy,vz,he)
time=getTickCount()
end
end
end
end)


addEvent('fire',true)
addEventHandler('shm_cgraj',root,function(x,y,z,x1,y1,z1)
local s=playSound3D('gun.mp3',x,y,z)
setSoundMaxDistance( s,150 )
fxAddGunshot ( x1,y1,z1,0,0,0)
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...