Jump to content

Vehicle enters markers


BriGhtx3

Recommended Posts

Posted
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?

Currently working on gamemodes :

  • Reallife Script 70%
  • Breakout Script 10%
Posted

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.

Currently working on gamemodes :

  • Reallife Script 70%
  • Breakout Script 10%
Posted

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 
) 

If I helped you, please click the like button on the right ;) Thanks!

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

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

Posted

You are trying to cancel functions of all markers if the player is on a vehicle?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

If you not understand ..

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

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

Posted

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

Currently working on gamemodes :

  • Reallife Script 70%
  • Breakout Script 10%
Posted (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 by Guest

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

Posted

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

Currently working on gamemodes :

  • Reallife Script 70%
  • Breakout Script 10%
Posted

maybe it works

local _markers = getElementsByType("marker") 
    for i,marker in ipairs(_markers) do 

Please do not PM me with scripting related question nor support, use the forums instead.

Posted (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 by Guest

My ingame nickname : Ops!

-DeathMatch GameMode By Ops! : 5%

Posted

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.

Currently working on gamemodes :

  • Reallife Script 70%
  • Breakout Script 10%
Posted

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) 

Currently working on gamemodes :

  • Reallife Script 70%
  • Breakout Script 10%
Posted

1 thing to try

make it clientSide in meta.xml

addEventHandler ( "onClientMarkerHit", getRootElement(), cancelEvent ) 

My ingame nickname : Ops!

-DeathMatch GameMode By Ops! : 5%

Posted

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 

EPT Team Server Development: 0%

Learning C++ | C++ is amazing xD

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