Jump to content

whats wrong ?


RekZ

Recommended Posts

when I start the script at 5 or 10 seconds, the text disappears

function infoauto ( ) 
  
    local sWidth,sHeight = guiGetScreenSize() 
    font = dxCreateFont("fuente.ttf", 13) 
     
    dxDrawRectangle((890/1024)*sWidth, (580/768)*sHeight, (190/1024)*sWidth, (250/768)*sHeight,tocolor(0,0,0,150),false) 
     
    vehicle = getPedOccupiedVehicle(getLocalPlayer()) 
    if ( vehicle ) then 
        speedx, speedy, speedz = getElementVelocity ( vehicle  ) 
        actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5)  
        kmh = math.floor(actualspeed*180) 
        mph = math.floor(actualspeed * 111.847) 
        mps = math.floor (actualspeed) 
        vehiclehealth = math.floor(getElementHealth ( vehicle )) 
  
        dxDrawText(tostring (kmh), (920/1024)*sWidth, (640/768)*sHeight, (280/1024)*sWidth, (250/768)*sHeight, tocolor (255, 255, 255, 255), 1, font) 
        dxDrawText("Velocidad", (896/1024)*sWidth, (620/768)*sHeight, (289/1024)*sWidth, (250/768)*sHeight, tocolor (255, 255, 255, 255), 0.9, font) 
  
        dxDrawText(getVehicleNameFromModel ( getElementModel ( vehicle ) ), (900/1024)*sWidth, (680/768)*sHeight, (289/1024)*sWidth, (250/768)*sHeight, tocolor ( 255, 255, 255, 255), 0.6, font) 
        dxDrawText("Auto Info", (914/1024)*sWidth, (580/768)*sHeight, (289/1024)*sWidth, (250/768)*sHeight, tocolor (255, 255, 255, 255), 0.65, font) 
        dxDrawText(tostring (vehiclehealth).."%", (899/1024)*sWidth, (710/768)*sHeight, (300/1024)*sWidth, (259/768)*sHeight, tocolor (250, 0, 0, 255), 1, font) 
  
else 
        dxDrawText("No", (905/1024)*sWidth, (610/768)*sHeight, (289/1024)*sWidth, (250/768)*sHeight, tocolor (200, 200, 200, 255), 1, font) 
        dxDrawText("Auto Info", (905/1024)*sWidth, (635/768)*sHeight, (289/1024)*sWidth, (250/768)*sHeight, tocolor (200, 200, 200, 255), 0.9,  font) 
        dxDrawText("-OFFLINE-", (910/1024)*sWidth, (680/768)*sHeight, (289/1024)*sWidth, (250/768)*sHeight, tocolor (255, 0, 0, 255), 0.9,  font) 
  
  
    end 
end  
addEventHandler ("onClientRender", root, infoauto ) 

Link to comment
  • Scripting Moderators

Try this:

font = dxCreateFont("fuente.ttf", 13) 
  
function infoauto ( ) 
    local sWidth,sHeight = guiGetScreenSize() 
    
    dxDrawRectangle((890/1024)*sWidth, (580/768)*sHeight, (190/1024)*sWidth, (250/768)*sHeight,tocolor(0,0,0,150),false) 
    
    vehicle = getPedOccupiedVehicle(getLocalPlayer()) 
    if ( vehicle ) then 
        speedx, speedy, speedz = getElementVelocity ( vehicle  ) 
        actualspeed = (speedx^2 + speedy^2 + speedz^2)^(0.5) 
        kmh = math.floor(actualspeed*180) 
        mph = math.floor(actualspeed * 111.847) 
        mps = math.floor (actualspeed) 
        vehiclehealth = math.floor(getElementHealth ( vehicle )) 
  
        dxDrawText(tostring (kmh), (920/1024)*sWidth, (640/768)*sHeight, (280/1024)*sWidth, (250/768)*sHeight, tocolor (255, 255, 255, 255), 1, font) 
        dxDrawText("Velocidad", (896/1024)*sWidth, (620/768)*sHeight, (289/1024)*sWidth, (250/768)*sHeight, tocolor (255, 255, 255, 255), 0.9, font) 
  
        dxDrawText(getVehicleNameFromModel ( getElementModel ( vehicle ) ), (900/1024)*sWidth, (680/768)*sHeight, (289/1024)*sWidth, (250/768)*sHeight, tocolor ( 255, 255, 255, 255), 0.6, font) 
        dxDrawText("Auto Info", (914/1024)*sWidth, (580/768)*sHeight, (289/1024)*sWidth, (250/768)*sHeight, tocolor (255, 255, 255, 255), 0.65, font) 
        dxDrawText(tostring (vehiclehealth).."%", (899/1024)*sWidth, (710/768)*sHeight, (300/1024)*sWidth, (259/768)*sHeight, tocolor (250, 0, 0, 255), 1, font) 
  
else 
        dxDrawText("No", (905/1024)*sWidth, (610/768)*sHeight, (289/1024)*sWidth, (250/768)*sHeight, tocolor (200, 200, 200, 255), 1, font) 
        dxDrawText("Auto Info", (905/1024)*sWidth, (635/768)*sHeight, (289/1024)*sWidth, (250/768)*sHeight, tocolor (200, 200, 200, 255), 0.9,  font) 
        dxDrawText("-OFFLINE-", (910/1024)*sWidth, (680/768)*sHeight, (289/1024)*sWidth, (250/768)*sHeight, tocolor (255, 0, 0, 255), 0.9,  font) 
  
  
    end 
end 
addEventHandler ("onClientRender", root, infoauto ) 

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