diff --git a/[core]/es_extended/client/functions.lua b/[core]/es_extended/client/functions.lua index af1c9183..6927656c 100644 --- a/[core]/es_extended/client/functions.lua +++ b/[core]/es_extended/client/functions.lua @@ -140,40 +140,23 @@ ESX.HashString = function(str) return input_map end -if GetResourceState("esx_context") ~= "missing" then - function ESX.OpenContext(...) - exports["esx_context"]:Open(...) - end +local contextAvailable = GetResourceState("esx_contex") ~= "missing" - function ESX.PreviewContext(...) - exports["esx_context"]:Preview(...) - end - - function ESX.CloseContext(...) - exports["esx_context"]:Close(...) - end - - function ESX.RefreshContext(...) - exports["esx_context"]:Refresh(...) - end -else - function ESX.OpenContext() - print("[^1ERROR^7] Tried to ^5open^7 context menu, but ^5esx_context^7 is missing!") - end - - function ESX.PreviewContext() - print("[^1ERROR^7] Tried to ^5preview^7 context menu, but ^5esx_context^7 is missing!") - end - - function ESX.CloseContext() - print("[^1ERROR^7] Tried to ^5close^7 context menu, but ^5esx_context^7 is missing!") - end - - function ESX.RefreshContext() - print("[^1ERROR^7] Tried to ^5Refresh^7 context menu, but ^5esx_context^7 is missing!") - end +function ESX.OpenContext(...) + return contextAvailable and exports["esx_context"]:Open(...) or not contextAvailable and print("[^1ERROR^7] Tried to ^5open^7 context menu, but ^5esx_context^7 is missing!") end +function ESX.PreviewContext(...) + return contextAvailable and exports["esx_context"]:Preview(...) or not contextAvailable and print("[^1ERROR^7] Tried to ^5preview^7 context menu, but ^5esx_context^7 is missing!") +end + +function ESX.CloseContext(...) + return contextAvailable and exports["esx_context"]:Close(...) or not contextAvailable and print("[^1ERROR^7] Tried to ^5close^7 context menu, but ^5esx_context^7 is missing!") +end + +function ESX.RefreshContext(...) + return contextAvailable and exports["esx_context"]:Refresh(...) or not contextAvailable and print("[^1ERROR^7] Tried to ^5Refresh^7 context menu, but ^5esx_context^7 is missing!") +end ESX.RegisterInput = function(command_name, label, input_group, key, on_press, on_release) RegisterCommand(on_release ~= nil and "+" .. command_name or command_name, on_press)