sel3a Posted November 17, 2014 Share Posted November 17, 2014 hello guys, i hope you guys will answer my question!! I'd like to make a moving gate like in real life gate,I have this script but It didn't work, I wont the both object to move right and left same as this one http://max.wilsonsd.org:8080/Clip_Art/Pmpa1/buildings/doors/iron_gate_open_close_hc.gif anyone can help me to make it ? since it didn't work here is the script. i've tried to do this but heh.... didn't work a51gate1 = createObject ( 3049, 2491.2, -1661.3, 14.6 ) a51col = createColCircle ( 2492.2, -1663.3, 14.6 ) function opena51gates(thePlayer) local team = getPlayerTeam(thePlayer) if not team then return end if getTeamName(team) == "Criminals" then moveObject (a51gate1, 8000, 2491.2, -1661.3, 14.6 ) setTimer (moveObject, 3500, 1, a51gate1, 1000, 3049, 2491.2, -1661.3, 14.6, 0, 0, 306) ob1 = setTimer (function () end, 5000, 1) end end addEventHandler( "onColShapeHit", a51col, opena51gates ) end end addEventHandler( "onColShapeHit", a51col, opena51gates ) function closea51gates(thePlayer) local team = getPlayerTeam(thePlayer) if not team then return end if getTeamName(team) == "Criminals" then moveObject (a51gate1, 4000, 2491.2, -1661.3, 14.6 ) end end addEventHandler( "onColShapeLeave", a51col, closea51gates ) Link to comment
Perfect Posted November 18, 2014 Share Posted November 18, 2014 What you really wanna do ? As i can see there is only one object/gate. Post your full script with your two objects/gates. Link to comment
sel3a Posted November 18, 2014 Author Share Posted November 18, 2014 Well u didn't understood me, I meant that can u just help me witth this gate, i want to make like a real door, or a garage, that turn right and then turn back. Or like a real door, that rotate 90° then go back to 0° see what i mean ? thanks. Link to comment
Perfect Posted November 18, 2014 Share Posted November 18, 2014 a51gate1 = createObject ( 3049, 2491.2, -1661.3, 14.6 ) a51col = createColCircle ( 2492.2, -1663.3, 14.6 ) function opena51gates(thePlayer) local team = getPlayerTeam(thePlayer) if not team then return end if (getTeamName(team) == "Criminals") then moveObject (a51gate1, 8000, 2491.2, -1661.3, 14.6, 90, 0, 0 ) end end function closea51gates(thePlayer) local team = getPlayerTeam(thePlayer) if not team then return end if (getTeamName(team) == "Criminals") then moveObject (a51gate1, 4000, 2491.2, -1661.3, 14.6, -90, 0, 0 ) end end addEventHandler( "onColShapeHit", a51col, opena51gates ) addEventHandler( "onColShapeLeave", a51col, closea51gates ) I don't know, which 90 degrees you want to rotate the gate, so adjust that according to your needs. Link to comment
sel3a Posted November 18, 2014 Author Share Posted November 18, 2014 well when i hit the col and after that i leave then hit the col again the gate will rotate too many times, and it will rotate randomly.. Is there any solution ? thanks. Link to comment
Perfect Posted November 19, 2014 Share Posted November 19, 2014 a51gate1 = createObject ( 3049, 2491.2, -1661.3, 14.6 ) a51col = createColCircle ( 2492.2, -1663.3, 14.6 ) function opena51gates(thePlayer) local team = getPlayerTeam(thePlayer) if not team then return end if (getTeamName(team) == "Criminals") then moveObject (a51gate1, 8000, 2491.2, -1661.3, 14.6, 90, 0, 0 ) setTimer(outputChatbox, 9000, 1, "You can go outside the colshape now.", source) end end function closea51gates(thePlayer) local team = getPlayerTeam(thePlayer) if not team then return end if (getTeamName(team) == "Criminals") then moveObject (a51gate1, 4000, 2491.2, -1661.3, 14.6, -90, 0, 0 ) setTimer(outputChatbox, 5000, 1, "You can go inside the colshape now.", source) end end addEventHandler( "onColShapeHit", a51col, opena51gates ) addEventHandler( "onColShapeLeave", a51col, closea51gates ) Only move inside/outside the colshape, when once the message is shown in the chat and say if its still happening. Link to comment
lopezloo Posted November 19, 2014 Share Posted November 19, 2014 Wrong section. https://forum.multitheftauto.com/viewforum.php?f=91 Link to comment
sel3a Posted November 19, 2014 Author Share Posted November 19, 2014 Well still.. Not working pff Anyway fuck it.. i'll try later or i'll ask someone else, thanks mate anyway. Link to comment
roddydennvor Posted November 20, 2014 Share Posted November 20, 2014 ~~ Try This ~~ local Gate = { [1] = createObject(980, 2527.5, 2423.9, 12.6,0,0,0), } local GateName = "DMV Side Gate" exports.pool:allocateElement(Gate[1]) local open = false local function ResetOpenState() open = false end local function closeDoor(thePlayer) moveObject(Gate[1], 3000,2527.5, 2423.9, 12.6, 0, 0, 0) setTimer(ResetOpenState, 1000, 1) end -- Gate code / Using local functions to avoid local function useDoor(thePlayer, commandName, ...) local x, y, z = getElementPosition(thePlayer) local distance = getDistanceBetweenPoints3D(2527.5, 2423.9, 12.6, x, y, z) if (distance<=15) and (open==false) then if (exports.global:hasItem(thePlayer, 64) or exports.global:hasItem(thePlayer, 82)) then moveObject(Gate[1], 3000, 2517.5, 2423.9, 12.6, 0, 0, 0) setTimer(closeDoor, 5000, 1, thePlayer) end end end addCommandHandler("gate", useDoor) Link to comment
sel3a Posted November 20, 2014 Author Share Posted November 20, 2014 Thanks mate just fixed something :PP Thank you mate i really appreciate it. 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