|
1 | | -local QBCore = exports['qb-core']:GetCoreObject() |
| 1 | + |
2 | 2 | local fireworkTime = 0 |
3 | 3 | local fireworkLoc = nil |
4 | 4 | local fireworkList = { |
@@ -35,42 +35,20 @@ local fireworkList = { |
35 | 35 | } |
36 | 36 | } |
37 | 37 |
|
38 | | -local function DrawText3D(x, y, z, text) |
39 | | - SetTextScale(0.35, 0.35) |
40 | | - SetTextFont(4) |
41 | | - SetTextProportional(true) |
42 | | - SetTextColour(255, 255, 255, 215) |
43 | | - BeginTextCommandDisplayText('STRING') |
44 | | - SetTextCentre(true) |
45 | | - AddTextComponentSubstringPlayerName(text) |
46 | | - SetDrawOrigin(x, y, z, 0) |
47 | | - EndTextCommandDisplayText(0.0, 0.0) |
48 | | - local factor = (string.len(text)) / 370 |
49 | | - DrawRect(0.0, 0.0 + 0.0125, 0.017 + factor, 0.03, 0, 0, 0, 75) |
50 | | - ClearDrawOrigin() |
51 | | -end |
52 | | - |
53 | | -local function fireworkText() |
54 | | - CreateThread(function() |
55 | | - while true do |
56 | | - Wait(0) |
57 | | - if fireworkTime > 0 and fireworkLoc then |
58 | | - DrawText3D(fireworkLoc.x, fireworkLoc.y, fireworkLoc.z, Lang:t('firework.time_left') .. fireworkTime) |
59 | | - end |
60 | | - if fireworkTime <= 0 then break end |
61 | | - end |
62 | | - end) |
63 | | -end |
64 | 38 |
|
65 | 39 | local function startFirework(asset, coords) |
66 | 40 | fireworkTime = Config.Fireworks.delay |
67 | 41 | fireworkLoc = { x = coords.x, y = coords.y, z = coords.z } |
| 42 | + local pedCoords = GetEntityCoords(PlayerPedId()) |
68 | 43 | CreateThread(function() |
69 | | - fireworkText() |
70 | 44 | while fireworkTime > 0 do |
| 45 | + if #(pedCoords - vector3(coords.x, coords.y, coords.z)) < 50.0 then |
| 46 | + exports['qb-core']:DrawText(Lang:t('firework.time_left') .. ' ' .. fireworkTime) |
| 47 | + end |
71 | 48 | Wait(1000) |
72 | 49 | fireworkTime -= 1 |
73 | 50 | end |
| 51 | + exports['qb-core']:HideText() |
74 | 52 | UseParticleFxAssetNextCall('scr_indep_fireworks') |
75 | 53 | for _ = 1, math.random(5, 10), 1 do |
76 | 54 | local firework = fireworkList[asset][math.random(1, #fireworkList[asset])] |
|
0 commit comments