Jump to content

[HELP] Object and Cursor


WelCome

Recommended Posts

Posted

Hello, I have a problem, when I move the cursor, the object becomes invisible

gate = Object(1337,712.61853, 659.00409, 9.94867)

addEventHandler('onClientRender',root,function()
if not isCursorShowing() then return end
local _,_,wx,wy,wz = getCursorPosition()
gate:setPosition(wx,wy,wz)
end)

 

Posted (edited)

function attached to onClientRender event won't work if you used return at least once

gate = Object(1337,712.61853, 659.00409, 9.94867)

addEventHandler('onClientRender',root,function()
	if isCursorShowing() then
		local _,_,wx,wy,wz = getCursorPosition()
		gate:setPosition(wx,wy,wz)
	end
end)

@WelCome

Edited by JeViCo
Posted

@JeViCo What??

Wiki:

Quote

This event is triggered every time GTA renders a new frame. It is required for the DirectX drawing functions, and also useful for other clientside operations that have to be applied repeatedly with very short time differences between them.

No errors

 

Posted
gate = Object(1337,712.61853, 659.00409, 9.94867)

addEventHandler('onClientClick',root,function()
if  isCursorShowing() then 
local _,_,wx,wy,wz = getCursorPosition()
gate:setPosition(wx,wy,wz)
    end 
end)

Try this

  • Moderators
Posted

Do without OOP.

 

gate = createObject(1337, 712.61853, 659.00409, 9.94867)

addEventHandler('onClientClick', root, function(_,_,_,_,wx,wy,wz)
    setElementPosition(gate, wx,wy,wz)
end)

 

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