Tokio

[HELP] How to make setElementPosition only for local player?

Recommended Posts

function test()
setElementPosition ( mark, pos.x,pos.y,pos.z )
end
addEventHandler("onMarkerHit", mark, test)

this is the code. 
if i hit the marker, the element position change for all players.. how to fix this?

sorry for my bad english.

Share this post


Link to post

Just execute the code on the clients side only.
You probably want to create the marker on the client, and send the touch event off to the server so the server can check if the player isn't cheating or similar.

Share this post


Link to post
1 hour ago, 3aGl3 said:

Just execute the code on the clients side only.
You probably want to create the marker on the client, and send the touch event off to the server so the server can check if the player isn't cheating or similar.

The client event is triggered for all clients you'd have to add a check as well then.

Put the code on the client side as well as the marker and use the onClientMarkerHit event.

The event's callback returns 2 arguments, the element that hit the marker and the matching dimension. Ignore the latter for now.

Example:

local mark = createMarker(0, 0, 4, "arrow", 1)

function onHit(element)
  if (element == localPlayer) then -- check if the element is the localPlayer (you)
    outputChatBox("hit")
  end
end
addEventHandler("onClientMarkerHit", mark, onHit)

Hope this helps

Edited by Tails
  • Thanks 1

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.