Jump to content

moving gate script


Recommended Posts

Try this: http://games.albonius.com/index.php?topic=242.msg697#msg697

-- All gates and their data 
gate = { 
    -- ObjectID     closeX      closeY      closeZ      openX       openY       openZ       rotX    rotY    rotZ    colX    colY    colZ    colRad  Group   Scale 
    [1]={ 11327,    1587.7,     -1638.4,    14.8,       1587.7,     -1638.4,    20,         0,      0,      90,     1588,   -1638,  10,     10,     "ISA",  1 }, 
    [2]={ 10671,    -1631,      688.4,      9.587,      -1631,      688.4,      20.187,     0,      0,      90,     -1631,  688,    7.187,  10,     "ISA",  2 }, 
    [3]={ 11327,    2334.6,     2443.7,     7.70,       2334.6,     2443.7,     15.70,      0,      0,      -30,    2334.6, 2443.7, 5.70,   10,     "ISA",  1.3 }, 
    [4]={ 11327,    2294,       2497.4,     5.3,        2294,       2497.4,     14.3,       0,      0,      0,      2294,   2497.6, 4.3,    15,     "ISA",  1.2 }, 
} 
  
-- Global data members 
gates = { } 
cols =  { } 
ocpenSpeed = 3000 
  
-- Add all gates 
function mapLoad ( name ) 
    for k=1, #gate do 
        -- Create objects 
        local gat = createObject( gate[k][1], gate[k][2], gate[k][3], gate[k][4], gate[k][8], gate[k][9], gate[k][10] ) 
        local col = createColCircle( gate[k][11], gate[k][12], gate[k][13], gate[k][14] ) 
        setObjectScale( gat, gate[k][16] ) 
     
        -- Assign arrays of object pointers 
        gates[col] = gat 
        cols[col] = k 
         
        -- Add event handlers 
        addEventHandler("onColShapeHit", col, openGate ) 
        addEventHandler("onColShapeLeave", col, closeGate ) 
    end 
end 
addEventHandler ( "onResourceStart", getResourceRootElement(), mapLoad ) 
  
-- Gates open                            
function openGate(player) 
    local ID = cols[source] 
    if isElement(player) and ( getElementData(player, "Group" ) == gate[ID][15] or  
        getElementData(player, "Group" ) == "ACRP" ) or getPlayerTeam(player) == getTeamFromName("Staff") then 
        moveObject(gates[source], ocpenSpeed, gate[ID][5], gate[ID][6], gate[ID][7] )  
    end 
end   
-- Gates close 
function closeGate(player) 
    local ID = cols[source] 
    if isElement(player) and ( getElementData(player, "Group" ) == gate[ID][15] or  
        getElementData(player, "Group" ) == "ACRP" ) or getPlayerTeam(player) == getTeamFromName("Staff") then 
        moveObject(gates[source], ocpenSpeed, gate[ID][2], gate[ID][3], gate[ID][4] )  
    end 
end 

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