spfont = dxCreateFont("fonts/font.ttf", 21)
local isAdded = false
function speed()
if(isAdded == false) then
addEventHandler ("onClientRender", root, getspeed)
isAdded = true
end
end
addEventHandler("onClientVehicleEnter", root, speed)
function wylacz ()
if(isAdded == true) then
removeEventHandler("onClientRender", root, getspeed)
isAdded = false
end
end
addEventHandler("onClientVehicleExit", root, wylacz)
function getspeed()
local playerVehicle = getPedOccupiedVehicle(localPlayer)
if(playerVehicle) then
local sx, sy, sz = getElementVelocity(playerVehicle)
kmhs = math.floor(((sx^2 + sy^2 + sz^2)^(0.5))*180)
mphs = math.floor((((sx^2 + sy^2 + sz^2)^(0.5))*180)/1.6)
health = getElementHealth(playerVehicle)
name = getVehicleName(playerVehicle)
currenthealth = math.floor(health/10)
screenWidth, screenHeight = guiGetScreenSize()
windowWidth, windowHeight = 300,170
left = screenWidth/1.18 - windowWidth/9.8
top = screenHeight/1.03 - windowHeight/20
dxDrawText ( " "..tostring(kmhs).."km/h", left , top +2, screenWidth +2, screenHeight , tocolor ( 255, 255, 255, 255 ), 1, spfont )
dxDrawText ( " "..tostring(kmhs).."km/h", left -2, top, screenWidth, screenHeight -2, tocolor ( 255, 255, 0, 255 ), 1, spfont )
dxDrawText ( " "..tostring(mphs).."mph", left , top -23, screenWidth +2, screenHeight , tocolor ( 255, 255, 255, 255 ), 1, spfont )
dxDrawText ( " "..tostring(mphs).."mph", left -2, top -25, screenWidth, screenHeight -2, tocolor ( 255, 255, 0, 255 ), 1, spfont )
end
end
try this