hxv Posted June 4, 2011 Share Posted June 4, 2011 How to get ground position by mouse click, my scripts: Client-side: addEvent("getGroundPosition", true) function getGround(player) local x,y,z = getElementPosition(source) local worldposition = getGroundPosition(x,y,z) outputChatBox("Ground position: " .. x .. " , " .. y .. " , " .. z .. " ") end addEventHandler("getGroundPosition", getRootElement(), getGround) Server-side: addEvent("getGroundPosition", true) function worldClicked( button, state, player ) if button == "left" and state == "down" then if isPedOnGround ( player ) then triggerClientEvent ("getGroundPosition", player) end end end addEventHandler( "onElementClicked", getRootElement(), worldClicked ) It doesn't work ;x what is the problem? Link to comment
Aibo Posted June 4, 2011 Share Posted June 4, 2011 you're not passing any coordinates of the click, and getting ground position at player position. and ground is not an element, so it will not trigger onElementClicked event. you can try using onPlayerClick event, though i really dont see a point in involving server in something that can be done clientside entirely. Link to comment
hxv Posted June 4, 2011 Author Share Posted June 4, 2011 you're not passing any coordinates of the click, and getting ground position at player position. and ground is not an element, so it will not trigger onElementClicked event. you can try using onPlayerClick event, though i really dont see a point in involving server in something that can be done clientside entirely. Thank's onPlayerClick event very helped me. Link to comment
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