Maccer. Posted November 2, 2009 Share Posted November 2, 2009 Okay, I'm trying to use string.find, but I can't figure out how to use it because it lacks flipping documentation! So, the problem is that, onClientClick doesn't detect any gui elements as part of the world. Also since there is no element named gui, there's only elements named "gui-element." I'm trying to use string.find to check the element name and stop the click if it if( isSpecialBindActivated == true and not string.find(getElementType(clickedWorld), "gui") ) then If there are better ways to fix my problem or better documentation of string.find, I'd appreciate it, because all I'm getting is this from debugscript: ERROR: Untitled 2.lua:17: bad argument #1 to 'find' (string expected, got boolean) Thanks. Link to comment
Remp Posted November 2, 2009 Share Posted November 2, 2009 string.find is a function in luas string library, it isnt mta specific so it wont be covered on the mta wiki: http://lua-users.org/wiki/StringLibraryTutorial onClientClick will never detect a gui element, it only triggers on real-world entities so the error in the code you posted is probably because clickedWorld == nil, therefore you are attempting to string.find on a variable that is not a string if you want to detect clicks on a gui element you could either use onClientGUIClick, or use onClientClick but track the gui element you are on with onClientMouseEnter, onClientMouseLeave and a global variable Link to comment
subenji99 Posted November 2, 2009 Share Posted November 2, 2009 Also, onClientGUIClick returns what element was clicked on as the "source" hidden variable, so you shouldn't even require string.find at all for this task. Link to comment
Maccer. Posted November 3, 2009 Author Share Posted November 3, 2009 string.find is a function in luas string library, it isnt mta specific so it wont be covered on the mta wiki: http://lua-users.org/wiki/StringLibraryTutorialonClientClick will never detect a gui element, it only triggers on real-world entities so the error in the code you posted is probably because clickedWorld == nil, therefore you are attempting to string.find on a variable that is not a string if you want to detect clicks on a gui element you could either use onClientGUIClick, or use onClientClick but track the gui element you are on with onClientMouseEnter, onClientMouseLeave and a global variable I do use onClientGUIClick, the problem is, if I click on a gui button onClientClick triggers too, but without knowing it's a gui element. It thinks it's the world. Link to comment
MOH Posted November 3, 2009 Share Posted November 3, 2009 Hehe. You need something like onElementIsCocky setElement = nil Link to comment
Remp Posted November 3, 2009 Share Posted November 3, 2009 I do use onClientGUIClick, the problem is, if I click on a gui button onClientClick triggers too, but without knowing it's a gui element. It thinks it's the world. use my second suggestion then, that is how ive worked around this problem before. store whichever gui element you are hovering over in a global variable, then you can just use onClientClick and check your variable to see if you clicked on gui Link to comment
Maccer. Posted November 4, 2009 Author Share Posted November 4, 2009 I do use onClientGUIClick, the problem is, if I click on a gui button onClientClick triggers too, but without knowing it's a gui element. It thinks it's the world. use my second suggestion then, that is how ive worked around this problem before. store whichever gui element you are hovering over in a global variable, then you can just use onClientClick and check your variable to see if you clicked on gui It's all in the works! Too bad I had to use a work-around though. 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