TorNix~|nR Posted April 8, 2017 Share Posted April 8, 2017 hello guys, I have a panel worked fine, but there is a little problem I have a button of Get Vehicle to spawn with it a vehicle, but I can spawn vehicle on all the window if I want to spawn vehicle? I click on whatever place on window, and done how to fix it only with the Get Vehicle button Code addEventHandler ("onClientGUIClick", GUIEditor.button[2], function (button, state, absoluteX, absoluteYe) guiSetVisible(GUIEditor.window[1],false) showCursor(false) end) function trigger () if (guiGridListGetSelectedItem (GUIEditor.gridlist[1])) then local car = guiGridListGetItemText (GUIEditor.gridlist[1], guiGridListGetSelectedItem (GUIEditor.gridlist[1]), 2) if car == "" or car == nil then return end triggerServerEvent ("getCar", getLocalPlayer(), car) guiSetVisible(GUIEditor.window[1],false) showCursor(false) end end addEventHandler ("onClientGUIClick", GUIEditor.button[1], function (button, state, absoluteX, absoluteYe) trigger(getLocalPlayer()) playSound ("fail.mp3") end) addEventHandler ("onClientGUIDoubleClick", GUIEditor.gridlist[1], function (button, state, absoluteX, absoluteYe) trigger(getLocalPlayer()) playSound ("fail.mp3") end) Help please? Link to comment
AE. Posted April 8, 2017 Share Posted April 8, 2017 addEventHandler ("onClientGUIClick", GUIEditor.button[1], function (button, state, absoluteX, absoluteYe) if source == GUIEditor.button[1] then -- you have to check if the source that got clicked is the button trigger(getLocalPlayer()) playSound ("fail.mp3") end end) Link to comment
Pembo Posted April 8, 2017 Share Posted April 8, 2017 (edited) function trigger() local row, col = guiGridListGetSelectedItem( GUIEditor.gridlist[1] ) if ( ( row ~= -1 ) and ( col ~= -1 ) ) then local car = guiGridListGetItemText( GUIEditor.gridlist[1], row, col ) if ( ( car == "" ) or ( car == nil ) ) then return end triggerServerEvent( "getCar", getLocalPlayer(), car ) guiSetVisible( GUIEditor.window[1], false ) showCursor( false ) end end addEventHandler("onClientGUIClick", GUIEditor.window[1], function( button, state ) if ( source == GUIEditor.button[1] ) then trigger() playSound( "fail.mp3" ) elseif ( source == GUIEditor.button[2] ) then guiSetVisible( GUIEditor.window[1], false ) showCursor( false ) end end ) addEventHandler("onClientGUIDoubleClick", GUIEditor.window[1], function( button, state ) if ( source == GUIEditor.gridlist[1] ) then trigger() playSound( "fail.mp3" ) end end ) Edited April 8, 2017 by Pembo 1 Link to comment
TorNix~|nR Posted April 8, 2017 Author Share Posted April 8, 2017 (edited) @Pembo It's worked, no more free click, but I can not spawn it with the button the button won't work help please GUIEditor.button[1] I forget upload this, if it can help you for i,v in ipairs (cars) do local carName = getVehicleNameFromModel (v[1]) local row = guiGridListAddRow (GUIEditor.gridlist[1]) guiGridListSetItemText (GUIEditor.gridlist[1], row, 1, i.."", false, true) guiGridListSetItemText (GUIEditor.gridlist[1], row, 2, carName, false, true) guiGridListSetItemColor(GUIEditor.gridlist[1], row, 1, 255, 255, 255, 255) end Edited April 8, 2017 by TorNix~|nR Link to comment
Pembo Posted April 8, 2017 Share Posted April 8, 2017 (edited) Hmm. Show me the code for the server side function attached to the event 'getCar' and I'll look further for you. Edited April 8, 2017 by Pembo 1 Link to comment
TorNix~|nR Posted April 8, 2017 Author Share Posted April 8, 2017 (edited) veh = {} addEvent ("getCar", true) addEventHandler ("getCar", getRootElement(), function(car) if veh[source] and isElement( veh[source] ) then destroyElement( veh[source] ) veh[source] = nil end local carID = getVehicleModelFromName (car) local x,y,z = getElementPosition(source) local carName = getVehicleNameFromModel (carID) veh[source] = createVehicle(carID, x,y,z) setVehicleColor(veh[source], 255, 150, 0) warpPedIntoVehicle(source, veh[source]) end ) Edited April 8, 2017 by TorNix~|nR Link to comment
Pembo Posted April 8, 2017 Share Posted April 8, 2017 2 hours ago, TorNix~|nR said: veh = {} addEvent ("getCar", true) addEventHandler ("getCar", getRootElement(), function(car) if veh[source] and isElement( veh[source] ) then destroyElement( veh[source] ) veh[source] = nil end local carID = getVehicleModelFromName (car) local x,y,z = getElementPosition(source) local carName = getVehicleNameFromModel (carID) veh[source] = createVehicle(carID, x,y,z) setVehicleColor(veh[source], 255, 150, 0) warpPedIntoVehicle(source, veh[source]) end ) What errors are displayed on the debug output? 1 Link to comment
TorNix~|nR Posted April 8, 2017 Author Share Posted April 8, 2017 Bad argument @ 'createVehicle' [Expected number at argument 1, got boolean] Bad argument @ 'setVehicleColor' [Expected element at argument 1, got boolean] Bad argument @ 'warpPedIntoVehicle' [Expected vehicle at argument 2, got boolean] Link to comment
Pembo Posted April 8, 2017 Share Posted April 8, 2017 (edited) AH! The error is that your using source instead of client. Replace 'veh[source]' with 'veh[client]'. Edited April 8, 2017 by Pembo Link to comment
TorNix~|nR Posted April 9, 2017 Author Share Posted April 9, 2017 same problem Done, thanks I fix it by myself, thank you so much @Pembo 1 Link to comment
Pembo Posted April 9, 2017 Share Posted April 9, 2017 17 hours ago, TorNix~|nR said: same problem Done, thanks I fix it by myself, thank you so much @Pembo Ah okay glad you fixed it. 1 Link to comment
TheBossCl Posted May 22, 2022 Share Posted May 22, 2022 On 08/04/2017 at 21:39, TorNix~|nR said: same problem Done, thanks I fix it by myself, thank you so much @Pembo How did you manage to fix the problem? The same thing happens to me with a login panel, every time I click any part of the window it is as if I clicked any of the buttons that I have :/. Link to comment
Spakye Posted May 23, 2022 Share Posted May 23, 2022 Hello, try to add false to your event handler addEventHandler ( "onClientGUIClick", theButton, theFunction, false ) 1 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