I am attempting to make a script that fires a missile using “ShootSingleBulletBetweenCoordsWithExtraParams” but it just shoots the missile a bit forward then explodes. It also goes no where near the player it just stays around the spawn point. This is the current code snippet.
local color = {
r=255,
g=0,
b=0,
a=255
}
local pped = GetPlayerPed(-1)
Citizen.CreateThread(function()
while true do
Citizen.Wait(600)
missile = GetHashKey("WEAPON_AIRSTRIKE_ROCKET")
RequestModel(missile)
RequestWeaponAsset(missile, 31, 26)
while not HasWeaponAssetLoaded(missile) do
Citizen.Wait(1)
print("dosen't")
end
if GetDistanceBetweenCoords( vector3(-2204.71, 2991.63, 70.06), vector3(GetEntityCoords(pped))) < 650 then
PlaySoundFromEntity(-1, "Out_Of_Bounds_Timer", pped, "DLC_HEISTS_GENERAL_FRONTEND_SOUNDS", true)
PlaySoundFromEntity(-1, "Out_Of_Bounds_Timer", pped, "DLC_HEISTS_GENERAL_FRONTEND_SOUNDS", true)
ShootSingleBulletBetweenCoordsWithExtraParams( vector3(-2204.71, 2991.63, 70.06), vector3(GetEntityCoords(pped)), 300, false, missile, nil, true, false, 4.0)
end
end
local rocketModel = GetHashKey("WEAPON_AIRSTRIKE_ROCKET")
local rocketOrigin = vector3(-2204.71, 2991.63, 70.06)
RegisterCommand('firerocket', function()
local playerPed = PlayerPedId()
local playerCoords = GetEntityCoords(playerPed)
local dist = #(rocketOrigin - playerCoords)
if dist > 650 then
return
end
RequestModel(rocketModel)
RequestWeaponAsset(rocketModel, 31, 0)
while not HasWeaponAssetLoaded(rocketModel) do
Citizen.Wait(0)
end
ShootSingleBulletBetweenCoords(rocketOrigin, playerCoords, 300, false, rocketModel, nil, true, true, nil)
end, false)
So unless you need those extra params for something I would use the ShootSingleBulletBetweenCoords native instead.
Thanks for your help. I ended up changing ShootSingleBulletBetweenCoordsWithExtraParams to ShootSingleBulletBetweenCoords and it now works. Again thanks for your help and have a great night/day.