Files
Elite-Gaming-FiveM/resources/night_ers/callouts/callouts_client.lua
T
2025-07-07 15:57:37 -07:00

108 lines
3.8 KiB
Lua

--============================== BUILD CALLOUTS =================================--
function ERS_BuildCallout(pedList, vehicleList, playersList, objectList, propList, fireList, smokeList, calloutDataClient)
local plyPed = PlayerPedId()
Config.Callouts[calloutDataClient.calloutId].client(plyPed, pedList, vehicleList, playersList, objectList, propList, fireList, smokeList, calloutDataClient)
end
--================ Open source functions (Edit these if you like.) =================--
function ERS_SetRandomDamageToVehicle(vehicle)
ERS_RequestNetControlForEntity(vehicle)
if DoesEntityExist(vehicle) then
SetVehicleBodyHealth(vehicle, math.random(0, 1000) + 0.0)
SetVehicleEngineHealth(vehicle, math.random(0, 1000) + 0.0)
-- Burst random tires
for i = 0, GetVehicleNumberOfWheels(vehicle) - 1 do
if math.random(100) < 10 then -- 10% chance to burst each tire
SetVehicleTyreBurst(vehicle, i, true, 1000.0)
end
end
-- Apply visual damage
for i = 0, 5 do -- Randomly damage some parts of the vehicle
if math.random(100) < 70 then -- 70% chance to apply damage to each part
SetVehicleDamage(vehicle, 0.5 * i, 0.5 * i, 0.5 * i, 500.0, 100.0, true)
end
end
else
if Config.Debug then
print("Vehicle does not exist.")
end
end
end
function ERS_CreateFlareAtCoordinate(coords)
AddExplosion(coords.x, coords.y, coords.z-1.0, 22, 1.0, true, false, 1.0)
end
function ERS_GivePedParachute(ped) -- Does not work on every ped.
ERS_RequestNetControlForEntity(ped)
if not DoesEntityExist(ped) then
if Config.Debug then
print("Ped does not exist.")
end
return
end
local weaponHash = GetHashKey("GADGET_PARACHUTE")
GiveWeaponToPed(ped, weaponHash, 1, false, true)
-- This sets the ped's parachute as visible if applicable to the model
SetPedComponentVariation(ped, 5, 8, 0, 2)
end
function ERS_SelectRandomPartyMusic()
local files = {
"party1",
"party2",
"party3",
}
local soundFile = files[math.random(#files)]
if Config.Debug then
print("Selected party music file: "..soundFile)
end
return soundFile
end
function ERS_CreateTemporaryBlipForEntities(entityList, timeoutInMs)
if Config.ShowBlipsForEntitiesOnCallouts then
local blipList = {}
local blip = nil
for index, entityNetId in pairs(entityList) do
local ent = NetworkGetEntityFromNetworkId(entityNetId)
ERS_RequestNetControlForEntity(ent)
if DoesEntityExist(ent) then
blip = AddBlipForEntity(ent)
SetBlipSprite(blip, Config.CalloutEntityBlipSprite)
SetBlipColour(blip, Config.CalloutEntityBlipColour)
SetBlipScale(blip, Config.CalloutEntityBlipScale)
SetBlipFlashes(blip, false)
-- SetBlipShowCone(blip, true)
table.insert(blipList, blip)
else
if Config.Debug then
print("Could not find entity with entityNetId "..entityNetId)
end
end
end
Citizen.SetTimeout(timeoutInMs, function()
for index, blipId in ipairs(blipList) do
if DoesBlipExist(blipId) then
RemoveBlip(blipId)
else
if Config.Debug then
print("Could not find blip with blipId "..blipId)
end
end
end
end)
else
if Config.Debug then
print("Showing blips for entities on callouts is disabled. The script will not create a blip for any entity.")
end
end
end