You forgot one comma, here try this.
gLPlayer = getLocalPlayer()
addEvent("onClientPlayerFireRocket", false)
function fireRocketByRotation(startX, startY, startZ, rotX, rotZ, velocity)
local nrotX = -rotX
local nrotZ = -(rotZ + 180)
local velZ = velocity * math.sin(math.rad(rotX))
local a = velocity * math.cos(math.rad(rotX))
local velX = a * math.sin(math.rad(-rotZ))
local velY = a * math.cos(math.rad(-rotZ))
createProjectile(gLPlayer, 19, startX, startY, startZ, 1.0, nil, nrotX, 0, nrotZ, velX / 50, velY / 50, velZ / 50)
triggerEvent("onClientPlayerFireRocket", gLPlayer)
end
function fireRocketByTargetPosition(startX, startY, startZ, targetX, targetY, targetZ, velocity)
local rotZ = getRotationZ(startX, startY, targetX, targetY)
local rotX = getRotationX(startX, startY, startZ, targetX, targetY, targetZ)
fireRocketByRotation(startX, startY, startZ, rotX, rotZ, velocity)
end
function getRotationZ(startX, startY, endX, endY) -- Dommed-Space-Marine
local height = endX - startX
local line = endY - startY
local t = -math.deg(math.atan2(height, line))
if t < 0 then
t = t + 360
end
return t
end
function getRotationX(startX, startY, startZ, endX, endY, endZ) -- Dommed-Space-Marine
local line = ((endX - startX) ^ 2 + (endY - startY) ^ 2) ^ 0.5
local height = endZ - startZ
local t = math.deg(math.atan2(height, line))
--[[
if t < 0 then
t = t + 360
end
--]]
return t
end
function rocket()
local x,y,z = getElementPosition(gLPlayer)
local rx,ry, rz = getPedCameraRotation(gLPlayer)
fireRocketByRotation(x,y,z,rx,ry,rz, 50)
end
end
bindKey("mouse1", "down", rocket)