Jump to content

question


WASSIm.

Recommended Posts

1- how make if player have nitro show icon

2- how make if lights on show icon

like this:

addEventHandler( "onClientRender", root, 
function light () 
local theVehicle = getPedOccupiedVehicle ( localPlayer )  
if ( isVehicleLocked( theVehicle ) ) then            dxDrawImage(0,0,0,0,"images/lock.png",0.0,20,20,tocolor(250,255,255,255),false) 
else 
dxDrawImage(0,0,0,0,"images/lock.png",0.0,20,20,tocolor(0,0,0,170),false) 
end 

Link to comment
addEventHandler ( "onClientRender", root, 
    function ( ) 
        local theVehicle = getPedOccupiedVehicle ( localPlayer ) 
        if ( theVehicle ) then 
            local color = ( isVehicleLocked ( theVehicle ) and tocolor(250,255,255,255) or tocolor(0,0,0,170) ) 
            dxDrawImage(0,0,0,0,"images/lock.png",0.0,20,20,color,false) 
        end 
    end 
) 

And what do you mean by "have nitro"?

Link to comment

You mean if he has the nitro upgrade, show an image? if so, use:

local ids = 
    { 
        [ 1008 ] = true, 
        [ 1009 ] = true, 
        [ 1010 ] = true 
    } 
  
local nitro = getVehicleUpgradeOnSlot ( theVehicle, 8 ) 
if ( ids [ nitro  ] ) then 
    -- Has nitro 
end 

Not sure if it works.

Link to comment
local ids = 
    { 
        [ 1008 ] = true, 
        [ 1009 ] = true, 
        [ 1010 ] = true 
    } 
  
local sx,sy = guiGetScreenSize() 
  
local enableVehicleHealth = true 
local enableFuelHealth = true 
local enableSpeedMeter = true 
local enablegps = true 
local enablelock = true 
local enableengine= true 
local enablenitro = true 
  
addEvent( "onClientSwitchDamageMeter" ) 
addEventHandler( "onClientSwitchDamageMeter", root, 
    function ( state ) 
        enableVehicleHealth = state 
    end 
) 
  
addEvent( "onClientSwitchFuelMeter" ) 
addEventHandler( "onClientSwitchFuelMeter", root, 
    function ( state ) 
        enableFuelHealth = state 
    end 
) 
  
addEvent( "onClientSwitchSpeedMeter" ) 
addEventHandler( "onClientSwitchSpeedMeter", root, 
    function ( state ) 
        enableSpeedMeter = state 
    end 
) 
  
addEventHandler( "onClientRender", root, 
    function() 
        local theVehicle = getPedOccupiedVehicle ( localPlayer )  
        if ( theVehicle ) then 
            local spx, spy, spz = getElementVelocity( theVehicle )   
            local kphSpeed = ( spx^2 + spy^2 + spz^2 ) ^ 0.5 * 1.61 * 100 
            local mphSpeed = ( spx^2 + spy^2 + spz^2 ) ^ 0.5 * 100 
            local vehiclespeed = mphSpeed 
             
            local vehicleHealth = ( getElementHealth( theVehicle ) ) 
            local vehicleFuel = getElementData( theVehicle, "vehicleFuel" ) 
             
            if ( enableVehicleHealth ) and ( enableFuelHealth ) and ( vehicleFuel ) then 
                hx1, hy1, hx2, hy2 = sx*(1155.0/1440),sy*(857.0/900),sx*(232.0/1440),sy*(27.0/900) 
                hx3, hy3, hx4, hy4 = sx*(1159.0/1440),sy*(861.0/900),vehicleHealth/10*sx*(224.0/1440)/100,sy*(19.0/900) 
                hx5, hy5, hx6, hy6 = sx*(1260.0/1440),sy*(860.0/900),sx*(26.0/1440),sy*(26.0/900) 
            elseif not ( vehicleFuel ) and ( enableVehicleHealth ) or ( enableVehicleHealth ) and not ( enableFuelHealth ) then 
                hx1, hy1, hx2, hy2 = sx*(1155.0/1440),sy*(857.0/900),sx*(232.0/1440),sy*(27.0/900) 
                hx3, hy3, hx4, hy4 = sx*(1159.0/1440),sy*(861.0/900),vehicleHealth/10*sx*(224.0/1440)/100,sy*(19.0/900) 
                hx5, hy5, hx6, hy6 = sx*(1260.0/1440),sy*(860.0/900),sx*(26.0/1440),sy*(26.0/900) 
            end 
                                                             if ( enableFuelHealth ) and ( enableVehicleHealth ) and ( vehicleFuel ) then 
                fx1, fy1, fx2, fy2 = sx*(1155.0/1440),sy*(817.0/900),sx*(232.0/1440),sy*(27.0/900) 
                fx3, fy3, fx4, fy4 = sx*(1159.0/1440),sy*(821.0/900),vehicleFuel*sx*(224.0/1440)/100,sy*(19.0/900) 
                fx5, fy5, fx6, fy6 = sx*(1260.0/1440),sy*(820.0/900),sx*(30.0/1440),sy*(30.0/900) 
            elseif ( vehicleFuel ) and ( enableFuelHealth ) and not ( enableVehicleHealth ) then 
                fx1, fy1, fx2, fy2 = sx*(1155.0/1440),sy*(817.0/900),sx*(232.0/1440),sy*(27.0/900) 
                fx3, fy3, fx4, fy4 = sx*(1159.0/1440),sy*(821.0/900),vehicleFuel*sx*(224.0/1440)/100,sy*(19.0/900) 
                fx5, fy5, fx6, fy6 = sx*(1260.0/1440),sy*(820.0/900),sx*(26.0/1440),sy*(26.0/900) 
            end 
                                                             if ( enableSpeedMeter ) then 
                sx1, sy1, sx2, sy2 = sx*(1155.0/1440),sy*(777.0/900),sx*(232.0/1440),sy*(27.0/900) 
                sx3, sy3, sx4, sy4 = sx*(1159.0/1440),sy*(781.0/900),vehiclespeed/1.5*sx*(224.0/1440)/100,sy*(19.0/900) 
                sx5, sy5, sx6, sy6 = sx*(1260.0/1440),sy*(780.0/900),sx*(26.0/1440),sy*(26.0/900) 
  
            local upgrades = getVehicleUpgrades ( theVehicle ) 
            local playerX, playerY, playerZ = getElementPosition ( localPlayer ) 
            local playerZoneName = getZoneName ( playerX, playerY, playerZ ) 
            local currenthealth = math.floor(vehicleHealth/10) 
  
            if ( vehicleHealth ) then 
                vehHealthColor = math.max(vehicleHealth - 250, 0)/750 
                vehHealthColorMath = -510*(vehHealthColor^2) 
                rh, gh = math.max(math.min(vehHealthColorMath + 255*vehHealthColor + 255, 255), 0), math.max(math.min(vehHealthColorMath + 765*vehHealthColor, 255), 0) 
            end 
  
            if ( vehicleFuel ) then 
                theFuel = ( vehicleFuel * 10 )  
                vehFuelColor = math.max(theFuel - 250, 0)/750 
                vehFuelthColorMath = -510*(vehFuelColor^2) 
                rf, gf = math.max(math.min(vehFuelthColorMath + 255*vehFuelColor + 255, 255), 0), math.max(math.min(vehFuelthColorMath + 750*vehFuelColor, 255), 0) 
            end 
  
            if ( vehiclespeed ) then 
                theSpeed = ( vehiclespeed * 6.5 )  
                vehSpeedColor = math.max(theSpeed - 250 , 0)/750 
                vehSpeedColorMath = -510*(vehSpeedColor^2) 
                rs, gs = math.max(math.min(vehSpeedColorMath + 255*vehSpeedColor + 0, 255), 0), math.max(math.min(vehSpeedColorMath + 750*vehSpeedColor, 255), 0) 
            end 
             
            if ( enableVehicleHealth ) then 
                dxDrawRectangle(hx1, hy1, hx2, hy2,tocolor(0,0,0,150),false) 
                dxDrawRectangle(hx3, hy3, hx4, hy4,tocolor(rh,gh,0,170),false) 
                dxDrawImage(hx5-150, hy5-2, hx6, hy6,"images/health.png",0.0,0.0,0.0,tocolor(255,255,255,0),false) 
                                                                                dxDrawText(""..tostring(currenthealth).."%",hx3+100, hy3-2, hx4, hy4,tocolor(255,255,255,255),1.6,"sans","left","top",false,false,false) 
            end 
             
            if ( enableFuelHealth ) and ( vehicleFuel ) then 
                dxDrawRectangle(fx1, fy1, fx2, fy2,tocolor(0,0,0,150),false) 
                dxDrawRectangle(fx3, fy3, fx4, fy4,tocolor(rf,gf,0,170),false) 
                dxDrawImage(fx5-150, fy5-5, fx6, fy6,"images/fuel.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) 
                                                                                dxDrawText(""..tostring(vehicleFuel).."%",fx3+100, fy3-2, fx4, fy4,tocolor(255,255,255,255),1.6,"sans","left","top",false,false,false) 
            end 
             
            if ( enableSpeedMeter )  then 
                dxDrawRectangle(sx1, sy1, sx2, sy2,tocolor(0,0,0,150),false) 
                dxDrawRectangle(sx3, sy3, sx4, sy4,tocolor(rs,gs,0,170),false) 
                dxDrawText(math.ceil(kphSpeed).." Kmh  / "..math.ceil(mphSpeed).." Mph",sx*(1120/1440),sy*(779/900),sx*(1435.0/1440),sy*(857.0/900),tocolor 
  
(255,255,255,255),1.6,"sans","center","top",false,false,false) 
            end 
  
            if ( enablegps ) and ( getVehicleEngineState ( theVehicle)  ) then 
                dxDrawText(""..tostring(playerZoneName).."",sx*(1158/1440),sy*(745.0/900),sx*(1435.0/1440),sy*(850.0/900),tocolor 
  
(255,255,255,255),1.6,"sans","left","top",false,false,false) 
                else 
                dxDrawText("Off",sx*(1158/1440),sy*(745.0/900),sx*(1435.0/1440),sy*(850.0/900),tocolor(255,255,255,255),1.6,"sans","left","top",false,false,false) 
            end 
  
            if ( enablelock ) and ( isVehicleLocked( theVehicle ) ) or ( getElementData( theVehicle, "vehicleLocked" ) ) then 
                    dxDrawImage(sx*(1390.0/1440),sy*(817.0/900),sx*(26.0/1440),sy*(26.0/900),"images/lock.png",0.0,0.0,0.0,tocolor(250,255,255,255),false) 
                else 
                    dxDrawImage(sx*(1390.0/1440),sy*(817.0/900),sx*(26.0/1440),sy*(26.0/900),"images/lock.png",0.0,0.0,0.0,tocolor(0,0,0,170),false) 
                end 
  
            if ( enablenitro ) and ( ids [ upgrades [ 8 ] ] ) then 
                    dxDrawImage(sx*(1390.0/1440),sy*(857.0/900),sx*(26.0/1440),sy*(26.0/900),"images/light.png",0.0,0.0,0.0,tocolor(250,255,255,255),false) 
                else 
                    dxDrawImage(sx*(1390.0/1440),sy*(857.0/900),sx*(26.0/1440),sy*(26.0/900),"images/light.png",0.0,0.0,0.0,tocolor(0,0,0,170),false) 
                end 
  
            if ( enableengine ) and ( getVehicleEngineState ( theVehicle) ) then 
                    dxDrawImage(hx5-150, hy5-2, hx6, hy6,"images/health.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) 
                    dxDrawImage(sx5-150, sy5-2, sx6, sy6,"images/speed.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) 
                                    dxDrawImage(sx5-150, sy5-35, sx6, sy6,"images/gps.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) 
                     
                else 
                    dxDrawImage(hx5-150, hy5-2, hx6, hy6,"images/health.png",0.0,0.0,0.0,tocolor(0,0,0,170),false) 
                    dxDrawImage(sx5-150, sy5-2, sx6, sy6,"images/speed.png",0.0,0.0,0.0,tocolor(0,0,0,170),false) 
                                    dxDrawImage(sx5-150, sy5-35, sx6, sy6,"images/gps.png",0.0,0.0,0.0,tocolor(0,0,0,170),false) 
                                                                                end 
            end 
        end 
   end 
) 

Link to comment
local ids = 
    { 
        [ 1008 ] = true, 
        [ 1009 ] = true, 
        [ 1010 ] = true 
    } 
  
local sx,sy = guiGetScreenSize() 
  
local enableVehicleHealth = true 
local enableFuelHealth = true 
local enableSpeedMeter = true 
local enablegps = true 
local enablelock = true 
local enableengine= true 
local enablenitro = true 
  
addEvent( "onClientSwitchDamageMeter" ) 
addEventHandler( "onClientSwitchDamageMeter", root, 
    function ( state ) 
        enableVehicleHealth = state 
    end 
) 
  
addEvent( "onClientSwitchFuelMeter" ) 
addEventHandler( "onClientSwitchFuelMeter", root, 
    function ( state ) 
        enableFuelHealth = state 
    end 
) 
  
addEvent( "onClientSwitchSpeedMeter" ) 
addEventHandler( "onClientSwitchSpeedMeter", root, 
    function ( state ) 
        enableSpeedMeter = state 
    end 
) 
  
addEventHandler( "onClientRender", root, 
    function() 
        local theVehicle = getPedOccupiedVehicle ( localPlayer ) 
        if ( theVehicle ) then 
            local nitro = getVehicleUpgradeOnSlot ( theVehicle, 8 ) 
            local spx, spy, spz = getElementVelocity( theVehicle )   
            local kphSpeed = ( spx^2 + spy^2 + spz^2 ) ^ 0.5 * 1.61 * 100 
            local mphSpeed = ( spx^2 + spy^2 + spz^2 ) ^ 0.5 * 100 
            local vehiclespeed = mphSpeed 
            
            local vehicleHealth = ( getElementHealth( theVehicle ) ) 
            local vehicleFuel = getElementData( theVehicle, "vehicleFuel" ) 
      
            if ( enableVehicleHealth ) and ( enableFuelHealth ) and ( vehicleFuel ) then 
                hx1, hy1, hx2, hy2 = sx*(1155.0/1440),sy*(857.0/900),sx*(232.0/1440),sy*(27.0/900) 
                hx3, hy3, hx4, hy4 = sx*(1159.0/1440),sy*(861.0/900),vehicleHealth/10*sx*(224.0/1440)/100,sy*(19.0/900) 
                hx5, hy5, hx6, hy6 = sx*(1260.0/1440),sy*(860.0/900),sx*(26.0/1440),sy*(26.0/900) 
            elseif not ( vehicleFuel ) and ( enableVehicleHealth ) or ( enableVehicleHealth ) and not ( enableFuelHealth ) then 
                hx1, hy1, hx2, hy2 = sx*(1155.0/1440),sy*(857.0/900),sx*(232.0/1440),sy*(27.0/900) 
                hx3, hy3, hx4, hy4 = sx*(1159.0/1440),sy*(861.0/900),vehicleHealth/10*sx*(224.0/1440)/100,sy*(19.0/900) 
                hx5, hy5, hx6, hy6 = sx*(1260.0/1440),sy*(860.0/900),sx*(26.0/1440),sy*(26.0/900) 
            end 
                                                             if ( enableFuelHealth ) and ( enableVehicleHealth ) and ( vehicleFuel ) then 
                fx1, fy1, fx2, fy2 = sx*(1155.0/1440),sy*(817.0/900),sx*(232.0/1440),sy*(27.0/900) 
                fx3, fy3, fx4, fy4 = sx*(1159.0/1440),sy*(821.0/900),vehicleFuel*sx*(224.0/1440)/100,sy*(19.0/900) 
                fx5, fy5, fx6, fy6 = sx*(1260.0/1440),sy*(820.0/900),sx*(30.0/1440),sy*(30.0/900) 
            elseif ( vehicleFuel ) and ( enableFuelHealth ) and not ( enableVehicleHealth ) then 
                fx1, fy1, fx2, fy2 = sx*(1155.0/1440),sy*(817.0/900),sx*(232.0/1440),sy*(27.0/900) 
                fx3, fy3, fx4, fy4 = sx*(1159.0/1440),sy*(821.0/900),vehicleFuel*sx*(224.0/1440)/100,sy*(19.0/900) 
                fx5, fy5, fx6, fy6 = sx*(1260.0/1440),sy*(820.0/900),sx*(26.0/1440),sy*(26.0/900) 
            end 
                                                             if ( enableSpeedMeter ) then 
                sx1, sy1, sx2, sy2 = sx*(1155.0/1440),sy*(777.0/900),sx*(232.0/1440),sy*(27.0/900) 
                sx3, sy3, sx4, sy4 = sx*(1159.0/1440),sy*(781.0/900),vehiclespeed/1.5*sx*(224.0/1440)/100,sy*(19.0/900) 
                sx5, sy5, sx6, sy6 = sx*(1260.0/1440),sy*(780.0/900),sx*(26.0/1440),sy*(26.0/900) 
  
            local upgrades = getVehicleUpgrades ( theVehicle ) 
            local playerX, playerY, playerZ = getElementPosition ( localPlayer ) 
            local playerZoneName = getZoneName ( playerX, playerY, playerZ ) 
            local currenthealth = math.floor(vehicleHealth/10) 
  
            if ( vehicleHealth ) then 
                vehHealthColor = math.max(vehicleHealth - 250, 0)/750 
                vehHealthColorMath = -510*(vehHealthColor^2) 
                rh, gh = math.max(math.min(vehHealthColorMath + 255*vehHealthColor + 255, 255), 0), math.max(math.min(vehHealthColorMath + 765*vehHealthColor, 255), 0) 
            end 
  
            if ( vehicleFuel ) then 
                theFuel = ( vehicleFuel * 10 ) 
                vehFuelColor = math.max(theFuel - 250, 0)/750 
                vehFuelthColorMath = -510*(vehFuelColor^2) 
                rf, gf = math.max(math.min(vehFuelthColorMath + 255*vehFuelColor + 255, 255), 0), math.max(math.min(vehFuelthColorMath + 750*vehFuelColor, 255), 0) 
            end 
  
            if ( vehiclespeed ) then 
                theSpeed = ( vehiclespeed * 6.5 ) 
                vehSpeedColor = math.max(theSpeed - 250 , 0)/750 
                vehSpeedColorMath = -510*(vehSpeedColor^2) 
                rs, gs = math.max(math.min(vehSpeedColorMath + 255*vehSpeedColor + 0, 255), 0), math.max(math.min(vehSpeedColorMath + 750*vehSpeedColor, 255), 0) 
            end 
            
            if ( enableVehicleHealth ) then 
                dxDrawRectangle(hx1, hy1, hx2, hy2,tocolor(0,0,0,150),false) 
                dxDrawRectangle(hx3, hy3, hx4, hy4,tocolor(rh,gh,0,170),false) 
                dxDrawImage(hx5-150, hy5-2, hx6, hy6,"images/health.png",0.0,0.0,0.0,tocolor(255,255,255,0),false) 
                                                                                dxDrawText(""..tostring(currenthealth).."%",hx3+100, hy3-2, hx4, hy4,tocolor(255,255,255,255),1.6,"sans","left","top",false,false,false) 
            end 
            
            if ( enableFuelHealth ) and ( vehicleFuel ) then 
                dxDrawRectangle(fx1, fy1, fx2, fy2,tocolor(0,0,0,150),false) 
                dxDrawRectangle(fx3, fy3, fx4, fy4,tocolor(rf,gf,0,170),false) 
                dxDrawImage(fx5-150, fy5-5, fx6, fy6,"images/fuel.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) 
                                                                                dxDrawText(""..tostring(vehicleFuel).."%",fx3+100, fy3-2, fx4, fy4,tocolor(255,255,255,255),1.6,"sans","left","top",false,false,false) 
            end 
            
            if ( enableSpeedMeter )  then 
                dxDrawRectangle(sx1, sy1, sx2, sy2,tocolor(0,0,0,150),false) 
                dxDrawRectangle(sx3, sy3, sx4, sy4,tocolor(rs,gs,0,170),false) 
                dxDrawText(math.ceil(kphSpeed).." Kmh  / "..math.ceil(mphSpeed).." Mph",sx*(1120/1440),sy*(779/900),sx*(1435.0/1440),sy*(857.0/900),tocolor(255,255,255,255),1.6,"sans","center","top",false,false,false) 
            end 
  
            if ( enablegps ) and ( getVehicleEngineState ( theVehicle)  ) then 
                dxDrawText(""..tostring(playerZoneName).."",sx*(1158/1440),sy*(745.0/900),sx*(1435.0/1440),sy*(850.0/900),tocolor(255,255,255,255),1.6,"sans","left","top",false,false,false) 
                else 
                dxDrawText("Off",sx*(1158/1440),sy*(745.0/900),sx*(1435.0/1440),sy*(850.0/900),tocolor(255,255,255,255),1.6,"sans","left","top",false,false,false) 
            end 
  
            if ( enablelock ) and ( isVehicleLocked( theVehicle ) ) or ( getElementData( theVehicle, "vehicleLocked" ) ) then 
                    dxDrawImage(sx*(1390.0/1440),sy*(817.0/900),sx*(26.0/1440),sy*(26.0/900),"images/lock.png",0.0,0.0,0.0,tocolor(250,255,255,255),false) 
                else 
                    dxDrawImage(sx*(1390.0/1440),sy*(817.0/900),sx*(26.0/1440),sy*(26.0/900),"images/lock.png",0.0,0.0,0.0,tocolor(0,0,0,170),false) 
                end 
            if ( enablenitro ) and ( ids [ nitro ] ) then 
                    dxDrawImage(sx*(1390.0/1440),sy*(857.0/900),sx*(26.0/1440),sy*(26.0/900),"images/light.png",0.0,0.0,0.0,tocolor(250,255,255,255),false) 
                else 
                    dxDrawImage(sx*(1390.0/1440),sy*(857.0/900),sx*(26.0/1440),sy*(26.0/900),"images/light.png",0.0,0.0,0.0,tocolor(0,0,0,170),false) 
                end 
  
            if ( enableengine ) and ( getVehicleEngineState ( theVehicle) ) then 
                    dxDrawImage(hx5-150, hy5-2, hx6, hy6,"images/health.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) 
                    dxDrawImage(sx5-150, sy5-2, sx6, sy6,"images/speed.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) 
                                    dxDrawImage(sx5-150, sy5-35, sx6, sy6,"images/gps.png",0.0,0.0,0.0,tocolor(255,255,255,255),false) 
                    
                else 
                    dxDrawImage(hx5-150, hy5-2, hx6, hy6,"images/health.png",0.0,0.0,0.0,tocolor(0,0,0,170),false) 
                    dxDrawImage(sx5-150, sy5-2, sx6, sy6,"images/speed.png",0.0,0.0,0.0,tocolor(0,0,0,170),false) 
                                    dxDrawImage(sx5-150, sy5-35, sx6, sy6,"images/gps.png",0.0,0.0,0.0,tocolor(0,0,0,170),false) 
                                                                                end 
            end 
        end 
   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...