Jump to content

Rotating Gate Help (with code)


Recommended Posts

Hey,

Me again :roll:

Well im trying to make a gate open on col shape hit but it isnt working...

Barrier = createObject ( 968, 1544.6271972656, -1630.3720703125, 13.8182258605957, 0, 0, 0 ) 
<colrectangle posX="1534.768" posY="-1630.3720703125" posZ="13.8182258605957" width="100" depth="61.8"/> 
toggle = 0 
  
function toggleBarrier(thePlayer,command) 
    if toggle == 0 then 
        setElementRotation (Barrier, 0, 0, 277) 
        toggle = 1 
    else 
        setElementRotation (Barrier, 0, 0, 0) 
        toggle = 0 
    end 
  
end 
  
function toggleBarrier(thePlayer,command) 
if toggle == 0 then 
        setElementRotation (Barrier, 0, 0, 277) 
        toggle = 1 
    else 
        setElementRotation (Barrier, 0, 0, 0) 
        toggle = 0 
    end 
end 
addEventHandler( "onMarkerHit", marker, toggleBarrier ) 
addEventHandler( "onMarkerHit", marker, toggleBarrier ) 

Please can someone correct me ? Thanks

Link to comment

your whole code is f***ed up

1- there are 2 function with the same name which does the same thing ,

2- you are creating the colshape wrong its not a map file use

createColCircle 
createColCuboid 
createColRectangle 
createColSphere 
createColTube 
createColPolygon 

3- next time use [lua.][/lua] without the dot

Edited by Guest
Link to comment
your whole code is f***ed up

1- there are 2 function with the same name which does the same thing ,

2- you are creating the colshape wrong its not a map file use

createColCircle 
createColCuboid 
createColRectangle 
createColSphere 
createColTube 
createColPolygon 

3- next time use

  

Dude, the point of this was to ask if someone could correct it for me, can you do so?

Link to comment
Barrier = createObject ( 968, 1544.6271972656, -1630.3720703125, 13.8182258605957, 0, 0, 0 ) 
Col = createColTube(1534.768, -1630.3720703125, 13.8182258605957, 10, 10) 
  
addEventHandler('onColShapeHit', Col, 
     function(hitElement, dim) 
         if getElementType(hitElement) == 'player' then 
               setElementRotation (Barrier, 0, 0, 277) 
         end 
    end 
) 
  
addEventHandler('onColShapeLeave', Col, 
    function(hitElement, dim) 
         if getElementType(hitElement) == 'player' then 
                setElementRotation (Barrier, 0, 0, 0) 
        end 
    end 
) 

not tested but should work

Link to comment
Barrier = createObject ( 968, 1544.6271972656, -1630.3720703125, 13.8182258605957, 0, 0, 0 ) 
Col = createColTube(1544.768, -1630.3720703125, 11.8182258605957, 15, 15) 
  
addEventHandler('onColShapeHit', Col, 
     function(hitElement, dim) 
         if getElementType(hitElement) == 'player' then 
               setElementRotation (Barrier, 0, 0, 277) 
         end 
    end 
) 
  
addEventHandler('onColShapeLeave', Col, 
    function(hitElement, dim) 
         if getElementType(hitElement) == 'player' then 
                setElementRotation (Barrier, 0, 0, 0) 
        end 
    end 
) 

the col shape was a bit high

Link to comment
Dude, the point of this was to ask if someone could correct it for me, can you do so?

Actually, the purpose of this forum is: you have a problem with scripting, we offer guidance on how to fix the problem and how to learn from your mistakes.

Not: fix my script plz.

Link to comment

Does anyone know how to make it move in one sweep, not just cut to the position?

Barrier = createObject ( 968, 1544.69, -1630.8, 13.3, 0, 89, 90 ) 
Col = createColTube(1544.8, -1630.3720703125, 11.8182258605957, 10, 10) 
  
addEventHandler('onColShapeHit', Col, 
     function(hitElement, dim) 
         if getElementType(hitElement) == 'player' then 
               setElementRotation (Barrier, 0, 0, 90) 
         end 
    end 
) 
  
addEventHandler('onColShapeLeave', Col, 
    function(hitElement, dim) 
         if getElementType(hitElement) == 'player' then 
                setElementRotation (Barrier, 0, 90, 90) 
        end 
    end 
)  

Thanks

Link to comment

Hey,

I changed it over to moveobject and its started doing alot of crazy stuff when i enter the colshape, can someone test it for me or tell me whats wrong with it... I think its because of the order setelementrotation was in...

Heres the code

Barrier = createObject ( 968, 1544.69, -1630.8, 13.3, 0, 89, 90 ) 
Col = createColTube(1544.8, -1630.3720703125, 11.8182258605957, 10, 10) 
  
addEventHandler('onColShapeHit', Col, 
     function(hitElement, dim) 
         if getElementType(hitElement) == 'player' then 
           if getTeamName(getPlayerTeam(hitElement))=="Police" then 
            playSoundFrontEnd ( 41 ) 
            moveObject(Barrier, 3000, 1544.69, -1630.8, 13.3, 0, 0, 90) 
           end 
         end 
    end 
) 
  
addEventHandler('onColShapeLeave', Col, 
    function(hitElement, dim) 
         if getElementType(hitElement) == 'player' then 
        if getTeamName(getPlayerTeam(hitElement))=="Police" then 
            moveObject(Barrier, 3000, 1544.69, -1630.8, 13.3, 0, 89, 90) 
        end 
         end 
    end 
) 

Thanks

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