Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local screenSize = {guiGetScreenSize()}
- local mainScale = 1 / 0.3 * screenSize[1] / screenSize[2]
- local maxScaleCurve = {{0, 0}, {3, 3}, {13, 5}}
- local rendering = true
- local font = dxCreateFont( "files/Roboto.ttf", 14, true )
- --[[addEventHandler("onClientRender", root, function()
- if rendering then
- for _, car in ipairs(getElementsByType("vehicle")) do
- if types[getVehicleType(car)] and (getElementData(car, "veh:plate") or getVehiclePlateText(car)) then
- if isElementOnScreen(car) and car ~= getPedOccupiedVehicle(localPlayer) then
- local plateText = getVehiclePlateText(car) or getElementData(car, "veh:plate")
- local localPosition = {getElementPosition(localPlayer)}
- local carPosition = {getElementPosition(car)}
- local worldPosition = {getScreenFromWorldPosition(carPosition[1], carPosition[2], carPosition[3] + 1.3)}
- local distance = getDistanceBetweenPoints3D(localPosition[1], localPosition[2], localPosition[3], carPosition[1], carPosition[2], carPosition[3])
- local scale = 2 / (mainScale * (distance / 100))
- local scale = curving(scale) / 3
- if distance <= 15 then
- local plateTextX = dxGetTextWidth(plateText, 1.4, "default-bold", true)
- if worldPosition[1] and worldPosition[2] and scale then
- dxDrawRectangleBox(worldPosition[1]-plateTextX/2-5, worldPosition[2]-10*scale, plateTextX+10, 20)
- dxDrawText(plateText, worldPosition[1]-plateTextX/2, worldPosition[2]-10*scale, plateTextX+10, 20, tocolor(255,255,255), 1.4, "default-bold")
- end
- end
- end
- end
- end
- end
- end)]]--
- local vehicleTable = {}
- local vehiclePlate = ''
- --local customFont = dxCreateFont('files/icons.ttf',30, false)
- local renderVehDistance = 15
- local showVehicle = true
- local distance = 0
- function isBike(veh)
- if getElementType(veh) == "vehicle" then
- if getVehicleType(veh) == "Helicopter" or getVehicleType(veh) == "BMX" or getVehicleType(veh) == "Boat" or getVehicleType(veh) == "Quad" then
- return true
- else
- return false
- end
- else
- return false
- end
- end
- function refresVehicleTable(element)
- thisTimer1 = setTimer(function()
- if getElementType(element)=="vehicle" and not isBike(element) then
- vehicleTable[element] = {getVehiclePlateText(element)}
- end
- end,1000,0)
- end
- addEventHandler("onClientElementStreamIn", root, function ()
- local type = getElementType (source)
- if showVehicle then
- if type == "vehicle" then
- refresVehicleTable(source)
- setPlayerNametagShowing (source,false)
- end
- end
- end)
- addEventHandler( "onClientElementStreamOut", root, function ()
- local type = getElementType (source)
- if showVehicle then
- if type == "vehicle"then
- vehicleTable[source] = nil
- setPlayerNametagShowing (source,false)
- end
- end
- end)
- function streamAllVehicles()
- for k,v in ipairs(getElementsByType("vehicle")) do
- if isElementStreamedIn(v) then
- refresVehicleTable(v)
- end
- end
- end
- streamAllVehicles()
- addEventHandler("onClientRender", root, function()
- if showVehicle then
- local px,py,pz = getElementPosition(localPlayer)
- for k,value in pairs(vehicleTable) do
- if isElement(k) then
- x,y,z = getElementPosition(k)
- distance = getDistanceBetweenPoints3D(px,py,pz,x,y,z)
- local plateText = getVehiclePlateText(k) or getElementData(k, "veh:plate")
- local localPosition = {getElementPosition(localPlayer)}
- local carPosition = {getElementPosition(k)}
- local worldPosition = {getScreenFromWorldPosition(carPosition[1], carPosition[2], carPosition[3] + 1.3)}
- local distance = getDistanceBetweenPoints3D(localPosition[1], localPosition[2], localPosition[3], carPosition[1], carPosition[2], carPosition[3])
- local scale = 2 / (mainScale * (distance / 100))
- local scale = curving(scale) / 3
- if (distance <= renderVehDistance and not(getElementAlpha(k)==0) and isLineOfSightClear(px, py, pz, x, y, z, true, false, false, true, false, false, false) and getPedOccupiedVehicle(localPlayer) ~= k) then
- local progress = distance/renderVehDistance
- local size = interpolateBetween (0.8,0,0,0.2,0,0,progress,"OutQuad") * 0.9
- if size >= 3.5 then
- size = 3.5
- end
- if(tostring(getElementType(k))=="vehicle") and vehicleTable[k] then
- vehiclePlate = vehicleTable[k][1]
- else
- vehiclePlate = "#ffffffIsmeretlen"
- end
- local vehpanel = { getScreenFromWorldPosition ( x, y, z+2 ) }
- if vehpanel[1] and vehpanel[2] then
- --dxDrawText (vehiclePlate:gsub("#%x%x%x%x%x%x", "") , vehpanel[1]+1, vehpanel[2]+1, vehpanel[1]+1, vehpanel[2]+1, tocolor(0,0,0,255), 1.4, "default-bold", "center","center",false,false,false,true )
- --dxDrawText (vehiclePlate , vehpanel[1], vehpanel[2], vehpanel[1], vehpanel[2], tocolor(255,255,255,255), 1.4, "default-bold", "center","center",false,false,false,true )
- local plateTextX = dxGetTextWidth(plateText, 1, "font", true)
- --dxDrawRectangleBox(worldPosition[1]-plateTextX/2-50, worldPosition[2]-10*scale,150, 25)
- --dxDrawText(vehiclePlate:gsub("#%x%x%x%x%x%x", ""), worldPosition[1]-plateTextX/2-10, worldPosition[2]-10*scale,150, 25, tocolor(0,0,0),1,font)
- dxDrawRectangleBox(worldPosition[1]-75, worldPosition[2]-10*scale,150, 25)
- dxDrawText(vehiclePlate:gsub("#%x%x%x%x%x%x", ""), worldPosition[1]-75, worldPosition[2]-10*scale,worldPosition[1]-75+150, worldPosition[2]-10*scale+25, tocolor(0,0,0),1,font,"center","center")
- end
- end
- end
- end
- end
- end, true, "low-5")
- --[[function disabledVehicel()
- showVehicle = not showVehicle
- end
- addCommandHandler("offplate", disabledVehicel)]]--
- bindKey("f10", "down", function()
- rendering = not rendering
- showVehicle = not showVehicle
- end)
- function dxDrawRectangleBox(left, top, width, height)
- dxDrawRectangle(left, top, width, height, tocolor(255,255,255,240))
- dxDrawRectangle(left-1, top, 1, height, tocolor(0,0,0,220))
- dxDrawRectangle(left+width, top, 1, height, tocolor(0,0,0,220))
- dxDrawRectangle(left, top-1, width, 1, tocolor(0,0,0,220))
- dxDrawRectangle(left, top+height, width, 1, tocolor(0,0,0,220))
- end
- function math.lerp(from, to, alpha)
- return from + (to - from) * alpha
- end
- function curving(scaleCalc)
- if scaleCalc < maxScaleCurve[1][1] then
- return maxScaleCurve[1][2]
- end
- for idx = 2,#maxScaleCurve do
- if scaleCalc < maxScaleCurve[idx][1] then
- local x1 = maxScaleCurve[idx - 1][1]
- local y1 = maxScaleCurve[idx - 1][2]
- local x2 = maxScaleCurve[idx][1]
- local y2 = maxScaleCurve[idx][2]
- local alpha = (scaleCalc - x1)/(x2 - x1);
- return math.lerp(y1,y2,alpha)
- end
- end
- return maxScaleCurve[#maxScaleCurve][2]
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement