Bonsai Posted June 29, 2010 Share Posted June 29, 2010 Hi, I want to make a map, but I found a problem, and I don't know how to solve that. I created a Marker. And if a player hits this Marker, an object shall move. But only for the player, who hit that Marker. grav1 = createMarker ( 4974.033203125, -1857.8096923828, 50.550357818604 , "corona" , 8, 0, 0,204, 255) function marker() if source == grav1 then moveObject (obj, 6000, 5010.1752929688,-1853.2252197266, 41.327033996582) end addEventHandler( "onClientMarkerHit", getLocalPlayer(), marker ) end The code is just to let u know how it shall work, its not the full code. Please help me, Bye Link to comment
Wisin Posted June 29, 2010 Share Posted June 29, 2010 First should be like this grav1 = createMarker ( 4974.033203125, -1857.8096923828, 50.550357818604 , "corona" , 8, 0, 0,204, 255) function marker() if source == grav1 then moveObject (obj, 6000, 5010.1752929688,-1853.2252197266, 41.327033996582) end end addEventHandler( "onClientMarkerHit", getLocalPlayer(), marker ) Link to comment
dzek (varez) Posted June 29, 2010 Share Posted June 29, 2010 grav1 = createMarker ( 4974.033203125, -1857.8096923828, 50.550357818604 , "corona" , 8, 0, 0,204, 255) function markerHit(thePlayer,dimension) if (dimension and thePlayer==getLocalPlayer()) then moveObject (obj, 6000, 5010.1752929688,-1853.2252197266, 41.327033996582) end end addEventHandler( "onClientMarkerHit", grav1, markerHit) Link to comment
DiSaMe Posted June 29, 2010 Share Posted June 29, 2010 The script is client-side, so object movement isn't synced. You need to make the script server-side. Alternatively, you can try attaching the event to all players (getRootElement() and checking element type in the function) and leaving the script client-side, but this way is less reliable. Link to comment
dzek (varez) Posted June 29, 2010 Share Posted June 29, 2010 @Doomed_Space_Marine: you can't attach MARKER event to PLAYER.. setting attached element to root element will cause event firing up on EVERY MARKER not EVERY PLAYER. And he didnt want it synced, read 1st post @Bonsai: my script should work. if not - post whole code, as you probably messed up something earlier Link to comment
Bonsai Posted June 29, 2010 Author Share Posted June 29, 2010 Hmm, I'm not that pro at this stuff, so I don't really understand what u mean But, I'll try to explain how it shall work: A Player drives in that marker, so that a Gates opens for him. Every other player has to drive in that marker first too, before that gate is open for them. At my first try, it moved for everyone, so just one player has to drive to the marker. And the script by varez doesn't work at all, at least for me. @varez I made whole new script to test it, so actually, everything should work. function startclient () obj = createObject( 971, 5010.1752929688, -1853.2252197266, 53.170219421387 , 0 , 0 , 0) grav1 = createMarker ( 4974.033203125, -1857.8096923828, 50.550357818604 , "corona" , 8, 0, 0,204, 255) end function markerHit(thePlayer,dimension) if (dimension and thePlayer==getLocalPlayer()) then moveObject (obj, 6000, 5010.1752929688,-1853.2252197266, 41.327033996582) end end addEventHandler( "onClientMarkerHit", grav1, markerHit) addEventHandler( "onClientResourceStart", resourceRoot, startclient ) Link to comment
dzek (varez) Posted June 29, 2010 Share Posted June 29, 2010 when playing type in console "debugscript 3" to debug your code - for the future.. function startclient () obj = createObject( 971, 5010.1752929688, -1853.2252197266, 53.170219421387 , 0 , 0 , 0) grav1 = createMarker ( 4974.033203125, -1857.8096923828, 50.550357818604 , "corona" , 8, 0, 0,204, 255) addEventHandler( "onClientMarkerHit", grav1, markerHit) end function markerHit(thePlayer,dimension) if (dimension and thePlayer==getLocalPlayer()) then moveObject (obj, 6000, 5010.1752929688,-1853.2252197266, 41.327033996582) end end addEventHandler( "onClientResourceStart", resourceRoot, startclient ) and put your code inside LUA tags, not CODE [ lua] -- code here [ /lua] Link to comment
Bonsai Posted June 30, 2010 Author Share Posted June 30, 2010 THX Mate! Works perfect! I'll put map here, when its done, so u know, what u helped for 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