Jump to content

Simple Gates using Col-Shape


Ab-47

Recommended Posts

What does this do?

Simple, enter the col-shape forcing the gate to move the the next co-ordinates. Using these co-ordinates determines which ways you'd like the gate to move, Left Right, Down, Up. Setting elements rotations whilst moving would come in a next step in scripting, for this simple script I'll only add an adjustment to the starting position which we call: Closed.

   gate = createObject( ID, x, y, z ) --Object ID (Airport Gate=978) & Co-Ordinates of your gates start of position. 
   setElementRotation ( gate, x, y, z ) --Co-Ordinates to your start of rotation 
   gatecol = createColCircle ( x, y, radius ) --Co-Ordinates "X" and "Y" and the radius, I use 15 as default. 
  
function openagates(thePlayer) 
        if getElementModel( thePlayer ) == 217 then --Will open only if the player is in the male staff skin 
        moveObject ( gate, speed, x, y, z ) --The speed in which 7000 is slow and 2000 is fast to open, Co-Ordinates for the gate to move to. 
        end 
end 
addEventHandler( "onColShapeHit", gatecol, openagates ) --Event Handler to trigger the function 
  
function closeagates(thePlayer) 
        if getElementModel( thePlayer ) == 217 then --Will close only if the player is in the male staff skin 
       moveObject (gate1, speed, x, y, z) --The speed in which 7000 is slow and 1000 is fast to open, Co-Ordinates for the gate to close. 
        end 
end 
addEventHandler( "onColShapeLeave", gatecol, closeagates ) --Event Handler to trigger the function 

How to construct it?

Simple fill in the co-ordinates and values to whichever position you like, with whatever object ID you want to use, add the col-shapes co-ordinates where when the player enters the col-shape it triggers the function. You can also change that "if" statement to any other way of opening it, like getPedOccupation or getPlayerTeam etc.

For more information follow a forum PM or contact me via IRC @ irc.gtanet.com / #UIP

Link to comment
Wrong section.

Which board should it be in? Board says; 'Showroom', I'm clearly showing my script to the public just telling them how to construct it in whichever coods they want. Hmm, I've been here for a small while, and I'm pretty sure this is the correct place.

(Correct me if I'm wrong, please) And thanks.

Link to comment
  • 2 weeks later...
  • 1 month later...

With the help with Castillo(Solidsnake14) You can have it 3 ways:

By skin:

gate = createObject( ID, x, y, z ) --Object ID (Airport Gate=978) & Co-Ordinates of your gates start of position. 
   setElementRotation ( gate, x, y, z ) --Co-Ordinates to your start of rotation 
   gatecol = createColCircle ( x, y, radius ) --Co-Ordinates "X" and "Y" and the radius, I use 15 as default. 
  
function openagates(thePlayer) 
        if getElementModel( thePlayer ) == PutSkinHear then 
        moveObject ( gate, speed, x, y, z ) --The speed in which 7000 is slow and 2000 is fast to open, Co-Ordinates for the gate to move to. 
        end 
end 
addEventHandler( "onColShapeHit", gatecol, openagates ) --Event Handler to trigger the function 
  
function closeagates(thePlayer) 
        if getElementModel( thePlayer ) == PutSkinHear then  
       moveObject (gate1, speed, x, y, z) --The speed in which 7000 is slow and 1000 is fast to open, Co-Ordinates for the gate to close. 
        end 
end 
addEventHandler( "onColShapeLeave", gatecol, closeagates ) --Event Handler to trigger the function 

By team:

gate = createObject( putObjectIdHear, PutXHear, PutYHear, PutZHear ) --Object ID (Airport Gate=978) & Co-Ordinates of your gates start of position. 
gatecol = createColCircle ( putXhear, putYhear, putRadiushear ) --Co-Ordinates "X" and "Y" and the radius, I use 15 as default. 
  
function openagates ( thePlayer ) 
    if ( getElementType ( thePlayer ) == "player" ) then 
        local team = getPlayerTeam ( thePlayer ) 
        local teamName = ( team and getTeamName ( team ) or "" ) 
        if ( teamName == "putTeamHear" ) then 
            moveObject ( gate, 2000, PutXHear, PutYHear, PutZHear ) --The speed in which 7000 is slow and 2000 is fast to open, Co-Ordinates for the gate to move to. 
        else 
            outputChatBox ( "Sorry, you can not open this gate as you are not in the specified groups", thePlayer ) 
        end 
    end 
end 
addEventHandler ( "onColShapeHit", gatecol, openagates ) --Event Handler to trigger the function 
  
function closeagates(thePlayer) 
    if ( getElementType ( thePlayer ) == "player" ) then 
        local team = getPlayerTeam ( thePlayer ) 
        local teamName = ( team and getTeamName ( team ) or "" ) 
        if ( teamName == "PutTeamNameHear" ) then 
            moveObject ( gate, 2000, putOrriginalXhear, putOrriginalYhear, putorriginalZhear ) --The speed in which 7000 is slow and 1000 is fast to open, Co-Ordinates for the gate to close. 
        end 
    end 
end 
addEventHandler ( "onColShapeLeave", gatecol, closeagates ) --Event Handler to trigger the function 

By ACL Group:

gate = createObject([b]putObjectIdHear, PutXHear, PutYHear, PutZHear, 0, 0, 0 [/b]) --Object ID (Airport Gate=978) & Co-Ordinates of your gates start of position. 
gatecol = createColCircle ( [b]putXhear, putYhear, putRadiusHear[/b] ) --Co-Ordinates "X" and "Y" and the radius, I use 15 as default. 
  
function openagates ( thePlayer ) 
    if ( getElementType ( thePlayer ) == "player" ) then 
        if ( isPlayerInGroup ( thePlayer ) ) then 
            moveObject ( gate, [b]putXhear, putYhear, putZhear[/b] ) --The speed in which 7000 is slow and 2000 is fast to open, Co-Ordinates for the gate to move to. 
        else 
            outputChatBox ( "Sorry, you can not open this gate as you are not in the specified groups", thePlayer ) 
        end 
    end 
end 
addEventHandler ( "onColShapeHit", gatecol, openagates ) --Event Handler to trigger the function 
  
function closeagates ( thePlayer ) 
    if ( getElementType ( thePlayer ) == "player" ) then 
        if ( isPlayerInGroup ( thePlayer ) ) then 
            moveObject ( gate, [b]putOrriginalXhear, putOrriginalYhear, putorriginalZhear[/b] ) --The speed in which 7000 is slow and 1000 is fast to open, Co-Ordinates for the gate to close. 
        end 
    end 
end 
addEventHandler ( "onColShapeLeave", gatecol, closeagates ) --Event Handler to trigger the function 
  
function isPlayerInGroup ( thePlayer ) 
    local accountName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
    if ( isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Admin" ) ) then 
        return true 
    else 
        return false 
    end 
end 

Hope this helps! Thanks to Castillo for the help in changing the script!

Link to comment
  • 1 year later...

user getElementRotation and setElementRotation :)

rX, rY, rZ = getElementRotation ( gate ) 
setElementRotation ( gate, rX, rY,rZ, true ) 

well for example if you want to rotate from Z then it will look like this

setElementRotation ( gate, 0, 0, rZ+50, true ) 

+ 50 is the amount of rotation.

Link to comment

  • gate = createObject( 980, 2253.1000976563, 512.5, 2 ) --Object ID (Airport Gate=978) & Co-Ordinates of your gates start of position.
    gatecol = createColCircle ( 2253.1000976563, 512.5, 25 ) --Co-Ordinates "X" and "Y" and the radius, I use 15 as default.
    function openagates ( thePlayer )
    if ( getElementType ( thePlayer ) == "player" ) then
    local team = getPlayerTeam ( thePlayer )
    local teamName = ( team and getTeamName ( team ) or "" )
    if ( teamName == "Staff" ) then
    moveObject ( gate, 2000, 2253.1000976563, 512.5, -3 ) --The speed in which 7000 is slow and 2000 is fast to open, Co-Ordinates for the gate to move to.
    else
    outputChatBox ( "Sorry, you can not open this gate as you are not in the specified groups", thePlayer )
    end
    end
    end
    addEventHandler ( "onColShapeHit", gatecol, openagates ) --Event Handler to trigger the function
    function closeagates(thePlayer)
    if ( getElementType ( thePlayer ) == "player" ) then
    local team = getPlayerTeam ( thePlayer )
    local teamName = ( team and getTeamName ( team ) or "" )
    if ( teamName == "Staff" ) then
    moveObject ( gate, 1000, 2253.1000976563, 512.5, 2 ) --The speed in which 7000 is slow and 1000 is fast to open, Co-Ordinates for the gate to close.
    rX, rY, rZ = getElementRotation ( gate )
    setElementRotation ( gate, rX, rY,rZ+272, true )
    end
    end
    end
    addEventHandler ( "onColShapeLeave", gatecol, closeagates ) --Event Handler to trigger the function

i should put it like that ?? o.O , iam a newbie on scripting :S

Link to comment
  • gate = createObject( 980, 2253.1000976563, 512.5, 2 ) --Object ID (Airport Gate=978) & Co-Ordinates of your gates start of position.
    gatecol = createColCircle ( 2253.1000976563, 512.5, 25 ) --Co-Ordinates "X" and "Y" and the radius, I use 15 as default.
    function openagates ( thePlayer )
    if ( getElementType ( thePlayer ) == "player" ) then
    local team = getPlayerTeam ( thePlayer )
    local teamName = ( team and getTeamName ( team ) or "" )
    if ( teamName == "Staff" ) then
    moveObject ( gate, 2000, 2253.1000976563, 512.5, -3 ) --The speed in which 7000 is slow and 2000 is fast to open, Co-Ordinates for the gate to move to.
    else
    outputChatBox ( "Sorry, you can not open this gate as you are not in the specified groups", thePlayer )
    end
    end
    end
    addEventHandler ( "onColShapeHit", gatecol, openagates ) --Event Handler to trigger the function
    function closeagates(thePlayer)
    if ( getElementType ( thePlayer ) == "player" ) then
    local team = getPlayerTeam ( thePlayer )
    local teamName = ( team and getTeamName ( team ) or "" )
    if ( teamName == "Staff" ) then
    moveObject ( gate, 1000, 2253.1000976563, 512.5, 2 ) --The speed in which 7000 is slow and 1000 is fast to open, Co-Ordinates for the gate to close.
    rX, rY, rZ = getElementRotation ( gate )
    setElementRotation ( gate, rX, rY,rZ+272, true )
    end
    end
    end
    addEventHandler ( "onColShapeLeave", gatecol, closeagates ) --Event Handler to trigger the function

i should put it like that ?? o.O , iam a newbie on scripting :S

What are you trying to do? I've cleared it up for you (not tested), but what you're doing is entering a col shape, opening the gate then when you leave the colshape, it closes and rotates to rot z 272 degrees..

  
local gate = createObject( 980, 2253.1000976563, 512.5, 2 ) --Object ID (Airport Gate=978) & Co-Ordinates of your gates start of position. 
local gatecol = createColCircle ( 2253.1000976563, 512.5, 25 ) --Co-Ordinates "X" and "Y" and the radius, I use 15 as default. 
  
local team = getPlayerTeam ( localPlayer ) 
local teamName = (getTeamName ( team )) 
  
function openagates ( thePlayer ) 
    if ( getElementType ( thePlayer ) == "player" ) then 
        if ( teamName == "Staff" ) then 
            moveObject ( gate, 2000, 2253.1000976563, 512.5, -3 ) --The speed in which 7000 is slow and 2000 is fast to open, Co-Ordinates for the gate to move to. 
        else 
            outputChatBox ( "Sorry, you can not open this gate as you are not in the specified groups", thePlayer ) 
        end 
    end 
end 
addEventHandler ( "onColShapeHit", gatecol, openagates ) --Event Handler to trigger the function 
  
function closeagates(thePlayer) 
    if ( getElementType ( thePlayer ) == "player" ) then 
        if ( teamName == "Staff" ) then 
            moveObject ( gate, 1000, 2253.1000976563, 512.5, 2 ) --The speed in which 7000 is slow and 1000 is fast to open, Co-Ordinates for the gate to close. 
            rX, rY, rZ = getElementRotation ( gate ) 
            setElementRotation ( gate, rX, rY,rZ+272, true ) 
        end 
    end 
end 
addEventHandler ( "onColShapeLeave", gatecol, closeagates ) --Event Handler to trigger the function 
  

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...