BriGhtx3 Posted April 2, 2012 Posted April 2, 2012 function keineAutosBeiMarkern(hitElement) if getElementType(hitElement) == "vehicle" then cancelEvent() end end addEventHandler("onMarkerHit",getRootElement(),keineAutosBeiMarkern) This is my serverside script. When I enter a marker with a vehicle i still get teleported.. How can I change the script that I don't get teleported when entering a marker with a vehicle?
BriGhtx3 Posted April 2, 2012 Author Posted April 2, 2012 I know how to cancel the event in the function, but this would be too much work since I have a lot of markers... So I want to create a general function.
myonlake Posted April 2, 2012 Posted April 2, 2012 I get what you mean, I am not so sure why that script didn't work, though you can try this, which is almost the same. addEventHandler("onMarkerHit", root, function(hitElement, matchingDimension) if getElementType(hitElement) == "vehicle" and matchingDimension then return end end )
Kenix Posted April 2, 2012 Posted April 2, 2012 addEventHandler( 'onMarkerHit', root, function( uHitElement, bMatchingDimension) if getElementType( uHitElement ) == 'player' and isPedInVehicle( uHitElement ) then return end end )
Castillo Posted April 2, 2012 Posted April 2, 2012 You are trying to cancel functions of all markers if the player is on a vehicle?
Kenix Posted April 2, 2012 Posted April 2, 2012 If you not understand .. addEventHandler( 'onMarkerHit', root, function( uHitElement, bMatchingDimension) if getElementType( uHitElement ) == 'player' and isPedInVehicle( uHitElement ) then return end -- Doing something! -- .... end )
BriGhtx3 Posted April 2, 2012 Author Posted April 2, 2012 I know how to do it within the marker function. But I want a GENERAL function where I check it for every marker, because I have too much markers to paste it everywhere For example: I have MarkerXY and when I hit it, I get teleported to interior XX I have MarkerYZ and when I hit it, I get teleported to interior YY I have MarkerAA and when I hit it, I get teleported to interior ZZ Now if I am in a vehicle and hit MarkerXY or MarkerYZ or MarkerAA or any other marker and I am IN a vehicle, the event gets cancelled
Kenix Posted April 2, 2012 Posted April 2, 2012 (edited) Set element data your marker( s ). Add one event handler ( onMarkerHit ) and check if marker have this data. Create table position for all markers. ... P.S Long ago i did write my interior system only 31lines in client side and 153 lines + comments. Also you can make it in map editor, move interior markers create text and etc. Edited April 2, 2012 by Guest
BriGhtx3 Posted April 2, 2012 Author Posted April 2, 2012 If I set the element data for every marker it is the same like pasting it everywhere. But this are simply too much So I need a general function
DNL291 Posted April 2, 2012 Posted April 2, 2012 maybe it works local _markers = getElementsByType("marker") for i,marker in ipairs(_markers) do
X-SHADOW Posted April 3, 2012 Posted April 3, 2012 (edited) addEventHandler( 'onMarkerHit', root, function( uHitElement, bMatchingDimension) if getElementType( uHitElement ) == 'player' and isPedInVehicle( uHitElement ) then local _markers = getElementsByType("marker") for i,marker in ipairs(_markers) do cancelEvent() end end end) Updated ! Edited April 3, 2012 by Guest
BriGhtx3 Posted April 3, 2012 Author Posted April 3, 2012 Thank you but: I need to check whether he is in a vehicle or not. So this script can't work for me. And I also can't work with tables, because then I have to copy each marker to the table.
BriGhtx3 Posted April 3, 2012 Author Posted April 3, 2012 Still the same. I also tried to change it like this: addEventHandler( 'onMarkerHit', root, function( uHitElement, bMatchingDimension) if getElementType( uHitElement ) == 'vehicle' then local _markers = getElementsByType("marker") for i,marker in ipairs(_markers) do cancelEvent() end end end)
X-SHADOW Posted April 3, 2012 Posted April 3, 2012 1 thing to try make it clientSide in meta.xml addEventHandler ( "onClientMarkerHit", getRootElement(), cancelEvent )
drk Posted April 3, 2012 Posted April 3, 2012 Will never work because X-SHADOW only COPY code and paste and think will work. See: https://wiki.multitheftauto.com/wiki/OnMarkerHit There is nothing about cancel onMarkerHit cancel event affection. Try this: Server-side: for _, marker in ipairs ( getElementsByType 'marker' ) do addEventHandler ( 'onMarkerHit', marker, cancelEnter ) end function cancelEnter ( player ) if ( getElementType ( player ) == 'vehicle' or isPedInVehicle ( player ) ) then return end end
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