JuniorMelo Posted February 18, 2016 Share Posted February 18, 2016 hello, I have this function that is not working , function MouseClick(button,state) if button == "left" and state == "down" then if ( source == f1 ) then triggerServerEvent("Ativo", getLocalPlayer(), getLocalPlayer(), Ativo) ori9 = on else triggerServerEvent("Garagem", getLocalPlayer(), getLocalPlayer(), garagem) ori9 = off end end end addEventHandler("onClientClick",getRootElement(),MouseClick) Link to comment
xXMADEXx Posted February 18, 2016 Share Posted February 18, 2016 What exactly are you trying to do? It's kinda hard to tell from this script. Also, be sure to check debugscript for errors by using /debugscript 3 And if you could, please post the whole script. Link to comment
Bonus Posted February 18, 2016 Share Posted February 18, 2016 "The source of this event is the client's root element." Thats not onClientGUIClick, it's onClientClick. Link to comment
JuniorMelo Posted February 18, 2016 Author Share Posted February 18, 2016 (edited) No Have erros in /debugscript 3 function guiPart() f1 = guiCreateButton(logX-recX/2+(recX-cancelX-okX+375), logY+fAltUser*2+sep*3-47,okX-70, recY-375, "", false) f2 = guiCreateButton(logX-recX/2+(recX-cancelX-okX+375), logY+fAltUser*2+sep*3-2,okX-70, recY-375, "F2", false) f3 = guiCreateButton(logX-recX/2+(recX-cancelX-okX+375), logY+fAltUser*2+sep*3+43,okX-70, recY-375, "F2", false) guiSetAlpha ( f1, 0 ) guiSetAlpha ( f2, 0 ) guiSetAlpha ( f3, 0 ) end function MouseClick(button,state) if button == "left" and state == "down" then if ( source == f1 ) then triggerServerEvent("Ativo", getLocalPlayer(), getLocalPlayer(), Ativo) --Event GiveCar ori9 = on --Image ON else triggerServerEvent("Garagem", getLocalPlayer(), getLocalPlayer(), Garagem) --Event Destroy Car ori9 = off --image OFF end end end addEventHandler("onClientClick",getRootElement(),MouseClick) Edited February 18, 2016 by Guest Link to comment
xXMADEXx Posted February 18, 2016 Share Posted February 18, 2016 Ok, so you're looking for something like this, however it's not going to work unless you have the following variables defined somewhere else in the script: - on - Ativo - off - Garagem function guiPart() f1 = guiCreateButton(logX-recX/2+(recX-cancelX-okX+375), logY+fAltUser*2+sep*3-47,okX-70, recY-375, "", false) f2 = guiCreateButton(logX-recX/2+(recX-cancelX-okX+375), logY+fAltUser*2+sep*3-2,okX-70, recY-375, "F2", false) f3 = guiCreateButton(logX-recX/2+(recX-cancelX-okX+375), logY+fAltUser*2+sep*3+43,okX-70, recY-375, "F2", false) guiSetAlpha ( f1, 0 ) guiSetAlpha ( f2, 0 ) guiSetAlpha ( f3, 0 ) end function MouseClick ( button, state ) if ( button == "left" ) then if ( source == f1 ) then triggerServerEvent("Ativo", getLocalPlayer(), getLocalPlayer(), Ativo); ori9 = on; else triggerServerEvent("Garagem", getLocalPlayer(), getLocalPlayer(), Garagem); ori9 = off; end end end addEventHandler ( "onClientGUIClick", root, MouseClick ); Link to comment
JuniorMelo Posted February 18, 2016 Author Share Posted February 18, 2016 Ok, so you're looking for something like this, however it's not going to work unless you have the following variables defined somewhere else in the script: - on - Ativo - off - Garagem function guiPart() f1 = guiCreateButton(logX-recX/2+(recX-cancelX-okX+375), logY+fAltUser*2+sep*3-47,okX-70, recY-375, "", false) f2 = guiCreateButton(logX-recX/2+(recX-cancelX-okX+375), logY+fAltUser*2+sep*3-2,okX-70, recY-375, "F2", false) f3 = guiCreateButton(logX-recX/2+(recX-cancelX-okX+375), logY+fAltUser*2+sep*3+43,okX-70, recY-375, "F2", false) guiSetAlpha ( f1, 0 ) guiSetAlpha ( f2, 0 ) guiSetAlpha ( f3, 0 ) end function MouseClick ( button, state ) if ( button == "left" ) then if ( source == f1 ) then triggerServerEvent("Ativo", getLocalPlayer(), getLocalPlayer(), Ativo); ori9 = on; else triggerServerEvent("Garagem", getLocalPlayer(), getLocalPlayer(), Garagem); ori9 = off; end end end addEventHandler ( "onClientGUIClick", root, MouseClick ); this way does not work. I believe it is for an event , "onClientGUIClick" , triggerServerEvent("Ativo", getLocalPlayer(), getLocalPlayer(), Ativo); --Event Give Car triggerServerEvent("Garagem", getLocalPlayer(), getLocalPlayer(), Garagem); --Event Destroy Car ori9 = on; --dxDrawImage ON ori9 = off; -- dxDrawImage OFF Link to comment
Bonus Posted February 18, 2016 Share Posted February 18, 2016 You work with GUI Buttons? Then use onClientGUIClick, not onClientClick!! "This is linked to the GTA world, as oppose to GUI for which onClientGUIClick is to be used. This event allows detection of click positions of the 3D world." 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