xF_Micka Posted January 21, 2014 Share Posted January 21, 2014 Hi. I have found a good speedometer on a server, here are the code extract from the client : --[[ @author: William DA SILVA @date: 12/08/2013 @website: [url=http://www.william-da-silva.net/]http://www.william-da-silva.net/[/url] @twitter: @willia_am @skype: willia_am @licence: DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004 Copyright (C) 2004 Sam Hocevar <[email protected]> Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed. DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. You just DO WHAT THE FUCK YOU WANT TO. ]] screenX, screenY = guiGetScreenSize(); Speed = {} function onClientResourceStart(resource) function Speed.render() if getLocalPlayer() then if isElement(localPlayer) then if isPedInVehicle(localPlayer) then local speed = getElementSpeed(getPedOccupiedVehicle(localPlayer), "kmh") if speed then -- RED --dxDrawRectangle((1*screenX)-(1*screenX), 0.89*screenY, 63.9, 0.03*screenY, tocolor(255, 64, 64, 255)) -- GREY --dxDrawRectangle((1*screenX)-(1*screenX), 0.89*screenY, 0.030*screenX, 0.03*screenY, tocolor(58, 58, 58, 255)) -- FPS --dxDrawText(FPSCalc.."",(1*screenX)-0.99*screenX, 0.89*screenY+(dxGetFontHeight(0.9, "default")/4), 5, 0.03*screenY, tocolor(255, 255, 255, 255), screenX*0.0008, "default") -- Blue dxDrawRectangle((1*screenX)-(1*screenX), 0.93*screenY, (0.065*screenX), (0.03*screenY), tocolor(32, 146, 234, 255)) -- Grey dxDrawRectangle((1*screenX)-(1*screenX), 0.93*screenY, (0.06*screenX), (0.03*screenY), tocolor(58, 58, 58, 255)) -- Speed if(speed <= 90) then dxDrawText(tostring(speed).." km/h", (1*screenX)-(0.99*screenX), (0.93*screenY)+(dxGetFontHeight(0.9, "default")/4), 5, 0.03*screenY,tocolor(118 ,238, 0, 255), screenX*0.0008, "default") end if(speed <= 120 and speed > 90) then dxDrawText(tostring(speed).." km/h", (1*screenX)-(0.99*screenX), (0.93*screenY)+(dxGetFontHeight(0.9, "default")/4), 5, 0.03*screenY,tocolor(255 ,127 , 36, 255), screenX*0.0008, "default") end if(speed > 120) then dxDrawText(tostring(speed).." km/h", (1*screenX)-(0.99*screenX), (0.93*screenY)+(dxGetFontHeight(0.9, "default")/4), 5, 0.03*screenY,tocolor(255 ,64 ,64 ,255), screenX*0.0008, "default") end end end end end end function getElementSpeed(element,unit) if (unit == nil) then unit = 0 end if (isElement(element)) then local x,y,z = getElementVelocity(element) if (unit=="mph" or unit==1 or unit =='1') then return math.floor((x^2 + y^2 + z^2) ^ 0.5 * 100) else return math.floor((x^2 + y^2 + z^2) ^ 0.5 * 1.8 * 100) end else return false end end --[[ Events ]]-- addEventHandler("onClientRender", getRootElement(), Speed.render) end addEventHandler ( "onClientResourceStart", getRootElement (), onClientResourceStart ) What script is it plz ? Link to comment
Castillo Posted January 21, 2014 Share Posted January 21, 2014 Show us how it looks like. Link to comment
xF_Micka Posted January 21, 2014 Author Share Posted January 21, 2014 Look that : Just below the radar. Thanks! Link to comment
Castillo Posted January 22, 2014 Share Posted January 22, 2014 I don't believe I have seen that resource on the MTA community, so it must be a private script made for the server you seen using it. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now