Jump to content

Create gate / lift marker open / closed


Big Smoker

Recommended Posts

Good night, I'm trying to create a gate script too, but I want to make one that makes a mark and only opens the door when the player is inside ... when the player enters inside the mark the gate opens and then closes. . Can someone help me? In case I want to do this for an elevator I need to put in the map of my server ... and putting a gate by command will not work well there I need an automatic THANK
YOU FROM AFTER

Att

~ Baido

Edited by felipebaidoloko
Translation
Link to comment
  • Moderators

From: https://forum.multitheftauto.com/topic/33519-helphow-to-make-an-movement-gate/?do=findComment&comment=843650

You will need :

Link to comment
local Marker = createMarker ( ... )
local object = createObject ( ... )

addEventHandler ("onMarkerHit",root,
  function ( player )
    if source == Marker then
      if getElementType ( player ) == "player" and not isPedInVehicle ( player ) then 
        moveObject ( object , x , y , z ) 
        end
      end
    end
  )

addEventHandler ("onMarkerLeave",root,
  function ( player )
    if source == Marker then
      if getElementType ( player ) == "player" and not isPedInVehicle ( player ) then 
        moveObject ( object , x , y , z ) 
        end
      end
    end
  )

 

Link to comment
  • 2 months later...

If you don't want to over complicate it I messed around with something and it worked, I am fresh at scripting, but I am learning slowly :) here's the extremely basic one I made (It is NOT group specific, it opens for ALL players unless you add it to open for just groups,)

 

object = createObject(980, x, y, z, rx, ry, rz) --!<rx,ry,rz are the rotations of the element, x,y,z is the position>
marker = createMarker(x, y, z, "cylinder", 7, 100, 0, 0, 0) --!<"cylinder", "carona" etc are types of markers, next is size, R,G,B and alpha>

function gateopen(player) --!<This is where we will write the function to move the gate>

	moveObject(object, speed, x,y,z) --!<object is the first line, then time (in ms) and xyz>

end --!<You MUST end the function>

addEventHandler("onMarkerHit",marker,gateopen) --!<If a player hits the marker, the function will be triggered, ("Command", marker, function)>

function gateclose(player) --!<Function to close the gate>

	moveObject(object, speed, x,y,z) --!<It will move on rotations too!>

end

addEventHandler("onMarkerLeave",marker,gateclose) --!<This will close the gate when the player leaves the marker>

Hope it helps!  here is the original YouTube video! (he put object where marker should be on handler, so it didn't work for him)

 

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