WelCome

[HELP] Object and Cursor

Recommended Posts

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)

 

Share this post


Link to post

Any error in the debugscript?

Share this post


Link to post

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

Share this post


Link to post

@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

 

Share this post


Link to post
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

Share this post


Link to post

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)

 

Share this post


Link to post

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.