Jump to content

Vehicle enters markers


BriGhtx3

Recommended Posts

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?

Link to comment

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 
) 

Link to comment
addEventHandler( 'onMarkerHit', root, 
    function( uHitElement, bMatchingDimension) 
        if getElementType( uHitElement ) == 'player' and isPedInVehicle( uHitElement ) then 
            return 
        end 
    end 
) 

Link to comment

If you not understand ..

addEventHandler( 'onMarkerHit', root, 
    function( uHitElement, bMatchingDimension) 
        if getElementType( uHitElement ) == 'player' and isPedInVehicle( uHitElement ) then 
            return 
        end 
        -- Doing something! 
        -- .... 
    end 
) 
  

Link to comment

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

Link to comment

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 by Guest
Link to comment
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 by Guest
Link to comment

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) 

Link to comment

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 

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