LabiVila Posted December 28, 2014 Posted December 28, 2014 So I want this, once I click the object, it outputs: "You selected a guy", if I do it again, it outputs the same text again, but I have a problem, it doesn't reply only one time but a lot like here: http://www.upload.ee/image/4432676/Untitled.png function mainWindow () main = guiCreateWindow (0.70, 0.20, 0.25, 0.25, "Auto-Converter", true) selectButton = guiCreateButton (0.15, 0.40, 0.30, 0.30, "Click", true, main) generate = guiCreateButton (0.60, 0.40, 0.30, 0.30, "G", true, main) addEventHandler ("onClientGUIClick", selectButton, function () outputChatBox ("Must select a shade (3458 or 8558).", 255, 255, 255) addEventHandler ("onClientClick", getRootElement(), function (button, state, absoluteX, absoluteY, worldX, worldY, worldZ, element) if (state == "down") then if (getElementType (element) == "object") and (getElementModel (element) == 8558 or getElementModel (element) == 3458) then outputChatBox ("You selected a shade") return end end end ) end ) outputDebugString ("Program Started") end addEventHandler ("onClientResourceStart", getResourceRootElement(getThisResource), mainWindow) I'd appreciate any help
MTA Team botder Posted December 28, 2014 MTA Team Posted December 28, 2014 You have to set the parameter getPropagated from addEventHandler to false addEventHandler("onClientGUIClick", selectButton, function () ... end, false)
LabiVila Posted December 28, 2014 Author Posted December 28, 2014 Thanks but it is not actually working
MTA Team botder Posted December 29, 2014 MTA Team Posted December 29, 2014 Everytime you click on your button you generate an event handler for onClientClick.
LabiVila Posted December 29, 2014 Author Posted December 29, 2014 Oh... now I get it. Any suggestion what to do tho?
MTA Team botder Posted December 29, 2014 MTA Team Posted December 29, 2014 Use a variable (boolean), which will tell the script, if the player is supposed to click on an element or not.
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