Jump to content

onObjectClick ?


glowdemon1

Recommended Posts

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).

Link to comment

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]  

Link to comment
  • 2 weeks later...

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) 

Link to comment
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) 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...