Add function to makeDistPed that runs after creation

Kept forgetting to do this

When using `makeDistPed()` (making a npc that only appears when nearby) you can now send a function to apply custom modifiers to it after the npc is created

eg.
```lua
makeDistPed(v.model[i], b, true, false, v.scenario, nil, nil, function(ped)
	if v["killable"] then
		SetEntityInvincible(ped, false)
		SetBlockingOfNonTemporaryEvents(ped, false)
		FreezeEntityPosition(ped, false)
	end
end)
```
This commit is contained in:
Jim Shield
2025-07-29 12:25:31 +01:00
parent f09e34b1b5
commit 6cfb776eb4

View File

@@ -18,7 +18,7 @@ local Peds = {}
-- ```lua
-- makeDistPed(pedData, pedCoords, true, false, 'WORLD_HUMAN_STAND_IMPATIENT', nil, true)
-- ```
function makeDistPed(data, coords, freeze, collision, scenario, anim, synced)
function makeDistPed(data, coords, freeze, collision, scenario, anim, synced, func)
local zoneCoords = type(data) == "table" and data.coords or coords
local randName = keyGen()..keyGen()
createCirclePoly({
@@ -27,6 +27,7 @@ function makeDistPed(data, coords, freeze, collision, scenario, anim, synced)
radius = 50.0,
onEnter = function()
Peds[randName] = makePed(data, coords, freeze, collision, scenario, anim, synced)
if func then func(Peds[randName]) end
end,
onExit = function()
DeletePed(Peds[randName])