Jump to content

onClientMarkerHit > createObject > moveObject ERROR


Recommended Posts

I made a script to move an object from point A to point B, it works well when addEventHander is attached to root, but i don't want this moving object(event) to be seen by anyone else but the one who triggered event, so i tried replacing getRootElement() with getLocalPlayer() but its not working, any help?

marker = createMarker(-840.2998046875, -3680.599609375, 44.299999237061) 
hitPlayer = getLocalPlayer() 
function shadesMagic(hitPlayer, matchingDimension) 
    if marker == hitPlayer or matchingDimension then 
        block_1 = createObject(3095,-808.7998046875,-3623.5,52.200000762939,0,146.99157714844,0) 
        moveObject(block_1,600,-835.7998046875,-3623.5,43.200000762939,0,33.00842285156,0) 
    end 
end 
addEventHandler("onClientMarkerHit", getLocalPlayer(), shadesMagic) 

Link to comment

Try triggering a function like this

-- server side  
triggerClientEvent(source,"sth",source) 
-- client side  
addEvent("sth",true) 
addEventHandler("sth",root, 
function () 
marker = createMarker(-840.2998046875, -3680.599609375, 44.299999237061) 
hitPlayer = getLocalPlayer() 
function shadesMagic(hitPlayer, matchingDimension) 
  --  if marker == hitPlayer or matchingDimension then this makes no sense 
block_1 = createObject(3095,-808.7998046875,-3623.5,52.200000762939,0,146.99157714844,0) 
moveObject(block_1,600,-835.7998046875,-3623.5,43.200000762939,0,33.00842285156,0) 
   -- end 
end 
addEventHandler("onClientMarkerHit", marker, shadesMagic) 
end) 

Edited by Guest
Link to comment
You lost me

What's the player defined in your script?

if the player was defined as player then change this

triggerClientEvent(source,"sth",source) 

to

triggerClientEvent(player,"sth",player) 

clear example :

addCommandHandler("sth", 
function (player) 
triggerClientEvent(player,"sth",player) 
end) 

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