From 008e51f45bdc06d8d047e71dd0b64fdbda0d165a Mon Sep 17 00:00:00 2001 From: Luna Alfien Date: Wed, 7 May 2025 21:14:25 -0700 Subject: [PATCH] Allow other resources to trigger route creation --- cl.lua | 1 + cl_commands.lua | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/cl.lua b/cl.lua index c5296d2..28043c1 100644 --- a/cl.lua +++ b/cl.lua @@ -20,3 +20,4 @@ nearest = nil pBlip = nil exports('getPostal', function() return nearest and nearest.code or nil end) +exports('setDirections', function(postal) SetRouteToPostal(postal) end) diff --git a/cl_commands.lua b/cl_commands.lua index 7ce1796..70c568a 100644 --- a/cl_commands.lua +++ b/cl_commands.lua @@ -8,11 +8,8 @@ local format = string.format --- [[ Nearest Postal Commands ]] --- --- -TriggerEvent('chat:addSuggestion', '/postal', 'Set the GPS to a specific postal', - { { name = 'Postal Code', help = 'The postal code you would like to go to' } }) - -RegisterCommand('postal', function(_, args) - if #args < 1 then +function SetRouteToPostal(postal) + if not postal then if pBlip then RemoveBlip(pBlip.hndl) pBlip = nil @@ -27,7 +24,7 @@ RegisterCommand('postal', function(_, args) return end - local userPostal = upper(args[1]) + local userPostal = upper(postal) local foundPostal for _, p in ipairs(postals) do @@ -65,5 +62,12 @@ RegisterCommand('postal', function(_, args) } }) end +end + +TriggerEvent('chat:addSuggestion', '/postal', 'Set the GPS to a specific postal', + { { name = 'Postal Code', help = 'The postal code you would like to go to' } }) + +RegisterCommand('postal', function(_, args) + SetRouteToPostal(args[1]) end)