-
Notifications
You must be signed in to change notification settings - Fork 4
/
client.lua
73 lines (64 loc) · 2 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
local cacheHandles = {}
local GetGamePool = GetGamePool
local CreateThread = CreateThread
local Wait = Wait
local GetEntityModel = GetEntityModel
local SetEntityAsMissionEntity = SetEntityAsMissionEntity
local DeleteEntity = DeleteEntity
local GetEntityCoords = GetEntityCoords
local FreezeEntityPosition = FreezeEntityPosition
local cObject = 'CObject'
local function FreezeObject(handle)
FreezeEntityPosition(handle, true)
end
local function DeleteObject(handle)
SetEntityAsMissionEntity(handle, true, true)
DeleteEntity(handle)
end
local function CheckObject(data, handle)
for _, metadata in pairs(data) do
if metadata.mode == FREEZE then
if metadata.pos then
local objCoord = GetEntityCoords(handle)
for _, vector in pairs(metadata.pos) do
if #(objCoord - vector) < 0.1 then
FreezeObject(handle)
break
end
end
else
FreezeObject(handle)
end
elseif metadata.mode == DELETE then
if metadata.pos then
local objCoord = GetEntityCoords(handle)
for _, vector in pairs(metadata.pos) do
if #(objCoord - vector) < 0.1 then
DeleteObject(handle)
break
end
end
else
DeleteObject(handle)
end
end
end
end
CreateThread(function()
while true do
local newCacheHandles = {}
for _, handle in pairs(GetGamePool(cObject)) do
newCacheHandles[handle] = true
if cacheHandles[handle] then
goto nextObject
end
local datas = Config.props[GetEntityModel(handle)]
if datas then
CheckObject(datas, handle)
end
::nextObject::
end
cacheHandles = newCacheHandles
Wait(500)
end
end)