From c0f8853bd79c76321ac4f6a1e40890a7891e6945 Mon Sep 17 00:00:00 2001 From: Giana Date: Thu, 16 Feb 2023 21:31:38 -0600 Subject: [PATCH] Implement NPC setup --- client/main.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/client/main.lua b/client/main.lua index bb57d59..3f19aa6 100644 --- a/client/main.lua +++ b/client/main.lua @@ -1,3 +1,26 @@ +-- Events -- + +RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function() + TriggerEvent('g-drugselling:client:spawnNpcs') +end) + +RegisterNetEvent('g-drugselling:client:spawnNpcs', function() + for k, v in pairs(Config.SellLocations) do + if v.npc.enabled then + local npc = v.npc + RequestModel(GetHashKey(npc.ped)) + while not HasModelLoaded(GetHashKey(npc.ped)) do + Citizen.Wait(100) + end + local sellPed = CreatePed(7, GetHashKey(npc.Ped), v.coords.x, v.coords.y, v.coords.z - 0.97, npc.heading, 0, true, true) + FreezeEntityPosition(sellPed, true) + SetBlockingOfNonTemporaryEvents(sellPed, true) + TaskStartScenarioInPlace(sellPed, npc.scenario, 0, false) + SetEntityInvincible(sellPed, true) + end + end +end) + -- Threads -- -- Blip setup