Big Smoker Posted March 11, 2017 Share Posted March 11, 2017 (edited) 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 March 11, 2017 by felipebaidoloko Translation Link to comment
#BrosS Posted March 11, 2017 Share Posted March 11, 2017 (edited) Use "onMarkerHit" moveObject Edited March 11, 2017 by #BrosS Link to comment
Moderators Citizen Posted March 11, 2017 Moderators Share Posted March 11, 2017 From: https://forum.multitheftauto.com/topic/33519-helphow-to-make-an-movement-gate/?do=findComment&comment=843650 You will need : createObject to create the gate createMarker to create the 2 markers you will need onMarkerHit attached to the created markers (make sure to ignore the "vehicle" hitElement type to prevent triggering it twice if in vehicle) moveObject to open/close the gate setElementData / getElementData on the gate to save and toggle the state of the gate (if it's open or closed) Link to comment
^iiEcoo'x_) Posted March 11, 2017 Share Posted March 11, 2017 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
kieran Posted June 8, 2017 Share Posted June 8, 2017 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
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