Jump to content

How to make a timer gate!!


sel3a

Recommended Posts

Posted

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 ) 
  
  

Posted

What you really wanna do ?

As i can see there is only one object/gate.

Post your full script with your two objects/gates.

Multi Theft Auto Player since middle of 2011.

Everybody want to act Crazy/Smart/Intelligent/Different/Unique/Innocent and Thats why I am Perfect.

Posted

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.

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

Multi Theft Auto Player since middle of 2011.

Everybody want to act Crazy/Smart/Intelligent/Different/Unique/Innocent and Thats why I am Perfect.

Posted

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.

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

Multi Theft Auto Player since middle of 2011.

Everybody want to act Crazy/Smart/Intelligent/Different/Unique/Innocent and Thats why I am Perfect.

Posted

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

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