-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.lua
49 lines (40 loc) · 1.5 KB
/
client.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
local QBCore = exports['qb-core']:GetCoreObject()
local CreatePed = function(modelHash, coords, scenario)
local created_npc = CreatePed(5, modelHash, coords.x, coords.y, coords.z, true, true)
SetEntityHeading(created_npc, heading)
FreezeEntityPosition(created_npc, true)
SetEntityInvincible(created_npc, true)
SetBlockingOfNonTemporaryEvents(created_npc, true)
TaskStartScenarioInPlace(created_npc, scenario, 0, true)
end
local CreateProp = function(modelHash, coords)
local created_prop = CreateObject(modelHash, coords.x, coords.y, coords.z, true, true, false)
SetEntityHeading(created_prop, coords.w)
FreezeEntityPosition(created_prop, true)
SetEntityInvincible(created_prop, true)
end
local SpawnEntities = function()
CreateThread(function()
-- Spawn NPCs
for _, npc in pairs(Config.NPCs) do
local npcModel = GetHashKey(npc.modelHash)
RequestModel(npcModel)
while not HasModelLoaded(npcModel) do
Wait(1)
end
CreatePed(npcModel, npc.coords, npc.scenario)
end
-- Spawn Props
for _, prop in pairs(Config.Props) do
local propModel = GetHashKey(prop.modelHash)
RequestModel(propModel)
while not HasModelLoaded(propModel) do
Wait(1)
end
CreateProp(propModel, prop.coords)
end
end)
end
CreateThread(function()
SpawnEntities()
end)