Jump to content

How to make a timer gate!!


sel3a

Recommended Posts

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

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

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