|
3 | 3 | local SoldPeds = {} |
4 | 4 | local SellZone = {} |
5 | 5 | local currentZone = nil |
| 6 | +local sellZones = {} |
6 | 7 |
|
7 | 8 | -- \ Create Zones for the drug sales |
8 | | - |
9 | 9 | if not Config.SellEverywhere['enabled'] then |
10 | 10 | for k, v in pairs(Config.SellZones) do |
11 | 11 | local coords = {} |
12 | 12 | for _, point in ipairs(v.points) do |
13 | 13 | table.insert(coords, vector3(point.x, point.y, point.z)) |
14 | 14 | end |
15 | 15 |
|
16 | | - lib.zones.poly({ |
| 16 | + sellZones[k] = lib.zones.poly({ |
17 | 17 | points = coords, |
18 | 18 | thickness = v.thickness, |
19 | 19 | debug = Config.DebugPoly, |
20 | | - onEnter = function(self) |
| 20 | + onEnter = function() |
| 21 | + lib.print.info('Zone Entered: '..k) |
21 | 22 | CreateSellingTargets() |
22 | 23 | currentZone = k |
23 | | - if Config.Debug then print("Entered Zone ["..k.."]") end |
| 24 | + if Config.Debug then lib.print.info("Entered Zone ["..k.."]") end |
24 | 25 | end, |
25 | | - onExit = function(self) |
| 26 | + onExit = function() |
| 27 | + lib.print.info('Zone Exited: '..k) |
26 | 28 | currentZone = nil |
27 | 29 | 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 |
29 | 34 | end |
30 | 35 | }) |
| 36 | + lib.print.info('Zone Created: '..k) |
31 | 37 | end |
32 | 38 | end |
33 | 39 |
|
| 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 | + |
34 | 58 | -- \ Play five animation for both player and ped |
35 | 59 | local function PlayGiveAnim(tped) |
36 | 60 | local pid = PlayerPedId() |
@@ -86,7 +110,6 @@ RegisterNetEvent('it-drugs:client:checkSellOffer', function(entity) |
86 | 110 | end |
87 | 111 |
|
88 | 112 | local zoneConfig = nil |
89 | | - local currentZone = nil |
90 | 113 | if Config.SellEverywhere['enabled'] then |
91 | 114 | zoneConfig = Config.SellEverywhere |
92 | 115 | else |
@@ -126,6 +149,9 @@ RegisterNetEvent('it-drugs:client:checkSellOffer', function(entity) |
126 | 149 | end |
127 | 150 | end |
128 | 151 |
|
| 152 | + lib.print.info('Player Items: '..playerItems) |
| 153 | + lib.print.info('sellAmount: '..sellAmount) |
| 154 | + |
129 | 155 | if playerItems < sellAmount then |
130 | 156 | sellAmount = playerItems |
131 | 157 | end |
|
0 commit comments