From 6cfb776eb4d83519eea94ed14a42fc894d86fcd9 Mon Sep 17 00:00:00 2001 From: Jim Shield Date: Tue, 29 Jul 2025 12:25:31 +0100 Subject: [PATCH] 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) ``` --- shared/make/makePed.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shared/make/makePed.lua b/shared/make/makePed.lua index 4b7119a..69c47b0 100644 --- a/shared/make/makePed.lua +++ b/shared/make/makePed.lua @@ -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])