From 448fdaa9fae1544a9644129de8e76d69e9a84c56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20N=27gadi?= Date: Sat, 5 Aug 2017 11:34:03 +0200 Subject: [PATCH] Add ESX.Game.Utils.DrawText3D --- .../es_extended/client/functions.lua | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/resources/[essential]/es_extended/client/functions.lua b/resources/[essential]/es_extended/client/functions.lua index d9c6be2a..195c4d71 100644 --- a/resources/[essential]/es_extended/client/functions.lua +++ b/resources/[essential]/es_extended/client/functions.lua @@ -15,6 +15,7 @@ ESX.UI.Menu = {} ESX.UI.Menu.RegisteredTypes = {} ESX.UI.Menu.Opened = {} ESX.Game = {} +ESX.Game.Utils = {} ESX.GetRandomString = function(length) @@ -649,6 +650,42 @@ ESX.Game.SetVehicleProperties = function(vehicle, props) end +ESX.Game.Utils.DrawText3D = function(coords, text, size) + + local onScreen, x, y = World3dToScreen2d(coords.x, coords.y, coords.z) + local camCoords = GetGameplayCamCoords() + local dist = GetDistanceBetweenCoords(camCoords.x, camCoords.y, camCoords.z, coords.x, coords.y, coords.z, 1) + local size = size + + if size == nil then + size = 1 + end + + local scale = (size / dist) * 2 + local fov = (1 / GetGameplayCamFov()) * 100 + local scale = scale * fov + + if onScreen then + + SetTextScale(0.0 * scale, 0.55 * scale) + SetTextFont(0) + SetTextProportional(1) + -- SetTextScale(0.0, 0.55) + SetTextColour(255, 255, 255, 255) + SetTextDropshadow(0, 0, 0, 0, 255) + SetTextEdge(2, 0, 0, 0, 150) + SetTextDropShadow() + SetTextOutline() + SetTextEntry('STRING') + SetTextCentre(1) + + AddTextComponentString(text) + + DrawText(x, y) + end + +end + ESX.ShowInventory = function() ESX.TriggerServerCallback('esx:getPlayerData', function(data)