Jump to content

Problem with onClientClick


Piorun

Recommended Posts

I have this code:

  
function tworzeniePickupa () 
  
   sx,sy,wx,wy,wz = getCursorPosition" class="kw4">getCursorPosition() 
   outputChatBox(wx.." "..wy.." "..wz) 
    
end 
addEventHandler ( "onClientClick", getRootElement(), tworzeniePickupa ) 
  

Everything is cool, but this code send me 2 messeges (outputChatBox) with coords of GTA world.

Please, help :(

Link to comment
  • Moderators

Maybe in your meta.xml, yourScript.lua is loaded 2 times or there are 2 times the function tworzeniePickupa in your code.

Why get the position of the cursor again because this event send this parameters ( button, state, absoluteX, absoluteY, wx, wy, wz, clickedElement ):

function tworzeniePickupa ( button, state, absoluteX, absoluteY, wx, wy, wz, clickedElement ) 
   outputChatBox(wx.." "..wy.." "..wz) 
end 
addEventHandler ( "onClientClick", getRootElement(), tworzeniePickupa ) 

Link to comment
function tworzeniePickupa ( button, state, absoluteX, absoluteY, wx, wy, wz, clickedElement ) 
    if state == "down" then 
        outputChatBox(wx.." "..wy.." "..wz) 
    end 
end 
addEventHandler ( "onClientClick", getRootElement(), tworzeniePickupa ) 

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