Skip to content

Commit 9da17ce

Browse files
authored
Merge pull request #4 from MichaelCoding25/Fix-Threads
Fix Threads and add destination text
2 parents c9daaf8 + c2770fe commit 9da17ce

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

cl.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
---@field code string
33
---@type table<number, PostalData>
44
postals = nil
5-
CreateThread(function()
5+
Citizen.CreateThread(function()
66
postals = LoadResourceFile(GetCurrentResourceName(), GetResourceMetadata(GetCurrentResourceName(), 'postal_file'))
77
postals = json.decode(postals)
88
for i, postal in ipairs(postals) do postals[i] = { vec(postal.x, postal.y), code = postal.code } end

cl_render.lua

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ local AddTextComponentSubstringPlayerName = AddTextComponentSubstringPlayerName
1818
local nearestPostalText = ""
1919

2020
-- recalculate current postal
21-
CreateThread(function()
21+
Citizen.CreateThread(function()
2222
-- wait for postals to load
2323
while postals == nil do Wait(1) end
2424

@@ -46,20 +46,26 @@ CreateThread(function()
4646
end
4747

4848
if pBlip and #(pBlip.p[1] - coords) < deleteDist then
49-
print("You've reached your postal destination!")
49+
TriggerEvent('chat:addMessage', {
50+
color = { 255, 0, 0 },
51+
args = {
52+
'Postals',
53+
"You've reached your postal destination!"
54+
}
55+
})
5056
RemoveBlip(pBlip.hndl)
5157
pBlip = nil
5258
end
5359

5460
local _code = postals[_nearestIndex].code
5561
nearest = { code = _code, dist = _nearestD }
5662
nearestPostalText = format(formatTemplate, _code, _nearestD)
57-
Wait(delay)
63+
Citizen.Wait(delay)
5864
end
5965
end)
6066

6167
-- text display thread
62-
CreateThread(function()
68+
Citizen.CreateThread(function()
6369
local posX = config.text.posX
6470
local posY = config.text.posY
6571
local _string = "STRING"
@@ -74,6 +80,6 @@ CreateThread(function()
7480
AddTextComponentSubstringPlayerName(nearestPostalText)
7581
EndTextCommandDisplayText(posX, posY)
7682
end
77-
Wait(0)
83+
Citizen.Wait(0)
7884
end
7985
end)

fxmanifest.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ lua54 "yes"
1212

1313
author 'blockba5her'
1414
description 'This script displays the nearest postal next to map, and allows you to navigate to specific postal codes'
15-
version '1.5.0'
15+
version '1.5.1'
1616
url 'https://github.com/blockba5her/nearest-postal'
1717

1818
client_scripts {

sv.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- version check
2-
CreateThread(function()
2+
Citizen.CreateThread(function()
33
local vRaw = LoadResourceFile(GetCurrentResourceName(), 'version.json')
44
if vRaw and config.versionCheck then
55
local v = json.decode(vRaw)

version.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"version": "1.5.0",
3-
"changelog": "Rewrite and performance improvements"
4-
}
2+
"version": "1.5.1",
3+
"changelog": "Fix Threads and add destination text"
4+
}

0 commit comments

Comments
 (0)