glowdemon1 Posted August 10, 2013 Posted August 10, 2013 Hi, I'm currently making a slot machine with a GUI, so I'm stuck at one certain point and I'm fairly new to scripting. I have a working cursor script and now I just need to find if there's something pre-definded like onObjectClick. (Whenever I click the slot machine object/model it does a certain action like show a GUI).
TAPL Posted August 10, 2013 Posted August 10, 2013 https://wiki.multitheftauto.com/wiki/OnClientClick
tosfera Posted August 10, 2013 Posted August 10, 2013 Hmm, try using this function too. Might be handy! https://wiki.multitheftauto.com/wiki/OnElementClicked
Vector Posted August 10, 2013 Posted August 10, 2013 server-side "onElementClicked" -- [url=https://wiki.multitheftauto.com/wiki/OnElementClicked]https://wiki.multitheftauto.com/wiki/OnElementClicked[/url] client-side "onClientClick" -- [url=https://wiki.multitheftauto.com/wiki/OnClientClick]https://wiki.multitheftauto.com/wiki/OnClientClick[/url]
glowdemon1 Posted August 19, 2013 Author Posted August 19, 2013 Alrighty, I did this but now it's not working, I've tried to put this both client and serverside, here's my codes : META: <meta> <info author="/" name="/" description="/" /> <script src="main.lua" type="client" /> <script src="s_main.lua" type="server" /> </meta> main.lua: function onMachineClick(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement) if element and getElementType( element ) == "object" and button == "right" and state == "down" and getElementModel(element) == 955 then outputChatBox( "WORKS" ) end end addEventHandler("onClientClick", getRootElement(), onMachineClick)
TAPL Posted August 19, 2013 Posted August 19, 2013 function onMachineClick(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, element) if element and getElementType( element ) == "object" and button == "right" and state == "down" and getElementModel(element) == 955 then outputChatBox( "WORKS" ) end end addEventHandler("onClientClick", getRootElement(), onMachineClick)
glowdemon1 Posted August 19, 2013 Author Posted August 19, 2013 Thanks mate, works like a charm ! What exactly did I do wrong ? I'm new to coding and I'm willing to learn alot.
iPrestege Posted August 19, 2013 Posted August 19, 2013 element and clickedElement You're get a type of an not defined element .
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