Jump to content

Rotating Gate Help (with code)


Recommended Posts

Posted

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

Founder of SAUR - Founder/Owner of ARC RPG

Posted (edited)

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

Business System viewtopic.php?f=108&t=35797

Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726

SQLite Tutorial viewtopic.php?f=148&t=38203

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

Founder of SAUR - Founder/Owner of ARC RPG

Posted
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

Business System viewtopic.php?f=108&t=35797

Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726

SQLite Tutorial viewtopic.php?f=148&t=38203

Posted
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

Business System viewtopic.php?f=108&t=35797

Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726

SQLite Tutorial viewtopic.php?f=148&t=38203

Posted

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

Founder of SAUR - Founder/Owner of ARC RPG

Posted

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

Founder of SAUR - Founder/Owner of ARC RPG

Posted

moveObject uses relative rotation.

so to place it back after you've rotated it 90 on Z axis you need to rotate it -90 degrees on Z axis (not by setting object rotation parameters from createObject)

?

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