Skip to content

Instantly share code, notes, and snippets.

@Saturn745
Created November 24, 2024 20:23
Show Gist options
  • Select an option

  • Save Saturn745/276e9f05bb0b1280472b3a27455a1f9a to your computer and use it in GitHub Desktop.

Select an option

Save Saturn745/276e9f05bb0b1280472b3a27455a1f9a to your computer and use it in GitHub Desktop.
Recreation of the GTA 5 SP "Caida Libre" plane crash scene in FiveM. It's not perfect 1:1.
RegisterNetEvent("PostCrash", function(objectNetId)
RequestIpl("Plane_crash_trench")
UseParticleFxAssetNextCall("scr_martin1")
local object = NetToObj(objectNetId)
StartParticleFxLoopedOnEntity("scr_sol1_plane_wreck", object, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, false, false, false)
StartParticleFxLoopedOnEntity("scr_sol1_plane_crash_dust", object, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, false, false, false)
StartParticleFxLoopedAtCoord("scr_sol1_fire_spot", 2803.5, 4789.3, 46.6, 89.5, 0.0, 0.0, 1.5, false, false, false, false)
StartParticleFxLoopedAtCoord("scr_sol1_fire_trail", 2805.4, 4782.5, 46.5, 89.5, 0.0, 74.0, 1.5, false, false, false, false)
StartParticleFxLoopedAtCoord("scr_sol1_fire_trail", 2804.1, 4777.3, 46.2, 89.5, 0.0, 74.0, 1.5, false, false, false, false)
StartParticleFxLoopedAtCoord("scr_sol1_fire_drip", 2808.2, 4791.6, 48.8, 89.5, 0.0, 169.1, 1.5, false, false, false, false)
StartParticleFxLoopedAtCoord("scr_sol1_plane_tail_fire", 2805.8, 4788.5, 49.8, 89.5, -100.0, -40.0, 0.7, false, false, false, false)
StartParticleFxLoopedAtCoord("scr_sol1_plane_engine_fire", 2808.6, 4793.4, 48.7, 0.0, 0.0, -10.0, 0.6, false, false, false, false)
StartParticleFxLoopedAtCoord("scr_sol1_plane_elec_crackle", 2809.1, 4802.4, 48.0, 0.0, 0.0, 0.0, 0.9, false, false, false, false)
end)
local function StartSmokeFX(vehicle)
RequestNamedPtfxAsset("scr_martin1")
while not HasNamedPtfxAssetLoaded("scr_martin1") do
Wait(0)
print(HasNamedPtfxAssetLoaded("scr_martin1"))
end
UseParticleFxAssetNextCall("scr_martin1")
local pfx = StartNetworkedParticleFxLoopedOnEntity("scr_sol1_plane_smoke_loop", vehicle, 1.6631, -3.2729, 0.7426, 0.0, 0.0, 0.0, 1.0, false, false, false)
SetParticleFxLoopedScale(pfx, 2.0)
end
RegisterNetEvent("PreCrash", function(vehicleNetId)
while not NetworkDoesEntityExistWithNetworkId(vehicleNetId) do
print("Plane has not yet came in range of the client, waiting for it to load")
Wait(0)
end
local vehicle = NetToVeh(vehicleNetId)
print("Plane has came in range of the client, starting smoke fx")
StartSmokeFX(vehicle)
end)
CreateThread(function()
RemoveIpl("Plane_crash_trench")
end)
local function CreatePlane()
-- Request models
RequestModel("shamal")
RequestVehicleRecording(1, "BB_SOL_JET");
while not HasVehicleRecordingBeenLoaded(1, "BB_SOL_JET") do
Wait(0)
end
print(HasVehicleRecordingBeenLoaded(1, "BB_SOL_JET"))
-- Create plane
local vehicle = CreateVehicle(`shamal`, -1638.618, -2734.44, 12.8201, 327.2515, true, true, false)
-- Wait until the vehicle is created
while not DoesEntityExist(vehicle) do
Wait(0)
end
Wait(5000)
-- Add a blip to the vehicle
local blip = AddBlipForEntity(vehicle)
SetBlipSprite(blip, 16)
SetBlipColour(blip, 5)
SetBlipFlashes(blip, true)
SetBlipFlashTimer(blip, 8000)
ControlLandingGear(vehicle, 3)
SetEntityInvincible(vehicle, true)
SetVehicleLivery(vehicle, 1)
Wait(5000)
StartPlaybackRecordedVehicle(vehicle, 1, "BB_SOL_JET", true)
SkipTimeInPlaybackRecordedVehicle(vehicle, 16500.00)
SetPlaybackSpeed(vehicle, 0.4)
--func_981(vehicle, 13662.0, 0)
SetModelAsNoLongerNeeded(`shamal`)
SetVehicleEngineOn(vehicle, true, true, false)
TriggerServerEvent("PreCrash", NetworkGetNetworkIdFromEntity(vehicle))
while true do
Wait(0)
print(GetTimePositionInRecording(vehicle))
if GetTimePositionInRecording(vehicle) > 121350.0 then
-- Request the model
RequestModel("prop_shamal_crash")
while not HasModelLoaded(`prop_shamal_crash`) do
Wait(0)
end
local object = CreateObject(`prop_shamal_crash`, 2807.692, 4796.449, 45.8, true, true, true)
SetEntityCollision(object, false, false)
SetEntityRotation(object, 0.0, 0.0, -11.34007, 2, true)
SetEntityQuaternion(object, -0.0162, -0.0524, -0.1071, 0.9927)
SetEntityInvincible(object, true)
FreezeEntityPosition(object, true)
SetModelAsNoLongerNeeded(`prop_shamal_crash`)
TriggerServerEvent("PostCrash", NetworkGetNetworkIdFromEntity(object))
-- Remove the plane
SetEntityAsMissionEntity(vehicle, true, true)
DeleteEntity(vehicle)
break
end
end
end
RegisterCommand("startplane", function()
CreatePlane()
end, false)
RegisterNetEvent("PostCrash", function(objectNetId)
TriggerClientEvent("PostCrash", -1, objectNetId)
end)
RegisterNetEvent("PreCrash", function(vehicleNetId)
TriggerClientEvent("PreCrash", -1, vehicleNetId)
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment