Skip to content

Commit 02315a1

Browse files
committed
Temp fix for zones
1 parent 858f21a commit 02315a1

1 file changed

Lines changed: 33 additions & 7 deletions

File tree

‎client/cl_selling.lua‎

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,58 @@
33
local SoldPeds = {}
44
local SellZone = {}
55
local currentZone = nil
6+
local sellZones = {}
67

78
-- \ Create Zones for the drug sales
8-
99
if not Config.SellEverywhere['enabled'] then
1010
for k, v in pairs(Config.SellZones) do
1111
local coords = {}
1212
for _, point in ipairs(v.points) do
1313
table.insert(coords, vector3(point.x, point.y, point.z))
1414
end
1515

16-
lib.zones.poly({
16+
sellZones[k] = lib.zones.poly({
1717
points = coords,
1818
thickness = v.thickness,
1919
debug = Config.DebugPoly,
20-
onEnter = function(self)
20+
onEnter = function()
21+
lib.print.info('Zone Entered: '..k)
2122
CreateSellingTargets()
2223
currentZone = k
23-
if Config.Debug then print("Entered Zone ["..k.."]") end
24+
if Config.Debug then lib.print.info("Entered Zone ["..k.."]") end
2425
end,
25-
onExit = function(self)
26+
onExit = function()
27+
lib.print.info('Zone Exited: '..k)
2628
currentZone = nil
2729
RemoveSellTarget()
28-
if Config.Debug then print("Exited Zone ["..k.."]") end
30+
if Config.Debug then lib.print.info("Exited Zone ["..k.."]") end
31+
end,
32+
inside = function()
33+
if Config.Debug then lib.print.info("Inside Zone ["..k.."]") end
2934
end
3035
})
36+
lib.print.info('Zone Created: '..k)
3137
end
3238
end
3339

40+
CreateThread(function()
41+
if not Config.SellEverywhere['enabled'] and Config.ManualZoneChecker then
42+
while true do
43+
Wait(1000)
44+
local ped = PlayerPedId()
45+
local pedCoords = GetEntityCoords(ped)
46+
for k, zone in pairs(sellZones) do
47+
if zone:contains(pedCoords) then
48+
if currentZone ~= k then
49+
zone:onEnter()
50+
end
51+
if Config.Debug then lib.print.info("Inside Zone ["..k.."]") end
52+
end
53+
end
54+
end
55+
end
56+
end)
57+
3458
-- \ Play five animation for both player and ped
3559
local function PlayGiveAnim(tped)
3660
local pid = PlayerPedId()
@@ -86,7 +110,6 @@ RegisterNetEvent('it-drugs:client:checkSellOffer', function(entity)
86110
end
87111

88112
local zoneConfig = nil
89-
local currentZone = nil
90113
if Config.SellEverywhere['enabled'] then
91114
zoneConfig = Config.SellEverywhere
92115
else
@@ -126,6 +149,9 @@ RegisterNetEvent('it-drugs:client:checkSellOffer', function(entity)
126149
end
127150
end
128151

152+
lib.print.info('Player Items: '..playerItems)
153+
lib.print.info('sellAmount: '..sellAmount)
154+
129155
if playerItems < sellAmount then
130156
sellAmount = playerItems
131157
end

0 commit comments

Comments
 (0)