Jump to content

[HELP] Problem with


Hard*

Recommended Posts

  

 local player_vehicle = getPedOccupiedVehicle(localPlayer)
    local r, g, b = getVehicleHeadLightColor(player_vehicle)
    if (player_vehicle) then
        dxDrawText("", x*0, y*39.5, x*1366 + x*1128, y*768, tocolor(r,g,b), 1, font_icons, "center", "top", false, false, false, true, false)
        dxDrawText("", x*0, y*39.5, x*1366 + x*908, y*768, tocolor(r,g,b), 1, font_icons, "center", "top", false, false, false, true, false)
    else
        dxDrawText("", x*0, y*39.5, x*1366 + x*1128, y*768, tocolor(255,165,0), 1, font_icons, "center", "top", false, false, false, true, false)
        dxDrawText("", x*0, y*39.5, x*1366 + x*908, y*768, tocolor(127,255,212), 1, font_icons, "center", "top", false, false, false, true, false)
    end

 

Problem: https://imgur.com/CJOteVg

How to resolve?

thx all.

Link to comment

Put the variable r, g, b inside the check, like this:

 local player_vehicle = getPedOccupiedVehicle(localPlayer)
    if (player_vehicle) then
  	local r, g, b = getVehicleHeadLightColor(player_vehicle)
        dxDrawText("", x*0, y*39.5, x*1366 + x*1128, y*768, tocolor(r,g,b), 1, font_icons, "center", "top", false, false, false, true, false)
        dxDrawText("", x*0, y*39.5, x*1366 + x*908, y*768, tocolor(r,g,b), 1, font_icons, "center", "top", false, false, false, true, false)
    else
        dxDrawText("", x*0, y*39.5, x*1366 + x*1128, y*768, tocolor(255,165,0), 1, font_icons, "center", "top", false, false, false, true, false)
        dxDrawText("", x*0, y*39.5, x*1366 + x*908, y*768, tocolor(127,255,212), 1, font_icons, "center", "top", false, false, false, true, false)
    end

 

The variable is out of the check if the player is in the car, that is, how he is using onClientRender (event that is every second working), he tries to get the light function of the vehicle, but if he is not in the car, give error then, so have to check inside.

Edited by VazErn
Language error e.e
Link to comment
20 minutes ago, VazErn said:

Coloque a variável r, g, b dentro do cheque, assim:


  
      
  	 
                  
                  
    
                  
                  
    

 

A variável está fora do cheque se o jogador está no carro, isto é, como ele está usando onClientRender (evento que está a cada segundo funcionando), ele tenta obter a função de luz do veículo, mas se ele não estiver no carro, dar erro então, então tem que verificar dentro.

Solved, thank u s2

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