ViRuZGamiing Posted May 19, 2013 Share Posted May 19, 2013 Hello, I want to make my small Bind / Command Scripts all together in 1 GUI My GUI: GUIEditor = { button = {}, window = {}, progressbar = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(280, 730, 718, 60, "Dashboard", false) guiWindowSetSizable(GUIEditor.window[1], false) GUIEditor.button[1] = guiCreateButton(9, 25, 117, 25, "Lights", false, GUIEditor.window[1]) GUIEditor.button[2] = guiCreateButton(136, 25, 117, 25, "Engine", false, GUIEditor.window[1]) GUIEditor.progressbar[1] = guiCreateProgressBar(260, 26, 196, 24, false, GUIEditor.window[1]) GUIEditor.button[3] = guiCreateButton(464, 25, 117, 25, "Lock", false, GUIEditor.window[1]) GUIEditor.button[4] = guiCreateButton(591, 25, 117, 25, "Close", false, GUIEditor.window[1]) end ) What I want to happen is: 1. Lights (The Car Lights turns on/off) 2. Engine (The Car Engine turns on/off) 3. Km/h (Speedometer: Not figured out yet!) 4. Lock (The Car Doors un/lock: Not figured out yet!) 5. Close (The GUI closes) Always when I put the GUI + Meta in a folder and run it the GUI is always open and no button works. yea I know why. But I want to know how I can convert my Bind / Commanded Scripts to a Clickable GUI script Engine Script function SwitchEngine( playerSource ) local theVehicle = getPedOccupiedVehicle ( playerSource ) if theVehicle and getVehicleController ( theVehicle ) == playerSource then local state = getVehicleEngineState ( theVehicle ) setVehicleEngineState ( theVehicle, not state ) end end function BindKeys ( player ) if ( eventName == "onVehicleStartEnter" ) then bindKey ( player,"x","down",SwitchEngine ) else unbindKey ( player,"x","down",SwitchEngine ) end end addEventHandler ( "onVehicleStartEnter", root, BindKeys ) addEventHandler ( "onVehicleStartExit", root, BindKeys ) Lights Script local root = getRootElement () local thisResourceRoot = getResourceRootElement(getThisResource()) function thisResourceStart () local players = getElementsByType ( "player" ) for k,v in ipairs(players) do bindKey ( v, "l", "down", toggleVehicleLights ) end end function playerJoin () bindKey ( source, "l", "down", toggleVehicleLights ) end addEventHandler ( "onResourceStart", thisResourceRoot, thisResourceStart ) addEventHandler ( "onPlayerJoin", root, playerJoin ) function toggleVehicleLights ( player, key, state ) if ( getPedOccupiedVehicleSeat ( player ) == 0 ) then local veh = getPedOccupiedVehicle ( player ) if ( getVehicleOverrideLights ( veh ) ~= 2 ) then setVehicleOverrideLights ( veh, 2 ) else setVehicleOverrideLights ( veh, 1 ) end end end Thanks for Helping! Link to comment
iPrestege Posted May 19, 2013 Share Posted May 19, 2013 onClientGUIClick triggerServerEvent Link to comment
ViRuZGamiing Posted May 19, 2013 Author Share Posted May 19, 2013 So If I add this to my Engine script and delete the current Event or CommandHandler, Will it work? addEventhandler ("onClientGUIClick",Engine, down) Link to comment
iPrestege Posted May 19, 2013 Share Posted May 19, 2013 addEventHandler ("onClientGUIClick",button or root or anything able to use,function,if u use a button add false here) Link to comment
ViRuZGamiing Posted May 19, 2013 Author Share Posted May 19, 2013 P.S. First of all I want to make my GUI Open and Close, Then we'll see to the Scripts, Okay? I want it to be when I'm in a car and click on it, it will open the GUI To close I want the Close button to be used. Thanks Link to comment
iPrestege Posted May 19, 2013 Share Posted May 19, 2013 isPedInVehicle bindKey guiSetVisible showCursor Link to comment
ViRuZGamiing Posted May 19, 2013 Author Share Posted May 19, 2013 So Filled in I get; addEventHandler ("onClientGUIClick",Close,closeGui,false) -- This will use the button Close, when pressed Close it will do what Function closeGui tells. Correct? Link to comment
ViRuZGamiing Posted May 19, 2013 Author Share Posted May 19, 2013 how about this? When I press "m" while in a car then Cursor is being showed. press "m" again and it's hidden. Only while in a car available! function showCursor(player) showCursor(player, true) end bindKey(player, m, down) addEventHandler("onVehicleEnter", player) function hideCursor(player) showCursor(player, false) end unbindKey(player, m, down) addEventHandler("onVehicleExit", player) Link to comment
iPrestege Posted May 19, 2013 Share Posted May 19, 2013 bindKey isPedInVehicle showCursor isCursorShowing Link to comment
ViRuZGamiing Posted May 19, 2013 Author Share Posted May 19, 2013 What about this? addEventHandler("onVehicleEnter", player, cursor, function cursor( ) showCursor( not isCursorShowing( ) ) end ) bindKey( "m", "down", "togglecursor" ) Can you edit it when wrong? Link to comment
iPrestege Posted May 19, 2013 Share Posted May 19, 2013 -- # Client Side bindKey("M","down", function ( ) if isPedInVehicle ( getLocalPlayer ( ) ) then showCursor ( not isCursorShowing ( ) ) end end ) Make it more easy . Link to comment
ViRuZGamiing Posted May 19, 2013 Author Share Posted May 19, 2013 Was mine to difficult? Link to comment
ViRuZGamiing Posted May 19, 2013 Author Share Posted May 19, 2013 I'm back in a sec > Gonna try the cursor script Link to comment
ViRuZGamiing Posted May 19, 2013 Author Share Posted May 19, 2013 bad argument @ bindKey Link to comment
iPrestege Posted May 19, 2013 Share Posted May 19, 2013 Make sure it's a client side ... . Link to comment
ViRuZGamiing Posted May 19, 2013 Author Share Posted May 19, 2013 Ow yea I didn't copied the Client Side thing so I forgot it Link to comment
ViRuZGamiing Posted May 19, 2013 Author Share Posted May 19, 2013 Works, next Step: Cursor Click on Car the whole GUI opens! Step 3: GUI Click "Close" GUI Closes. I tried alot of codes the past 10 Minutes none worked... Link to comment
iPrestege Posted May 19, 2013 Share Posted May 19, 2013 Post what you did you try to close the gui . Link to comment
Sasu Posted May 19, 2013 Share Posted May 19, 2013 next Step: Cursor Click on Car the whole GUI opens! Try this: addEventHandler("onClientClick", root, function(_,_,_,_,_,_,_, clickedElement) if clickedElement == getPedOccupiedVehicle(localPlayer) then guiSetVisible(GUIEditor.window[1], true) end end ) Link to comment
ViRuZGamiing Posted May 19, 2013 Author Share Posted May 19, 2013 (edited) What does _,_, mean? Server sided right? Edited May 19, 2013 by Guest Link to comment
Sasu Posted May 19, 2013 Share Posted May 19, 2013 We use _, when we dont use the other parameters? Link to comment
ViRuZGamiing Posted May 19, 2013 Author Share Posted May 19, 2013 No Errors but it is being showed when i'm ingame whole time. it needs to be invisible and when i'm IN a car and click on the car it becomes visible. With the Last button Close back invisible. Link to comment
ViRuZGamiing Posted May 19, 2013 Author Share Posted May 19, 2013 + Can I lock a GUI? I don't want people to move the GUI but that I stays on the given location on the screen Link to comment
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