-----BY:PaoloPG
local missile = createObject(3267, 1098.3994140625, 1537, 51, 0, 0, 131.50735473633)
setObjectScale(missile, 10)
local hydra = createVehicle(520, 4905.2998046875, -1011.0999755859, 76, 353.07855224609, 0, 347.59057617188)
local startTime = getTickCount()
function rotateTowards(missile, targetElement)
local mX, mY, mZ = getElementPosition(missile)
local tX, tY, tZ = getElementPosition(targetElement)
local dist2D = getDistanceBetweenPoints2D(mX, mY, tX, tY)
local rotX = -math.deg(math.atan2(mZ - tZ, dist2D)) - 45
rotX = rotX + 7
local rotZ = math.deg(math.atan2(mY - tY, mX - tX)) + 90
local prevX, prevY, prevZ = getElementRotation(missile)
setElementRotation(missile, rotX, 0, rotZ)
end
local follow = true
addEventHandler("onClientRender", root,
function()
if not follow then return end
rotateTowards(missile, localPlayer)
end)
local shooting = 1
local allowShoot = true
function shoot()
if not allowShoot then return end
setTimer(function()
local x = {}
local y = {}
local z = {}
x[1], y[1], z[1] = getPositionFromElementOffset(missile, 6.6192855834961, 11.790905952454, 28.00372505188)
x[2], y[2], z[2] = getPositionFromElementOffset(missile, -6.7651495933533, 11.7900390625, 28.00372505188)
x[3], y[3], z[3] = getPositionFromElementOffset(missile, 6.5832195281982, 13.9140625, 23.011194229126)
x[4], y[4], z[4] = getPositionFromElementOffset(missile, -6.7646484375, 13.914520263672, 23.011194229126)
local rotX, rotY, rotZ = getElementRotation(missile)
local tx, ty, tz = getElementPosition(localPlayer)
local dist3D = getDistanceBetweenPoints3D(x[shooting], y[shooting], z[shooting], tx, ty, tz)
local velX, velY, velZ = (x[shooting] - tx)/dist3D, (y[shooting] - ty)/dist3D, (z[shooting] - tz)/dist3D
createProjectile(localPlayer, 20, x[shooting], y[shooting], z[shooting], 1.0, localPlayer, rotX + 0, 0, rotZ, -velX, -velY, -velZ)
createProjectile(localPlayer, 20, x[shooting], y[shooting], z[shooting], 1.0, localPlayer, rotX + 0, 0, rotZ, -velX, -velY, -velZ)
shooting = shooting + 1
if(shooting > 4)then shooting = 1 end
end, 500, 4)
setTimer(function()
local x = {}
local y = {}
local z = {}
x[1], y[1], z[1] = getPositionFromElementOffset(missile, 6.6192855834961, 11.790905952454, 28.00372505188)
x[2], y[2], z[2] = getPositionFromElementOffset(missile, -6.7651495933533, 11.7900390625, 28.00372505188)
x[3], y[3], z[3] = getPositionFromElementOffset(missile, 6.5832195281982, 13.9140625, 23.011194229126)
x[4], y[4], z[4] = getPositionFromElementOffset(missile, -6.7646484375, 13.914520263672, 23.011194229126)
local rotX, rotY, rotZ = getElementRotation(missile)
local tx, ty, tz = getElementPosition(localPlayer)
local dist3D = getDistanceBetweenPoints3D(x[shooting], y[shooting], z[shooting], tx, ty, tz)
local velX, velY, velZ = (x[shooting] - tx)/dist3D, (y[shooting] - ty)/dist3D, (z[shooting] - tz)/dist3D
createProjectile(localPlayer, 20, x[shooting], y[shooting], z[shooting], 1.0, localPlayer, rotX + 0, 0, rotZ, -velX, -velY, -velZ)
createProjectile(localPlayer, 20, x[shooting], y[shooting], z[shooting], 1.0, localPlayer, rotX + 0, 0, rotZ, -velX, -velY, -velZ)
shooting = shooting + 1
if(shooting > 4)then shooting = 1 end
end, 500, 4)
setTimer(function()
shoot()
end, 1, 1)
end
function getMatrix(posX, posY, posZ, rotX, rotY, rotZ)
local rx, ry, rz = math.rad(rotX), math.rad(rotY), math.rad(rotZ)
local matrix = {}
matrix[1] = {}
matrix[1][1] = math.cos(rz)*math.cos(ry) - math.sin(rz)*math.sin(rx)*math.sin(ry)
matrix[1][2] = math.cos(ry)*math.sin(rz) + math.cos(rz)*math.sin(rx)*math.sin(ry)
matrix[1][3] = -math.cos(rx)*math.sin(ry)
matrix[2] = {}
matrix[2][1] = -math.cos(rx)*math.sin(rz)
matrix[2][2] = math.cos(rz)*math.cos(rx)
matrix[2][3] = math.sin(rx)
matrix[3] = {}
matrix[3][1] = math.cos(rz)*math.sin(ry) + math.cos(ry)*math.sin(rz)*math.sin(rx)
matrix[3][2] = math.sin(rz)*math.sin(ry) - math.cos(rz)*math.cos(ry)*math.sin(rx)
matrix[3][3] = math.cos(rx)*math.cos(ry)
matrix[4] = {}
matrix[4][1], matrix[4][2], matrix[4][3] = posX, posY, posZ
return matrix
end
function getPositionFromElementOffset(element,offX,offY,offZ)
local rotX, rotY, rotX = getElementRotation(element)
local posX, posY, posZ = getElementPosition(element)
local m = getElementMatrix(element)
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
end
local PG = createMarker( 1090.5, 1280, 100, "corona", 100, 255, 110, 0, 255)
addEventHandler("onClientMarkerHit", root,
function(hitElement, sameDimension)
if(hitElement ~= localPlayer or not sameDimension)then return end
local vehicle = getPedOccupiedVehicle(localPlayer)
if not vehicle then return end
if(source == PG)then
setTimer(function()
follow = true
setVehicleDamageProof(vehicle, true)
shoot()
setTimer(function(vehicle)
follow = true
allowShoot = true
end, 10000, 1, vehicle)
end, 1000, 1)
end
end)
for k, vehicle in ipairs(getElementsByType("vehicle", resourceRoot)) do
setElementFrozen(vehicle, true)
end
Aqui esta no quiero un comando quiero que cuando acabe la funcion comienze de nuevo e_e