♻️(client/functions): context functions

This commit is contained in:
Thekuca
2023-07-17 14:35:00 +02:00
committed by GitHub
parent c4a82b464e
commit 6f5cdcb045
+14 -31
View File
@@ -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)