Skip to content

Commit 84a08a3

Browse files
authored
Adding ATMs support when target.enabled is false (#72)
* Adding ATMs support when target.enabled is false I tried to do something clean, it doesn't display any markers but it'll show Help notification when you're close to an atm * Fix fails * Cleaning things Raw text is used, I had to edit the helping part because ClearHelp didn't wanted to do a proper thing, so, everything's working now.
1 parent 3669546 commit 84a08a3

1 file changed

Lines changed: 25 additions & 11 deletions

File tree

src/client/lua/interaction.lua

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
local config = json.decode(LoadResourceFile(GetCurrentResourceName(), "config.json"))
22
local bank_coords = config.bankBlips.coords
3+
local atm_props = config.atms.props
34

4-
5-
function display_help_text()
5+
function display_help_text(text)
66
BeginTextCommandDisplayHelp("STRING")
7-
AddTextComponentString("Open bank: ~INPUT_PICKUP~")
8-
EndTextCommandDisplayHelp(0, true, false, -1)
7+
AddTextComponentString(text)
8+
EndTextCommandDisplayHelp(0, false, false, -1)
99
end
1010

1111
CreateThread(function ()
12-
12+
1313
if not config.target.enabled then
1414
while true do
1515
local player_id = PlayerPedId()
@@ -19,20 +19,34 @@ CreateThread(function ()
1919
for i = 1, #bank_coords do
2020
local pos = bank_coords[i]
2121

22-
local dist = #(player_coords - vector3(pos.x, pos.y, pos.z))
23-
if dist <= 10.0 then
22+
local distBank = #(player_coords - vector3(pos.x, pos.y, pos.z))
23+
if distBank <= 10.0 then
2424
DrawMarker(2, pos.x, pos.y, pos.z, 0.0, 0.0, 0.0, 0.0, 180.0, 0.0, 0.5, 0.5, 0.3, 255, 255, 255, 50, false, true, 2, nil, nil, false)
2525

26-
if dist <= 3.5 then
27-
display_help_text()
26+
if distBank <= 3.5 then
27+
display_help_text("Open bank: ~INPUT_PICKUP~")
28+
2829

2930
if IsControlJustReleased(0, 38) then
3031
exports["pefcl"]:openBank()
3132
end
32-
else
33-
ClearHelp(true)
3433
end
3534

35+
sleep = 0
36+
end
37+
end
38+
39+
for i = 1, #atm_props do
40+
local prop = GetClosestObjectOfType(player_coords, 5.0, joaat(atm_props[i]), false, false, false)
41+
local pos = GetEntityCoords(prop)
42+
local distAtm = #(player_coords - pos)
43+
44+
if distAtm <= 2.0 then
45+
display_help_text("Open atm: ~INPUT_PICKUP~")
46+
47+
if IsControlJustReleased(0, 38) then
48+
exports["pefcl"]:openAtm()
49+
end
3650

3751
sleep = 0
3852
end

0 commit comments

Comments
 (0)