@@ -434,43 +434,6 @@ local function drawLoop()
434
434
if lastValidOptions then
435
435
shouldUpdate = not lib .table .matches (validOpts , lastValidOptions )
436
436
end
437
-
438
- if shouldUpdate and validOpts then
439
-
440
- local newOptions = {}
441
-
442
- for j = 1 , # validOpts do
443
- local opt = validOpts [j ]
444
- newOptions [opt ] = true
445
- activeOptions [opt ] = true
446
- local resp = (opt .onActive or opt .whileActive ) and utils .getResponse (opt )
447
-
448
- if opt .onActive and not activeOptions [opt ] then
449
- pcall (opt .onActive , resp )
450
- end
451
-
452
-
453
- if opt .whileActive then
454
- CreateThread (function ()
455
- while activeOptions [opt ] do
456
- pcall (opt .whileActive , resp )
457
- Wait (0 )
458
- end
459
- end )
460
- end
461
-
462
- end
463
-
464
- for j = 1 , # lastValidOptions do
465
- local opt = lastValidOptions [j ]
466
- if opt .onInactive and not newOptions [opt ] and activeOptions [opt ] then
467
- pcall (opt .onInactive , utils .getResponse (opt ))
468
- activeOptions [opt ] = nil
469
- end
470
- end
471
- end
472
-
473
- lastValidOptions = validOpts
474
437
end
475
438
476
439
nearbyData [i ] = {
@@ -507,9 +470,52 @@ local function drawLoop()
507
470
DrawSprite (dui .instance .dictName , dui .instance .txtName , 0.0 , 0.0 , 1.0 , 1.0 , 0.0 , 255 , 255 , 255 , 255 )
508
471
local newClosestId = item .bone or item .offset or item .entity or item .coordId
509
472
if data .shouldUpdate or lastClosestItem ~= newClosestId or lastValidCount ~= data .validCount then
473
+ local newOptions = {}
474
+
475
+ if data .validOpts then
476
+ for _ , opts in pairs (data .validOpts ) do
477
+ for j = 1 , # opts do
478
+ local opt = opts [j ]
479
+ newOptions [opt ] = true
480
+ if not activeOptions [opt ] then
481
+ activeOptions [opt ] = true
482
+ local resp = (opt .onActive or opt .whileActive ) and utils .getResponse (opt )
483
+
484
+ if opt .onActive then
485
+ pcall (opt .onActive , resp )
486
+ end
487
+
488
+ if opt .whileActive then
489
+ CreateThread (function ()
490
+ while activeOptions [opt ] do
491
+ pcall (opt .whileActive , resp )
492
+ Wait (0 )
493
+ end
494
+ end )
495
+ end
496
+ end
497
+ end
498
+ end
499
+ end
500
+
501
+ if lastValidOptions then
502
+ for _ , opts in pairs (lastValidOptions ) do
503
+ for j = 1 , # opts do
504
+ local opt = opts [j ]
505
+
506
+ if opt .onInactive and not newOptions [opt ] and activeOptions [opt ] then
507
+ pcall (opt .onInactive , utils .getResponse (opt ))
508
+ activeOptions [opt ] = nil
509
+ end
510
+ end
511
+ end
512
+ end
513
+
510
514
local resetIndex = lastClosestItem ~= newClosestId
511
515
lastClosestItem = newClosestId
512
516
lastValidCount = data .validCount
517
+ lastValidOptions = data .validOpts
518
+
513
519
store .current = {
514
520
options = data .validOpts ,
515
521
entity = item .entity ,
@@ -522,9 +528,9 @@ local function drawLoop()
522
528
else
523
529
local distance = # (playerCoords - coords )
524
530
if distance < config .maxInteractDistance and item .currentScreenDistance < math.huge then
525
- local distanceRatio = math.min (0.5 + (0.25 * (distance / 10.0 )), 1.0 )
526
- local scale = 0.025 * distanceRatio
527
- DrawSprite (' shared' , ' emptydot_32' , 0.0 , 0.0 , scale , scale * aspectRatio , 0.0 , r , g , b , a )
531
+ local distanceRatio = math.min (0.5 + (0.25 * (distance / 10.0 )), 1.0 )
532
+ local scale = 0.025 * distanceRatio
533
+ DrawSprite (' shared' , ' emptydot_32' , 0.0 , 0.0 , scale , scale * aspectRatio , 0.0 , r , g , b , a )
528
534
end
529
535
end
530
536
@@ -533,6 +539,16 @@ local function drawLoop()
533
539
end
534
540
535
541
if not foundValid and next (store .current ) then
542
+ for _ , opts in pairs (store .current .options ) do
543
+ for j = 1 , # opts do
544
+ local opt = opts [j ]
545
+
546
+ if opt .onInactive and activeOptions [opt ] then
547
+ pcall (opt .onInactive , utils .getResponse (opt ))
548
+ activeOptions [opt ] = nil
549
+ end
550
+ end
551
+ end
536
552
store .current = {}
537
553
lastClosestItem = nil
538
554
end
@@ -592,4 +608,4 @@ RegisterNUICallback('select', function(data, cb)
592
608
cb (1 )
593
609
end )
594
610
595
- CreateThread (BuilderLoop )
611
+ CreateThread (BuilderLoop )
0 commit comments