mr.Extreme Posted February 15, 2014 Posted February 15, 2014 hello 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)
Castillo Posted February 15, 2014 Posted February 15, 2014 'source' is not defined anywhere. You may want to use: getPedOccupiedVehicle
mr.Extreme Posted February 15, 2014 Author Posted February 15, 2014 (edited) no work ...... debugscript: WARNING: Bad argument @ isVehicleLocked isVehicleLocked(getPedOccupiedVehicle) Edited February 15, 2014 by Guest
cheez3d Posted February 15, 2014 Posted February 15, 2014 (edited) 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 February 15, 2014 by Guest
mr.Extreme Posted February 15, 2014 Author Posted February 15, 2014 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
cheez3d Posted February 15, 2014 Posted February 15, 2014 The button becomes visible when you enter a car (so there is no need to use that timer) and it disappears when you start exiting the car. What exactly doesn't work for you?
mr.Extreme Posted February 15, 2014 Author Posted February 15, 2014 i am not needed to make guiSetVisible
cheez3d Posted February 15, 2014 Posted February 15, 2014 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.
Moderators Citizen Posted February 16, 2014 Moderators Posted February 16, 2014 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)
mr.Extreme Posted February 16, 2014 Author Posted February 16, 2014 loool i forget use this getElementData instead of getPedOccupiedVehicle now working and thanks for all
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now