Jump to content

guiSetText


mr.Extreme

Recommended Posts

hello :D

i have problem with this

if vehicle locked no show unlock and if unlocked no show lock in button

here my code >

clientside:

  
  
GUIEditor.button[3] = guiCreateButton(226, 119, 93, 29, "", false, GUIEditor.window[1]) 
guiSetFont(GUIEditor.button[3], "default-bold-small") 
  
function ubdatebutton() 
    if (isVehicleLocked(source)) then 
    guiSetText(GUIEditor.button[3], "unLock") 
    end 
    if (not isVehicleLocked(source)) then 
    guiSetText(GUIEditor.button[3], "Lock") 
    end 
end 
setTimer( ubdatebutton, 50, 0) 
  
  

Link to comment
  
local keyButton = guiCreateButton(0,0,93,29,"",false) 
guiSetFont(keyButton,"default-bold-small") 
guiSetVisible(keyButton,false) 
  
addEventHandler("onClientVehicleEnter",root,function() 
    guiSetVisible(keyButton,true) 
    if isVehicleLocked(source) then 
        guiSetText(keyButton,"Unlock!") 
    else 
        guiSetText(keyButton,"Lock!") 
    end 
end) 
  
addEventHandler("onClientVehicleStartExit",root,function() 
    guiSetVisible(keyButton,false) 
end) 
  

Edited by Guest
Link to comment
  
local keyButton = guiCreateButton(0,0,93,29,"",false) 
guiSetFont(keyButton,"default-bold-small") 
guiSetVisible(keyButton,false) 
  
addEventHandler("onClientVehicleEnter",root,function() 
    guiSetVisible(keyButton,true) 
    if isVehicleLocked(source) then 
        guiSetText(keyButton,"Unlock!") 
    else 
        guiSetText(keyButton,"Lock!") 
end) 
  
addEventHandler("onClientVehicleStartExit",root,function() 
    guiSetVisible(keyButton,false) 
end) 
  

no work :( andd you are forget end 8)

Link to comment
  
local keyButton = guiCreateButton(0,0,93,29,"",false) 
guiSetFont(keyButton,"default-bold-small") 
  
addCommandHandler("updatebutton",function() 
    local vehicle = getPedOccupiedVehicle(localPlayer) 
    if vehicle then 
        if isVehicleLocked(vehicle) then 
            guiSetText(keyButton,"Unlock!") 
        else 
            guiSetText(keyButton,"Lock!") 
        end 
    else 
        outputChatBox("ERROR - You are not currently driving a vehicle!",255,0,0) 
    end 
end) 
  

Use /updatebutton to check if the vehicle is locked or not.

Link to comment
  • Moderators
  
local keyButton = guiCreateButton(0,0,93,29,"",false) 
guiSetFont(keyButton,"default-bold-small") 
  
addCommandHandler("updatebutton",function() 
    local vehicle = getPedOccupiedVehicle(localPlayer) 
    if vehicle then 
        if isVehicleLocked(vehicle) then 
            guiSetText(keyButton,"Unlock!") 
        else 
            guiSetText(keyButton,"Lock!") 
        end 
    else 
        outputChatBox("ERROR - You are not currently driving a vehicle!",255,0,0) 
    end 
end) 
  

Use /updatebutton to check if the vehicle is locked or not.

Why replacing the timer with a command ???

GUIEditor.button[3] = guiCreateButton(226, 119, 93, 29, "", false, GUIEditor.window[1]) 
guiSetFont(GUIEditor.button[3], "default-bold-small") 
  
function ubdatebutton() 
    local vehicle = getPedOccupiedVehicle( localPlayer ) 
    if vehicle then 
        guiSetVisible(GUIEditor.button[3], true) 
        if isVehicleLocked(vehicle) then 
            guiSetText(GUIEditor.button[3], "Unlock") 
        else 
            guiSetText(GUIEditor.button[3], "Lock") 
        end 
    else 
        guiSetVisible(GUIEditor.button[3], false) 
    end 
end 
setTimer(ubdatebutton, 100, 0) 

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