Jump to content

Need Help


Ayee

Recommended Posts

  • Moderators
local names = {
    [411] = "Ferrari",
    [555] = "Porsche", -- copy lines
}

setPlayerHudComponentVisible("vehicle_name", false)

local x,y = guiGetScreenSize()
local timer = nil
local showName = nil

function showVehName()
    if not showName then return end
    dxDrawText(showName, 1, y/1.5+1, x+1, y+1, tocolor(0,0,0,120), 2.5, "default-bold", "center", "center")
    dxDrawText(showName, 0, y/1.5, x, y, tocolor(220,220,220,180), 2.5, "default-bold", "center", "center")
end


addEventHandler("onClientVehicleEnter", getRootElement(), function(player)
    if player ~= localPlayer then return end
        
    if isTimer(timer) then killTimer(timer) removeEventHandler("onClientRender", getRootElement(), showVehName) showName = nil end
    
    local vehModel = getElementModel(source)
    local vehName = getVehicleNameFromModel(vehModel)
    if names[vehModel] then vehName = names[vehModel] end
        
    showName = vehName
        
    addEventHandler("onClientRender", getRootElement(), showVehName)
    setTimer(function() removeEventHandler("onClientRender", getRootElement(), showVehName) showName = nil end, 3000, 1)
end)

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...