Jump to content

Search a speedometer


xF_Micka

Recommended Posts

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

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...