Jump to content

guiSetVisible(help)


undefined

Recommended Posts

Hey All. I have a problem on my freeroam and i dont understand this problem.

When the player entered vehicle, the gui elements visible true but when the player left vehicle then chkEngine and chkKilit is visible false but the other gui elements not visible false. It's not give error or warning on debug.

My enter code:

addEventHandler("onClientVehicleEnter", getRootElement(), function( thePlayer, seat ) 
    if thePlayer == gMe then 
    local vehicle = getPedOccupiedVehicle(thePlayer) 
    if not vehicle then return end 
        guiSetVisible(repairVehicleButton, true) 
        guiSetVisible(flipVehicleButton, true) 
        guiSetVisible(upgradeVehicleButton, true) 
        guiSetVisible(colorVehicleButton, true) 
        guiSetVisible(paintjobVehicleButton, true) 
        guiSetVisible(chkLights, true) 
        if seat == 0 then 
            guiSetVisible(chkEngine, true) 
            guiSetVisible(chkKilit, true) 
        end 
        if getVehicleOverrideLights ( vehicle ) == 2 then 
            guiCheckBoxSetSelected(chkLights, true) 
        else 
            guiCheckBoxSetSelected(chkLights, false) 
        end 
    end 
end) 

My left code:

addEventHandler("onClientVehicleStartExit", getRootElement(), function( thePlayer, seat, door ) 
    if thePlayer == gMe then 
        guiCheckBoxSetSelected(chkLights, false) 
        guiCheckBoxSetSelected(chkKilit, false) 
         
        guiSetVisible(vehPaintjobWindow, false) 
        guiSetVisible(repairVehicleButton, false) 
        guiSetVisible(flipVehicleButton, false) 
        guiSetVisible(upgradeVehicleButton, false) 
        guiSetVisible(colorVehicleButton, false) 
        guiSetVisible(paintjobVehicleButton, false) 
        guiSetVisible(chkLights, false) 
        guiSetVisible(chkKilit, false) 
        guiSetVisible(chkEngine, false) 
        triggerServerEvent("vehPaintjobWindowAyar", localPlayer) 
        guiSetVisible(vehUpgradeWindow, false) 
        triggerServerEvent("vehUpgradeWindowAyar", localPlayer) 
        if seat == 0 then 
            local vehicle = getPedOccupiedVehicle(thePlayer) 
            setVehicleEngineState ( vehicle, false ) 
            triggerServerEvent("setLockState", localPlayer, false) 
        end 
    end 
end) 

Note: gMe = getLocalPlayer()

Link to comment

My part gui code:

repairVehicleButton = guiCreateButton(91, 241, 67, 22, "Tamir Et", false, freeroamWindow) 
guiSetFont(repairVehicleButton, "default-bold-small") 
     
flipVehicleButton = guiCreateButton(167, 241, 67, 22, "Çevir", false, freeroamWindow) 
guiSetFont(flipVehicleButton, "default-bold-small") 
     
upgradeVehicleButton = guiCreateButton(14, 269, 67, 22, "Yükselt", false, freeroamWindow) 
guiSetFont(upgradeVehicleButton, "default-bold-small") 
     
colorVehicleButton = guiCreateButton(91, 269, 67, 22, "Renk", false, freeroamWindow) 
guiSetFont(colorVehicleButton, "default-bold-small") 
     
paintjobVehicleButton = guiCreateButton(168, 269, 67, 22, "Boya", false, freeroamWindow) 
guiSetFont(paintjobVehicleButton, "default-bold-small") 
     
chkLights = guiCreateCheckBox(14, 301, 77, 15, "Far", false, false, freeroamWindow) 
chkKilit = guiCreateCheckBox(14, 319, 77, 15, "Kilit", false, false, freeroamWindow) 
chkEngine = guiCreateCheckBox(157, 301, 77, 15, "Motor", true, false, freeroamWindow) 

Help pls...

Link to comment
addEventHandler("onClientVehicleEnter", root, 
function(thePlayer, seat) 
    if thePlayer == gMe then 
        guiSetVisible(repairVehicleButton, true) 
        guiSetVisible(flipVehicleButton, true) 
        guiSetVisible(upgradeVehicleButton, true) 
        guiSetVisible(colorVehicleButton, true) 
        guiSetVisible(paintjobVehicleButton, true) 
        guiSetVisible(chkLights, true) 
        if seat == 0 then 
            guiSetVisible(chkEngine, true) 
            guiSetVisible(chkKilit, true) 
        end 
        if getVehicleOverrideLights(source) == 2 then 
            guiCheckBoxSetSelected(chkLights, true) 
        else 
            guiCheckBoxSetSelected(chkLights, false) 
        end 
    end 
end) 
  
addEventHandler("onClientVehicleStartExit", root, 
function(thePlayer, seat, door) 
    if thePlayer == gMe then 
        guiCheckBoxSetSelected(chkLights, false) 
        guiCheckBoxSetSelected(chkKilit, false) 
        
        guiSetVisible(vehPaintjobWindow, false) 
        guiSetVisible(repairVehicleButton, false) 
        guiSetVisible(flipVehicleButton, false) 
        guiSetVisible(upgradeVehicleButton, false) 
        guiSetVisible(colorVehicleButton, false) 
        guiSetVisible(paintjobVehicleButton, false) 
        guiSetVisible(chkLights, false) 
        guiSetVisible(chkKilit, false) 
        guiSetVisible(chkEngine, false) 
        triggerServerEvent("vehPaintjobWindowAyar", localPlayer) 
        guiSetVisible(vehUpgradeWindow, false) 
        triggerServerEvent("vehUpgradeWindowAyar", localPlayer) 
        if seat == 0 then 
            setVehicleEngineState(source, false) 
            triggerServerEvent("setLockState", localPlayer, false) 
        end 
    end 
end) 

Link to comment
addEventHandler("onClientVehicleEnter", root, 
function(thePlayer, seat) 
    if thePlayer == gMe then 
        guiSetVisible(repairVehicleButton, true) 
        guiSetVisible(flipVehicleButton, true) 
        guiSetVisible(upgradeVehicleButton, true) 
        guiSetVisible(colorVehicleButton, true) 
        guiSetVisible(paintjobVehicleButton, true) 
        guiSetVisible(chkLights, true) 
        if seat == 0 then 
            guiSetVisible(chkEngine, true) 
            guiSetVisible(chkKilit, true) 
        end 
        if getVehicleOverrideLights(source) == 2 then 
            guiCheckBoxSetSelected(chkLights, true) 
        else 
            guiCheckBoxSetSelected(chkLights, false) 
        end 
    end 
end) 
  
addEventHandler("onClientVehicleStartExit", root, 
function(thePlayer, seat, door) 
    if thePlayer == gMe then 
        guiCheckBoxSetSelected(chkLights, false) 
        guiCheckBoxSetSelected(chkKilit, false) 
        
        guiSetVisible(vehPaintjobWindow, false) 
        guiSetVisible(repairVehicleButton, false) 
        guiSetVisible(flipVehicleButton, false) 
        guiSetVisible(upgradeVehicleButton, false) 
        guiSetVisible(colorVehicleButton, false) 
        guiSetVisible(paintjobVehicleButton, false) 
        guiSetVisible(chkLights, false) 
        guiSetVisible(chkKilit, false) 
        guiSetVisible(chkEngine, false) 
        triggerServerEvent("vehPaintjobWindowAyar", localPlayer) 
        guiSetVisible(vehUpgradeWindow, false) 
        triggerServerEvent("vehUpgradeWindowAyar", localPlayer) 
        if seat == 0 then 
            setVehicleEngineState(source, false) 
            triggerServerEvent("setLockState", localPlayer, false) 
        end 
    end 
end) 

Not work :cry::?

Link to comment
--ClientSide

repairVehicleButton = guiCreateButton(91, 241, 67, 22, "Tamir Et", false, freeroamWindow) 
guiSetFont(repairVehicleButton, "default-bold-small") 
flipVehicleButton = guiCreateButton(167, 241, 67, 22, "Çevir", false, freeroamWindow) 
guiSetFont(flipVehicleButton, "default-bold-small") 
upgradeVehicleButton = guiCreateButton(14, 269, 67, 22, "Yükselt", false, freeroamWindow) 
guiSetFont(upgradeVehicleButton, "default-bold-small") 
colorVehicleButton = guiCreateButton(91, 269, 67, 22, "Renk", false, freeroamWindow) 
guiSetFont(colorVehicleButton, "default-bold-small") 
paintjobVehicleButton = guiCreateButton(168, 269, 67, 22, "Boya", false, freeroamWindow) 
guiSetFont(paintjobVehicleButton, "default-bold-small") 
chkLights = guiCreateCheckBox(14, 301, 77, 15, "Far", false, false, freeroamWindow) 
chkKilit = guiCreateCheckBox(14, 319, 77, 15, "Kilit", false, false, freeroamWindow) 
chkEngine = guiCreateCheckBox(157, 301, 77, 15, "Motor", true, false, freeroamWindow) 
  
  
addEventHandler("onClientVehicleEnter", root, 
function(thePlayer, seat) 
    if ( thePlayer == localPlayer and seat == 0 ) then 
            guiSetVisible(repairVehicleButton, true) 
            guiSetVisible(flipVehicleButton, true) 
            guiSetVisible(upgradeVehicleButton, true) 
            guiSetVisible(colorVehicleButton, true) 
            guiSetVisible(paintjobVehicleButton, true) 
            guiSetVisible(chkLights, true) 
            guiSetVisible(chkEngine, true) 
            guiSetVisible(chkKilit, true) 
            if getVehicleOverrideLights(localPlayer) == 2 then 
            guiCheckBoxSetSelected(chkLights, true) 
        else 
            guiCheckBoxSetSelected(chkLights, false) 
        end 
    end 
end) 
  
addEventHandler("onClientVehicleStartExit", root, 
function(thePlayer, seat, door) 
    if ( thePlayer == localPlayer and seat == 0 ) then 
        guiCheckBoxSetSelected(chkLights, false) 
        guiCheckBoxSetSelected(chkKilit, false) 
        guiSetVisible(vehPaintjobWindow, false) 
        guiSetVisible(repairVehicleButton, false) 
        guiSetVisible(flipVehicleButton, false) 
        guiSetVisible(upgradeVehicleButton, false) 
        guiSetVisible(colorVehicleButton, false) 
        guiSetVisible(paintjobVehicleButton, false) 
        guiSetVisible(chkLights, false) 
        guiSetVisible(chkKilit, false) 
        guiSetVisible(chkEngine, false) 
        triggerServerEvent("vehPaintjobWindowAyar", localPlayer) 
        triggerServerEvent("vehUpgradeWindowAyar", localPlayer) 
        guiSetVisible(vehUpgradeWindow, false) 
        if (door == 0  )then 
        setVehicleEngineState(getPedOccupiedVehicle(localPlayer, false)) 
            triggerServerEvent("setLockState", localPlayer, false) 
        end 
    end 
end) 

/debugscript 3 for erros

if getVehicleOverrideLights(localPlayer) == 2 then 

localPlayer is a vehicle? ok don't tell anyone. :lol:

@AbaZaSiRiN00, I can't see anything wrong with the code, recheck your code there must be a code changing the visible to true again.

Link to comment

Im fixed it myself. My problem is in the open/close gui elements. Between "onClientVehicleStartExit" and "onClientVehicleExit" are considered a player in the car.

Im added the onVehicleStartExit = false in the "onClientVehicleStartExit" event. And im added the open/close function's

if onVehicleStartExit then 
guiSetVisible(...) 
..... 

Thanks for your help...

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