`Dmz Posted February 28, 2010 Share Posted February 28, 2010 Hi, MTA community. I have one problem with server side event onMarkerHit, it doesn't works, but when I write similar script client-side, it works, so is it bug or scripting mistake? vokJuodas = createMarker(197.1796875, 168.767578125, 1002.0234375, "cylinder", 1.5, 1, 1, 1) setElementInterior(vokJuodas,3) addEventHandler("onMarkerHit", vokJuodas, function () triggerClientEvent("vokPuolimas", getRootElement()) end) Link to comment
50p Posted February 28, 2010 Share Posted February 28, 2010 It's a bug to me. It's been around since DP1. You should addEventHandler to root element (resource's root element is better) and make sure that the marker hit is the marker you created. Link to comment
`Dmz Posted March 1, 2010 Author Share Posted March 1, 2010 Maybe you can show me how because I haven't any idea how to do it, I tried it to do it with event onPlayerMarkerHit, but it was the same thing like with onMarkerHit event. Link to comment
50p Posted March 1, 2010 Share Posted March 1, 2010 myMarker = createMarker( ......... ) addEventHandler( "onMarkerHit", getResourceRootElement(), function( ) if ( source == myMarker ) then -- You hit your marker, do whatever you want here end end ) Link to comment
`Dmz Posted March 2, 2010 Author Share Posted March 2, 2010 I don't works this is my code look maybe i did something wrong here? indJuodas = createMarker(216.9921875, 79.0078125, 1004.0390625, "cylinder", 1.5, 1, 1, 1) setElementInterior(indJuodas,6) addEventHandler( "onMarkerHit", getResourceRootElement(), function( ) if ( source == indJuodas ) then outputChatBox("Boo") end end ) Link to comment
50p Posted March 2, 2010 Share Posted March 2, 2010 Try this: function markerHit( ) if ( source == indJuodas ) then outputChatBox("Boo") end end addEventHandler( "onRecourseStart", getResourceRootElement(), function( ) indJuodas = createMarker(216.9921875, 79.0078125, 1004.0390625, "cylinder", 1.5, 1, 1, 1) setElementInterior(indJuodas,6) addEventHandler( "onMarkerHit", this, markerHit ) end ) Link to comment
Castillo Posted March 2, 2010 Share Posted March 2, 2010 indJuodas = createMarker(216.9921875, 79.0078125, 1004.0390625, "cylinder", 1.5, 1, 1, 1) setElementInterior(indJuodas,6) function markerHit() if ( source == indJuodas ) then outputChatBox("Boo") end end addEventHandler ("onMarkerHit", getRootElement(), markerHit) this should work Link to comment
`Dmz Posted March 2, 2010 Author Share Posted March 2, 2010 SolidSnake14 said: indJuodas = createMarker(216.9921875, 79.0078125, 1004.0390625, "cylinder", 1.5, 1, 1, 1) setElementInterior(indJuodas,6) function markerHit() if ( source == indJuodas ) then outputChatBox("Boo") end end addEventHandler ("onMarkerHit", getRootElement(), markerHit) this should work No it don't works to. Link to comment
Castillo Posted March 2, 2010 Share Posted March 2, 2010 are u sure? cause i tryed it and does it what it says, "Boo" that says when i enter in the marker. the script its server-side Link to comment
`Dmz Posted March 2, 2010 Author Share Posted March 2, 2010 SolidSnake14 said: are u sure? cause i tryed it and does it what it says, "Boo" that says when i enter in the marker.the script its server-side Yes this is server-side, but it don't works I don't lie. Maybe something wrong with my all script but what then if it is. Link to comment
Castillo Posted March 2, 2010 Share Posted March 2, 2010 must be your other script parts because this code works i tested it. Link to comment
DutchCaffeine Posted March 2, 2010 Share Posted March 2, 2010 50p said: Try this: function markerHit( ) if ( source == indJuodas ) then outputChatBox("Boo") end end addEventHandler( "onRecourseStart", getResourceRootElement(), function( ) indJuodas = createMarker(216.9921875, 79.0078125, 1004.0390625, "cylinder", 1.5, 1, 1, 1) setElementInterior(indJuodas,6) addEventHandler( "onMarkerHit", this, markerHit ) end ) This should work, but the variable this is not defined! The code with the variable this defined this = getResourceRootElement(getThisResource()) function markerHit( ) if ( source == indJuodas ) then outputChatBox("Boo") end end addEventHandler( "onRecourseStart", getResourceRootElement(), function( ) indJuodas = createMarker(216.9921875, 79.0078125, 1004.0390625, "cylinder", 1.5, 1, 1, 1) setElementInterior(indJuodas,6) addEventHandler( "onMarkerHit", this, markerHit ) end ) Link to comment
50p Posted March 2, 2010 Share Posted March 2, 2010 Alexander said: 50p said: Try this: function markerHit( ) if ( source == indJuodas ) then outputChatBox("Boo") end end addEventHandler( "onRecourseStart", getResourceRootElement(), function( ) indJuodas = createMarker(216.9921875, 79.0078125, 1004.0390625, "cylinder", 1.5, 1, 1, 1) setElementInterior(indJuodas,6) addEventHandler( "onMarkerHit", this, markerHit ) end ) This should work, but the variable this is not defined! The code with the variable this defined this = getResourceRootElement(getThisResource()) function markerHit( ) if ( source == indJuodas ) then outputChatBox("Boo") end end addEventHandler( "onRecourseStart", getResourceRootElement(), function( ) indJuodas = createMarker(216.9921875, 79.0078125, 1004.0390625, "cylinder", 1.5, 1, 1, 1) setElementInterior(indJuodas,6) addEventHandler( "onMarkerHit", this, markerHit ) end ) You have to read wiki more often. https://wiki.multitheftauto.com/wiki/AddEventHandler 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