client/functions.lua
-- All these functions are editable to suit your preferences and customization
-- Function used when the player interacts with the script and the message to open the Car Dealer shows.
function InteractText()
if Config.Framework == "esx" then
ESX.ShowHelpNotification(Locales.interaction)
elseif Config.Framework == "qb" then
DrawText3D(Config.Cardealer.Location.x, Config.Cardealer.Location.y, Config.Cardealer.Location.z, " "..Locales.interaction.." ")
end
end
-- Notification function which you may change to your prferences.
function Notification(message)
if Config.Framework == "esx" then
ESX.ShowNotification(message)
elseif Config.Framework == "qb" then
QBCore.Functions.Notify(message, "success")
end
end
-- The function that renders 3D text when interacting with the script.
function DrawText3D(x, y, z, text)
local on_screen, screenX, screenY = World3dToScreen2d(x, y, z)
if on_screen then
local factor = (string.len(text)) / 380
SetTextScale(0.36, 0.36)
SetTextFont(4)
SetTextColour(255, 255, 255, 215)
SetTextEntry("STRING")
SetTextCentre(true)
AddTextComponentSubstringPlayerName(text)
SetDrawOrigin(x, y, z, 0)
EndTextCommandDisplayText(0.0, -0.10)
DrawRect(0.0, -0.10+0.0125, 0.020+ factor, 0.03, 0, 0, 0, 80)
ClearDrawOrigin()
end
end
-- Event that's triggered when the vehicle is bought to let the server know you're the owner.(If you're not using qb-core you don't need to worry about it)
function SetOwner(plate)
TriggerEvent('vehiclekeys:client:SetOwner', plate)
end
Last updated