Jump to content

[HELP] Image opening 100 times


..:D&G:..

Recommended Posts

Hello guys, I made a speedometer that glows when you turn on the lights, but when I turn on the lights, 1000 images open on top of each other.

  
function drawFuelLights() 
    local vehicle = getPedOccupiedVehicle(getLocalPlayer()) 
    if (vehicle) then 
        if ( getVehicleOverrideLights ( vehicle ) == 2 ) then 
            if not (thDiscNight) then theDiscNight = guiCreateStaticImage( discX, discY, imageWidth, imageHeight, "fuelmeter/fueldisc-night.png", false ) end 
        else 
            if (theDiscNight) then 
                guiSetVisible(theDiscNight, false) 
            end 
        end 
    end 
end 
  
function onVehicleEnter(thePlayer, seat) 
    if (thePlayer==getLocalPlayer()) then 
        if (seat<2) then 
            if seat == 0 then 
                addEventHandler("onClientRender", getRootElement(), drawFuelLights) 
            end 
        end 
    end 
end 
addEventHandler("onClientVehicleEnter", getRootElement(), onVehicleEnter) 
  
  
function onVehicleExit(thePlayer, seat) 
    if (thePlayer==getLocalPlayer()) then 
        if (seat<2) then 
            if seat == 0 then 
                removeEventHandler("onClientRender", getRootElement(), drawFuelLights) 
            end 
        end 
    end 
end 
addEventHandler("onClientVehicleExit", getRootElement(), onVehicleExit) 

Any ideas?

Link to comment

This is what I've done but it still doesnt' show up.

function drawFuelLights() 
    local vehicle = getPedOccupiedVehicle(getLocalPlayer()) 
    if (vehicle) then 
        if ( getVehicleOverrideLights ( vehicle ) == 2 ) then 
            theDiscNight = dxDrawImage( discX, discY, imageWidth, imageHeight, "fuelmeter/fueldisc-night.png" ) 
        else 
            if (theDiscNight) then 
                removeEventHandler("onClientRender", getRootElement(), drawFuelLights) 
            end 
        end 
    end 
end 

I am soo damn angry cuz I been trying to do this thing for 2 hours now, and can't get it to work! When I used guiCreateStatic image, it worked but created lots of images on top of each other, now, they don't work at all!

Link to comment
This is what I've done but it still doesnt' show up.
function drawFuelLights() 
    local vehicle = getPedOccupiedVehicle(getLocalPlayer()) 
    if (vehicle) then 
        if ( getVehicleOverrideLights ( vehicle ) == 2 ) then 
            theDiscNight = dxDrawImage( discX, discY, imageWidth, imageHeight, "fuelmeter/fueldisc-night.png" ) 
        else 
            if (theDiscNight) then 
                removeEventHandler("onClientRender", getRootElement(), drawFuelLights) 
            end 
        end 
    end 
end 

I am soo damn angry cuz I been trying to do this thing for 2 hours now, and can't get it to work! When I used guiCreateStatic image, it worked but created lots of images on top of each other, now, they don't work at all!

what is exactly your problem? because it works with the code you just did

Link to comment

I fixed it by using this code:

function drawDiscsNight() 
    guiSetVisible(discnight, true) 
    guiSetVisible(theDiscNight, true) 
    guiSetProperty( theDiscNight, "AlwaysOnTop", "True" ) 
end 
  
function notDrawDiscsNight() 
    guiSetVisible(discnight, false) 
    guiSetVisible(theDiscNight, false) 
end 
  
function drawLights() 
    local vehicle = getPedOccupiedVehicle(getLocalPlayer()) 
    if (vehicle) then 
        if ( getVehicleOverrideLights ( vehicle ) == 2 ) then 
            addEventHandler("onClientRender", getRootElement(), drawDiscsNight) 
            removeEventHandler("onClientRender", getRootElement(), notDrawDiscsNight) 
        else 
            if ( getVehicleOverrideLights ( vehicle ) == 1 ) then 
                removeEventHandler("onClientRender", getRootElement(), drawDiscsNight) 
                addEventHandler("onClientRender", getRootElement(), notDrawDiscsNight) 
            end 
        end 
    end 
end 

But I keep getting an error saying that the events are already handled in another function, but they ain't (I think...)

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