Jump to content

help


toxicsmoke11

Recommended Posts

im trying to draw images as vehicle speed increases

but it only works if speed is above 50

if speed is for example above 100 then there will be just one image and there should be two of them just on other place

local sw,sh = guiGetScreenSize() 
function reddotTest() 
local theVehicle = getPedOccupiedVehicle(localPlayer) 
if theVehicle then 
local speedx,speedy,speedz = getElementVelocity(theVehicle) 
local actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5)  
local kmh = actualspeed * 180 
  
dxDrawImage(sw/2,sh/2,32,32,"files/blackdot.png") 
dxDrawImage(sw/1.80,sh/2,32,32,"files/blackdot.png") 
dxDrawImage(sw/1.60,sh/2,32,32,"files/blackdot.png") 
dxDrawImage(sw/1.40,sh/2,32,32,"files/blackdot.png") 
dxDrawImage(sw/1.20,sh/2,32,32,"files/blackdot.png") 
--dxDrawImage(sw/2,sh/2,32,32,"files/reddot.png") 
dxDrawText(math.floor(kmh + 0.5).. " km/h",sw/2, sh/1.80,sw/2, sh/1.80,tocolor(255,255,255,255),1,"bankgothic") 
if kmh > 50 then 
local fifty = dxDrawImage(sw/2,sh/2,32,32,"files/reddot.png") 
outputChatBox("50 or more") 
elseif kmh > 0 and kmh > 100 then 
local hundred = dxDrawImage(sw/1.80,sh/2,32,32,"files/reddot.png") 
outputChatBox("100 or more") 
elseif kmh > 150 then 
local hundredfifty = dxDrawImage(sw/1.60,sh/2,32,32,"files/reddot.png") 
outputChatBox("150 or more") 
elseif kmh > 200 then 
local twohundred = dxDrawImage(sw/1.40,sh/2,32,32,"files/reddot.png") 
outputChatBox("200 or more") 
elseif kmh > 250 then 
local twohundredf = dxDrawImage(sw/1.20,sh/2,32,32,"files/reddot.png") 
outputChatBox("250 or more") 
elseif kmh == 0 then 
fifty = nil 
hundred = nil 
hundredfifty = nil 
twohundred = nil 
twohundredf = nil 
end 
else return end 
end 

why isnt this working?

Link to comment

That's because you put it to only draw one of them depending on the speed.

local sw, sh = guiGetScreenSize ( ) 
  
function reddotTest ( ) 
    local theVehicle = getPedOccupiedVehicle ( localPlayer ) 
    if ( theVehicle ) then 
        local speedx, speedy, speedz = getElementVelocity ( theVehicle ) 
        local actualspeed = ( speedx ^ 2 + speedy ^ 2 + speedz ^ 2 ) ^ ( 0.5 ) 
        local kmh = ( actualspeed * 180 ) 
        dxDrawImage ( sw / 2, sh / 2, 32, 32, "files/blackdot.png" ) 
        dxDrawImage ( sw / 1.80, sh / 2, 32, 32, "files/blackdot.png" ) 
        dxDrawImage ( sw / 1.60, sh / 2, 32, 32, "files/blackdot.png" ) 
        dxDrawImage ( sw / 1.40, sh / 2, 32, 32, "files/blackdot.png" ) 
        dxDrawImage ( sw / 1.20, sh / 2, 32, 32, "files/blackdot.png" ) 
        --dxDrawImage(sw/2,sh/2,32,32,"files/reddot.png") 
        dxDrawText ( math.floor ( kmh + 0.5 ) .. " km/h", sw / 2, sh / 1.80, sw / 2, sh / 1.80, tocolor ( 255, 255, 255, 255 ), 1, "bankgothic" ) 
        if ( kmh > 50 ) then 
            dxDrawImage ( sw / 2, sh / 2, 32, 32, "files/reddot.png" ) 
            outputChatBox ( "50 or more" ) 
        end 
  
        if ( kmh >= 100 ) then 
            dxDrawImage ( sw / 1.80, sh / 2, 32, 32, "files/reddot.png" ) 
            outputChatBox ( "100 or more" ) 
        end 
  
        if ( kmh >= 150 ) then 
            dxDrawImage ( sw / 1.60, sh / 2, 32, 32, "files/reddot.png" ) 
            outputChatBox ( "150 or more" ) 
        end 
  
        if ( kmh >= 200 ) then 
            dxDrawImage ( sw / 1.40, sh / 2, 32, 32, "files/reddot.png" ) 
            outputChatBox ( "200 or more" ) 
        end 
  
        if ( kmh >= 250 ) then 
            dxDrawImage ( sw / 1.20, sh / 2, 32, 32, "files/reddot.png" ) 
            outputChatBox ( "250 or more" ) 
        end 
    end 
end 

Try it.

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