As title, I made a GUI, a vehicle panel GUI, that says the driver the state of engine, lights and doors. The problem is that if I enter a vehicle, i see the panel, but eveyone sees my panel too. And i've another problem, the status is realoaded each time I enter the vehicle, not everytime i press the engine, lights lockcar button...
Here's the entire GUI code:
addEventHandler("onClientVehicleEnter", getRootElement(),
function(thePlayer, seat)
Panel_Window = guiCreateWindow(751,159,174,123,"VEHICLE PANEL",false)
guiWindowSetMovable(Panel_Window,false)
guiWindowSetSizable(Panel_Window,false)
Engine_Label = guiCreateLabel(0.0747,0.252,0.8046,0.2195,"Engine status: Off ",true,Panel_Window)
guiLabelSetColor(Engine_Label,255,255,255)
guiLabelSetVerticalAlign(Engine_Label,"top")
guiLabelSetHorizontalAlign(Engine_Label,"left",false)
Doors_Label = guiCreateLabel(0.069,0.6829,0.8621,0.1951,"Door Status: Locked ",true,Panel_Window)
guiLabelSetColor(Doors_Label,255,255,255)
guiLabelSetVerticalAlign(Doors_Label,"top")
guiLabelSetHorizontalAlign(Doors_Label,"left",false)
Lights_Label = guiCreateLabel(0.069,0.4715,0.8046,0.2114,"Lights Status: On ",true,Panel_Window)
guiLabelSetColor(Lights_Label,255,255,255)
guiLabelSetVerticalAlign(Lights_Label,"top")
guiLabelSetHorizontalAlign(Lights_Label,"left",false)
playervehicle = getPedOccupiedVehicle ( thePlayer )
if getVehicleOverrideLights ( playervehicle ) == 2 then
guiSetText ( Lights_Label, "Lights status: On " )
else
guiSetText ( Lights_Label, "Lights status: Off " )
end
playervehicle = getPedOccupiedVehicle ( thePlayer )
if isVehicleLocked ( playervehicle ) then
guiSetText ( Doors_Label, "Door status: Locked " )
else
guiSetText ( Doors_Label, "Door status: Unlocked " )
end
playervehicle = getPedOccupiedVehicle ( thePlayer )
local engine1 = getVehicleEngineState ( playervehicle )
if ( engine1 == false ) then
guiSetText ( Engine_Label, "Engine status: Off " )
else
guiSetText ( Engine_Label, "Engine status: On " )
end
end
)
function enginefunc( key , state )
if ( keyState == "down" ) then
local player = getLocalPlayer
outputChatBox("PRESSED 1")
playervehicle = getPedOccupiedVehicle ( plr )
if isPedInVehicle ( plr ) then
local engine1 = getVehicleEngineState ( playervehicle )
if ( engine1 == false ) then
guiSetText ( Engine_Label, "Engine status: Off " )
else
guiSetText ( Engine_Label, "Engine status: On " )
end
end
end
end
function lightsfunc( key , state )
if ( keyState == "down" ) then
local player = getLocalPlayer
outputChatBox("PRESSED 2")
playervehicle = getPedOccupiedVehicle ( plr )
if isPedInVehicle ( plr ) then
if isVehicleLocked ( playervehicle ) then
guiSetText ( Doors_Label, "Door status: Locked " )
else
guiSetText ( Doors_Label, "Door status: Unlocked " )
end
end
end
end
function doorsfunc( key , state )
if ( keyState == "down" ) then
local player = getLocalPlayer
outputChatBox("PRESSED 3")
playervehicle = getPedOccupiedVehicle ( plr )
if isPedInVehicle ( plr ) then
if isVehicleLocked ( playervehicle ) then
guiSetText ( Doors_Label, "Door status: Locked " )
else
guiSetText ( Doors_Label, "Door status: Unlocked " )
end
end
end
end
function chiavi2 ()
local bind1 = bindKey( "1", "down", "enginefunc" )
local bind2 = bindKey( "2", "down", "lightsfunc" )
local bind3 = bindKey( "3", "down", "doorsfunc" )
if bind1 and bind2 and bind3 then
outputChatBox( "Keys bound")
end
end
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), chiavi2)
addEventHandler("onClientVehicleExit", getRootElement(),
function(thePlayer, seat)
destroyElement(Panel_Window)
end
)
Question
AlexMiller
As title, I made a GUI, a vehicle panel GUI, that says the driver the state of engine, lights and doors. The problem is that if I enter a vehicle, i see the panel, but eveyone sees my panel too. And i've another problem, the status is realoaded each time I enter the vehicle, not everytime i press the engine, lights lockcar button...
Here's the entire GUI code:
I hope someone can help me.
Thank you
Link to comment
2 answers to this question
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